mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-09-05 16:47:14 -04:00
Updated Bash completion to reflect zsh completion behavior
Former-commit-id: ea8d14d76e85500eb1d2a27884b068dc302ea225 Former-commit-id: c631d938ccf3aa6131f54e12249a983f74d4a09d
This commit is contained in:
+21
-26
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env bash
|
# sshyp(1) completion
|
||||||
|
|
||||||
_path_gen() {
|
_path_gen() {
|
||||||
local sshyp_path="$HOME/.local/share/sshyp"
|
local sshyp_path="$HOME/.local/share/sshyp"
|
||||||
@@ -11,35 +11,30 @@ _path_gen() {
|
|||||||
done
|
done
|
||||||
} &&
|
} &&
|
||||||
|
|
||||||
# from this point, this completions script was partially generated by
|
|
||||||
# completely (https://github.com/dannyben/completely)
|
|
||||||
|
|
||||||
_sshyp_completions() {
|
_sshyp_completions() {
|
||||||
local cur=${COMP_WORDS[COMP_CWORD]}
|
local cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")
|
local prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||||
local compline="${compwords[*]}"
|
|
||||||
|
|
||||||
if [ "${#COMP_WORDS[@]}" -gt "2" ] && echo "${COMP_WORDS[@]}" | grep -q 'shear'; then
|
case $prev in
|
||||||
return
|
sshyp )
|
||||||
elif [ "${#COMP_WORDS[@]}" -gt "3" ] && (! echo "${COMP_WORDS[@]}" | grep -q '/' || echo "${COMP_WORDS[@]}" | grep -q 'shear'); then
|
while read -r; do ITEM=${REPLY// /\\ }; COMPREPLY+=( "$ITEM" ); done < <( compgen -W "$(printf "'%s' " "${trimmed_paths[@]}")" -- "$cur" )
|
||||||
return
|
;;
|
||||||
elif [ "${#COMP_WORDS[@]}" -gt "4" ]; then
|
/* )
|
||||||
return
|
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "add edit copy gen shear" -- "$cur" )
|
||||||
fi
|
;;
|
||||||
|
add )
|
||||||
if [[ "$compline" == *'edit'* ]]; then
|
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "folder note password" -- "$cur" )
|
||||||
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "relocate username password note url" -- "$cur" )
|
;;
|
||||||
elif [[ "$compline" == *'copy'* ]]; then
|
copy )
|
||||||
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "username password url note" -- "$cur" )
|
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "note password url username" -- "$cur" )
|
||||||
elif [[ "$compline" == *'add'* ]]; then
|
;;
|
||||||
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "password note folder" -- "$cur" )
|
edit )
|
||||||
elif [[ "$compline" == *'gen'* ]]; then
|
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "note password relocate url username" -- "$cur" )
|
||||||
|
;;
|
||||||
|
gen )
|
||||||
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "update" -- "$cur" )
|
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" )
|
esac
|
||||||
else
|
|
||||||
while read -r; do ITEM=${REPLY// /\\ }; COMPREPLY+=( "$ITEM" ); done < <( compgen -W "help version tweak add gen edit copy shear sync $(printf "'%s' " "${trimmed_paths[@]}")" -- "$cur" )
|
|
||||||
fi
|
|
||||||
|
|
||||||
} &&
|
} &&
|
||||||
_path_gen && complete -F _sshyp_completions sshyp
|
_path_gen && complete -F _sshyp_completions sshyp
|
||||||
|
|||||||
Reference in New Issue
Block a user