mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-09-03 23:57:17 -04:00
Updated bash completion for #24
This commit is contained in:
+20
-27
@@ -15,36 +15,29 @@ _path_gen() {
|
|||||||
# completely (https://github.com/dannyben/completely)
|
# completely (https://github.com/dannyben/completely)
|
||||||
|
|
||||||
_sshyp_completions() {
|
_sshyp_completions() {
|
||||||
if [ "${#COMP_WORDS[@]}" -gt "4" ]; then
|
local cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
|
local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")
|
||||||
|
local compline="${compwords[*]}"
|
||||||
|
|
||||||
|
if [ "${#COMP_WORDS[@]}" -gt "3" ] && (! echo "${COMP_WORDS[@]}" | grep -q '/' || echo "${COMP_WORDS[@]}" | grep -q 'shear'); then
|
||||||
|
return
|
||||||
|
elif [ "${#COMP_WORDS[@]}" -gt "4" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
local cur=${COMP_WORDS[COMP_CWORD]}
|
|
||||||
local compline="${COMP_WORDS[@]:1:$COMP_CWORD-1}"
|
|
||||||
|
|
||||||
case "$compline" in
|
if [[ "$compline" == *'edit'* ]]; then
|
||||||
'add password'* | 'add -p'* | 'add note'* | 'add -n'* | 'add folder'*| 'add -f'* | 'edit relocate'* | 'edit -r'* | 'edit username'* | 'edit -u'* | 'edit password'* | 'edit -p'* | 'edit url'* | 'edit -l'* | 'edit note'* | 'edit -n'* | 'copy username'* | 'copy -u'* | 'copy password'* | 'copy -p'* | 'copy note'* | 'copy -n'* | 'copy url'* | 'copy -l'* | 'gen update'* | 'gen -u'*)
|
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "relocate username password note url" -- "$cur" )
|
||||||
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(printf "'%s' " "${trimmed_paths[@]}")" -- "$cur" )
|
elif [[ "$compline" == *'copy'* ]]; then
|
||||||
;;
|
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "username password url note" -- "$cur" )
|
||||||
|
elif [[ "$compline" == *'add'* ]]; then
|
||||||
|
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "password note folder" -- "$cur" )
|
||||||
|
elif [[ "$compline" == *'gen'* ]]; then
|
||||||
|
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "update" -- "$cur" )
|
||||||
|
elif [[ "$compline" == '/'* ]]; then
|
||||||
|
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "add gen edit copy shear" -- "$cur" )
|
||||||
|
else
|
||||||
|
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "help version tweak add gen edit copy shear sync $(printf "'%s' " "${trimmed_paths[@]}")" -- "$cur" )
|
||||||
|
fi
|
||||||
|
|
||||||
'edit'*)
|
|
||||||
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "relocate username password note url" -- "$cur" )
|
|
||||||
;;
|
|
||||||
|
|
||||||
'copy'*)
|
|
||||||
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "username password url note" -- "$cur" )
|
|
||||||
;;
|
|
||||||
|
|
||||||
'add'*)
|
|
||||||
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "password note folder" -- "$cur" )
|
|
||||||
;;
|
|
||||||
|
|
||||||
'gen'*)
|
|
||||||
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "update" -- "$cur" )
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "help version tweak add gen edit copy shear sync $(printf "'%s' " "${trimmed_paths[@]}")" -- "$cur" )
|
|
||||||
;;
|
|
||||||
|
|
||||||
esac
|
|
||||||
} &&
|
} &&
|
||||||
_path_gen && complete -F _sshyp_completions sshyp
|
_path_gen && complete -F _sshyp_completions sshyp
|
||||||
|
|||||||
Reference in New Issue
Block a user