mirror of
https://github.com/zdharma-continuum/zconvey.git
synced 2026-09-10 07:06:21 -04:00
Extract zc-ls into autoloaded function
This commit is contained in:
parent
cae26c16a6
commit
4a17b6d4bc
38
zc-ls
Normal file
38
zc-ls
Normal file
|
|
@ -0,0 +1,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
|
||||
|
|
@ -22,7 +22,7 @@ fi
|
|||
#
|
||||
# Autoloads
|
||||
#
|
||||
autoload zc zc-rename zc-take
|
||||
autoload zc zc-rename zc-take zc-ls
|
||||
|
||||
#
|
||||
# Global variables
|
||||
|
|
@ -115,44 +115,6 @@ function __zconvey_is_session_active() {
|
|||
# User functions
|
||||
#
|
||||
|
||||
function zc-ls() {
|
||||
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
|
||||
}
|
||||
|
||||
function zc-id() {
|
||||
__zconvey_get_name_of_id "$ZCONVEY_ID"
|
||||
if [ -z "$REPLY" ]; then
|
||||
|
|
|
|||
Loading…
Reference in a new issue