mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-08-28 12:56:28 -04:00
Former-commit-id: 8404cf01dd8b828b69d85bdbe520ad422a47b1ae [formerly d037acd5b0]
Former-commit-id: ae522f2d127096c5654748a53f4bffef7e234609
51 lines
2.0 KiB
Bash
Executable File
51 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
_path_gen() {
|
|
local sshyp_path="$HOME/.local/share/sshyp/"
|
|
local sshyp_path_length="${#sshyp_path}"
|
|
readarray -t full_paths < <(find "$HOME"/.local/share/sshyp -type f -exec ls {} \;)
|
|
for path in "${full_paths[@]}"; do
|
|
trimmed_path=$(echo $path | sed 's/.\{4\}$//' | cut -c"$sshyp_path_length"-)
|
|
trimmed_path=$(echo ${trimmed_path// /\\ })
|
|
trimmed_paths+=("$trimmed_path")
|
|
done
|
|
} &&
|
|
|
|
# from this point, this completions script was partially generated by
|
|
# completely (https://github.com/dannyben/completely)
|
|
|
|
_sshyp_completions() {
|
|
if [ "${#COMP_WORDS[@]}" -gt "4" ]; then
|
|
return
|
|
fi
|
|
local cur=${COMP_WORDS[COMP_CWORD]}
|
|
local compline="${COMP_WORDS[@]:1:$COMP_CWORD-1}"
|
|
|
|
case "$compline" in
|
|
'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; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(printf "'%s' " "${trimmed_paths[@]}")" -- "$cur" )
|
|
;;
|
|
|
|
'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
|
|
} &&
|
|
complete -F _sshyp_completions sshyp
|