mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-08-28 04:46:34 -04:00
Former-commit-id: 7179fd168dd5c5a68854a72efe6a00153b97f1e5 Former-commit-id: 3329e42498daa2a78295bcd8949d8c7281d3575b
46 lines
2.0 KiB
Bash
Executable File
46 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
_path_gen() {
|
|
local sshyp_path="$HOME/.local/share/sshyp"
|
|
local glob_status=$(shopt -p globstar)
|
|
[ -z "${glob_status##*u*}" ] && shopt -s globstar # if recursive globbing is disabled, enable it
|
|
local full_paths=("$sshyp_path"/**/*.gpg)
|
|
$glob_status # set recursive globbing to user default
|
|
for path in "${full_paths[@]}"; do
|
|
trimmed_paths+=("${path:${#sshyp_path}:-4}")
|
|
done
|
|
} &&
|
|
|
|
# from this point, this completions script was partially generated by
|
|
# completely (https://github.com/dannyben/completely)
|
|
|
|
_sshyp_completions() {
|
|
local cur=${COMP_WORDS[COMP_CWORD]}
|
|
local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")
|
|
local compline="${compwords[*]}"
|
|
|
|
if [ "${#COMP_WORDS[@]}" -gt "2" ] && echo "${COMP_WORDS[@]}" | grep -q 'shear'; then
|
|
return
|
|
elif [ "${#COMP_WORDS[@]}" -gt "3" ] && (! echo "${COMP_WORDS[@]}" | grep -q '/' || echo "${COMP_WORDS[@]}" | grep -q 'shear'); then
|
|
return
|
|
elif [ "${#COMP_WORDS[@]}" -gt "4" ]; then
|
|
return
|
|
fi
|
|
|
|
if [[ "$compline" == *'edit'* ]]; then
|
|
while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "relocate username password note url" -- "$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 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
|