improved z.sh a bit

This commit is contained in:
Rudis Muiznieks 2025-03-20 12:38:44 -05:00
parent 1e620361e1
commit f13d71d44f
Signed by: rudism
GPG key ID: CABF2F86EF7884F9

View file

@ -8,22 +8,25 @@ _z_exec() {
return $?
}
_z_completions() {
complete $(_z_exec "select alias from jump_list order by alias")
}
function completion/z {
OPTIONS=( #>#
"h:; show help text"
"l:; list aliases"
"a:; add a new alias"
array OPTIONS \
"h:; show help text" \
"l:; list aliases" \
"a:; add a new alias" \
"r:; remove alias"
) #<#
command -f completion//parseoptions -n
argnum="${WORDS[#]}"
if [ "$ARGOPT" = "-" ] && [ "$argnum" -eq 1 ]; then
command -f completion//completeoptions
elif [ -z "$ARGOPT" ] && [ "$argnum" -eq 1 ]; then
complete -T $(_z_exec "select alias from jump_list")
_z_completions
elif [ "$ARGOPT" = "r" ] && [ "$argnum" -eq 2 ]; then
complete -T $(_z_exec "select alias from jump_list")
_z_completions
elif [ "${WORDS[2]}" = "-a" ] && [ "$argnum" -eq 3 ]; then
complete -T -S '/' -d
fi