1#!/bin/sh -e
2#
3#    session: tmux session name
4#
5#    Copyright (C) 2013-2014 Dustin Kirkland <kirkland@byobu.org>
6#
7#    Authors: Dustin Kirkland <kirkland@byobu.org>
8#
9#    This program is free software: you can redistribute it and/or modify
10#    it under the terms of the GNU General Public License as published by
11#    the Free Software Foundation, version 3 of the License.
12#
13#    This program is distributed in the hope that it will be useful,
14#    but WITHOUT ANY WARRANTY; without even the implied warranty of
15#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16#    GNU General Public License for more details.
17#
18#    You should have received a copy of the GNU General Public License
19#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
21__session_detail() {
22	tmux list-sessions
23}
24
25__session() {
26	# Note: This will only work in byobu-tmux
27	case "$BYOBU_BACKEND" in
28		tmux)
29			local count=$(tmux list-sessions 2>/dev/null | grep -v "^_" | wc -l)
30			if [ $count -gt 1 ]; then
31				color u W k; printf "${ICON_SESSION}#S"; color --
32			else
33				echo
34			fi
35		;;
36		screen)
37			local count=$(screen -ls | grep "^\s\+.*)$" | wc -l)
38			if [ $count -gt 1 ]; then
39				color u W k; printf "${ICON_SESSION}%S"; color --
40			else
41				echo
42			fi
43		;;
44	esac
45}
46
47# vi: syntax=sh ts=4 noexpandtab
48