~siretart/byobu/debian

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh -e
#
#    byobu-status
#    Copyright (C) 2008 Canonical Ltd.
#
#    Authors: Dustin Kirkland <kirkland@canonical.com>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, version 3 of the License.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.

PKG="byobu"

find_script () {
	# Allow for local status scripts
	if [ -x "$HOME/.$PKG/bin/$1" ]; then
		echo "$HOME/.$PKG/bin/$1"
	elif [ -x "/usr/lib/$PKG/$1" ]; then
		echo "/usr/lib/$PKG/$1"
	else
		echo "/bin/true"
	fi
}

# Source configurations
[ -r "/etc/$PKG/statusrc" ] && . "/etc/$PKG/statusrc"
[ -r "$HOME/.$PKG/status" ] && . "$HOME/.$PKG/status"
[ -r "$HOME/.$PKG/statusrc" ] && . "$HOME/.$PKG/statusrc"

export P="$1"
if [ "$P" = "--detail" ]; then
	VER=
	if which dpkg-query >/dev/null; then
		VER=`dpkg-query --show $PKG | awk '{print "-" $2 }'`
	fi
	printf "$PKG$VER Detailed Status Navigation\n  Expand all - zr\t\tCollapse all - zm\n  Expand one - zo\t\tCollapse one - zc\n\n"
	if [ -d "$HOME/.$PKG/bin" ]; then
		DIR="$HOME/.$PKG/bin"
	else
		DIR="/usr/lib/$PKG"
	fi
	for i in `ls "$DIR"`; do
		[ "$i" = "menu" ] && continue
		script=`find_script $i`
		short=`$script --short | sed 's/^\s*//' | sed 's/\s*$//' | sed 's/.{[^}]*}//g'` || true
		detail=`$script --detail | sed '/^$/d' | sed 's/^/\t/g'` || true
		printf "%s\n\t(%s)\n" "$short" "$i"
		[ -n "$detail" ] && printf "%s\n" "$detail"
	done
else
		eval x="\$$P" || exit 1
		[ "$x" = "1" ] || exit 0
		. $(find_script "$P")
fi