From e1c0022255508dcb1ec3dd6dd25e1288d927d384 Mon Sep 17 00:00:00 2001 From: Jeffrey Ratcliffe Date: Sat, 22 Sep 2012 09:57:08 +0200 Subject: bash completion - Fix UTF8, escape spaces, inverted commas, brackets, and ampersands, and clean up --- contrib/pass.bash-completion | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'contrib') diff --git a/contrib/pass.bash-completion b/contrib/pass.bash-completion index 36c0cf2..71bb12a 100644 --- a/contrib/pass.bash-completion +++ b/contrib/pass.bash-completion @@ -10,7 +10,6 @@ _pass_complete_entries () { autoexpand=${1:-0} local IFS=$'\n' - local i=0 for item in $(compgen -f $prefix$cur); do if [[ $item == $prefix.* ]]; then continue @@ -30,28 +29,28 @@ _pass_complete_entries () { fi done item="${item%$suffix}" - COMPREPLY[$i]=$(printf "%q" "${item#$prefix}" ) - (( i++ )) + item="${item// /\ }" + item="${item//'/\'}" + item="${item//\(/\(}" + item="${item//)/\)}" + item="${item//&/\&}" + COMPREPLY+=("${item#$prefix}") done } _pass() { - local cur prev opts base - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" - - commands="init ls show insert generate edit rm git help --help version --version" + local cur="${COMP_WORDS[COMP_CWORD]}" + local commands="init ls show insert generate edit rm git help --help version --version" if [[ $COMP_CWORD -gt 1 ]]; then case "${COMP_WORDS[1]}" in init) COMPREPLY+=($(compgen -W "-e --reencrypt" -- ${cur})) - keys=$(gpg --list-keys |grep uid |sed 's/.*<\(.*\)>/\1/') + local keys=$(gpg --list-keys |grep uid |sed 's/.*<\(.*\)>/\1/') COMPREPLY+=($(compgen -W "${keys}" -- ${cur})) ;; - ls|list) + ls|list|edit) _pass_complete_entries ;; show|-*) @@ -66,9 +65,6 @@ _pass() COMPREPLY+=($(compgen -W "-n --no-symbols -c --clip -f --force" -- ${cur})) _pass_complete_entries ;; - edit) - _pass_complete_entries - ;; rm|remove|delete) COMPREPLY+=($(compgen -W "-r --recursive -f --force" -- ${cur})) _pass_complete_entries -- cgit v1.2.3