improved z.sh completion for yash
This commit is contained in:
parent
7cfe2b103e
commit
d446bf51c4
1 changed files with 12 additions and 4 deletions
16
yash/z.sh
16
yash/z.sh
|
@ -1,3 +1,6 @@
|
|||
# shellcheck shell=sh
|
||||
# shellcheck disable=SC2001 disable=SC2034 disable=SC2046 disable=2164
|
||||
|
||||
JUMP_LIST=~/.config/z/jump_list
|
||||
|
||||
_z_exec() {
|
||||
|
@ -14,10 +17,15 @@ function completion/z {
|
|||
) #<#
|
||||
|
||||
command -f completion//parseoptions -n
|
||||
if [ -z "$ARGOPT" ] || [ "$ARGOPT" = "r" ]; then
|
||||
complete -T $(_z_exec "select alias from jump_list")
|
||||
elif [ "$ARGOPT" = "-" ]; then
|
||||
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")
|
||||
elif [ "$ARGOPT" = "r" ] && [ "$argnum" -eq 2 ]; then
|
||||
complete -T $(_z_exec "select alias from jump_list")
|
||||
elif [ "${WORDS[2]}" = "-a" ] && [ "$argnum" -eq 3 ]; then
|
||||
complete -T -S '/' -d
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -46,7 +54,7 @@ _z_add() {
|
|||
echo "Directory not found: $dir"
|
||||
return 1
|
||||
fi
|
||||
fullpath=$(cd "$dir"; pwd)
|
||||
fullpath=$(realpath "$dir")
|
||||
if [ ! -d "$fullpath" ]; then
|
||||
echo "Could not change to directory: $fullpath"
|
||||
return 1
|
||||
|
|
Loading…
Add table
Reference in a new issue