Further bash-completion work

This commit is contained in:
Jon-William Lewis
2016-02-15 16:23:01 -06:00
parent d1140974f4
commit 051546691f
2 changed files with 6 additions and 5 deletions

View File

@@ -22,7 +22,7 @@ _sns_complete_entries () {
local IFS=$'\n' local IFS=$'\n'
local items=($(compgen -f $prefix$cur)) local items=($(compgen -f $prefix$cur))
for item in ${items[@]}; do for item in "${items[@]}"; do
[[ $item =~ /\.[^/]*$ ]] && continue [[ $item =~ /\.[^/]*$ ]] && continue
# if there is a unique match, and it is a directory with one entry # if there is a unique match, and it is a directory with one entry
@@ -56,7 +56,7 @@ _sns_complete_folders () {
local IFS=$'\n' local IFS=$'\n'
local items=($(compgen -d $prefix$cur)) local items=($(compgen -d $prefix$cur))
for item in ${items[@]}; do for item in "${items[@]}"; do
[[ $item == $prefix.* ]] && continue [[ $item == $prefix.* ]] && continue
COMPREPLY+=("${item#$prefix}/") COMPREPLY+=("${item#$prefix}/")
done done
@@ -77,9 +77,10 @@ _sns()
if [[ $COMP_CWORD -gt 1 ]]; then if [[ $COMP_CWORD -gt 1 ]]; then
local lastarg="${COMP_WORDS[$COMP_CWORD-1]}" local lastarg="${COMP_WORDS[$COMP_CWORD-1]}"
case "${COMP_WORDS[1]}" in case "${COMP_WORDS[1]}" in
--list) --list|-l)
_sns_complete_folders _sns_complete_folders
--edit|--print) ;;
--edit|-e|--print|-p|--delete|-d)
_sns_complete_entries _sns_complete_entries
;; ;;
*) *)

View File

@@ -15,7 +15,7 @@ fi
if [ "$ENCRYPTION" == "TRUE" ]; then if [ "$ENCRYPTION" == "TRUE" ]; then
SESSION_ID="$RANDOM" #SESSION_ID later becomes the temporary filename SESSION_ID="$RANDOM" #SESSION_ID later becomes the temporary filename
readonly NOTE="$NOTE.$EXT.gpg" readonly NOTE="$NOTE.gpg.$EXT"
else else
readonly NOTE="$NOTE.$EXT" readonly NOTE="$NOTE.$EXT"
fi fi