-
Notifications
You must be signed in to change notification settings - Fork 2
/
zc-ls
38 lines (31 loc) · 1.22 KB
/
zc-ls
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
setopt localoptions extendedglob clobber
integer idx is_locked
local name busyfile busywith
for (( idx = 1; idx <= 100; idx ++ )); do
name=""
busywith=""
__zconvey_is_session_active "$idx" && is_locked=1 || is_locked=0
__zconvey_get_name_of_id "$idx"
name="$REPLY"
busyfile="$ZCONVEY_OTHER_DIR/${idx}.busy"
[[ -e "$busyfile" && "$idx" != "$ZCONVEY_ID" ]] && busywith=" \033[1;33m(BUSY: $(<$busyfile))\033[0m"
if [[ "$is_locked" = "0" && -n "$name" ]]; then
print "\033[1;31m(ABSENT)\033[0m ID: $idx, NAME: $name"
elif [[ "$is_locked" = "0" && -z "$name" ]]; then
# Don't inform about absent, nameless sessions
:
elif [[ "$is_locked" = "1" && -z "$name" ]]; then
if [ "$idx" = "$ZCONVEY_ID" ]; then
print "\033[1;32m\033[4m(CURRENT) ID: $idx\033[0m$busywith"
else
print "\033[1;33m(ON-LINE)\033[0m ID: $idx$busywith"
fi
elif [[ "$is_locked" = "1" && -n "$name" ]]; then
if [ "$idx" = "$ZCONVEY_ID" ]; then
print "\033[1;32m\033[4m(CURRENT) ID: $idx, NAME: $name\033[0m$busywith"
else
print "\033[1;33m(ON-LINE)\033[0m ID: $idx, NAME: $name$busywith"
fi
fi
done
# vim:ft=zsh