Permalink
Browse files

let shells do the quoting in completions, like they should

Dug around in bash docs until I found out how to get it to quote
metachars in tab completions like zsh does by default, so that's
nice. I knew you you could do it, bash!
  • Loading branch information...
1 parent 66898d0 commit 175a6d97235b8f2383ea16d69ea86ada54159d2e @rupa committed Aug 10, 2012
Showing with 3 additions and 6 deletions.
  1. +3 −6 z.sh
View
9 z.sh
@@ -86,10 +86,7 @@ _z() {
} else {
for( i in fnd ) $1 !~ fnd[i] && $1 = ""
}
- if( $1 ) {
- gsub(/[\(\)\[\]\| ]/, "\\\\&", $1)
- print $1
- }
+ if( $1 ) print $1
}
' 2>/dev/null
@@ -187,7 +184,7 @@ alias ${_Z_CMD:-z}='_z 2>&1'
if complete &> /dev/null; then
# bash tab completion
- complete -C '_z --complete "$COMP_LINE"' ${_Z_CMD:-z}
+ complete -o filenames -C '_z --complete "$COMP_LINE"' ${_Z_CMD:-z}
[ "$_Z_NO_PROMPT_COMMAND" ] || {
# populate directory list. avoid clobbering other PROMPT_COMMANDs.
echo $PROMPT_COMMAND | grep -q "_z --add"
@@ -200,5 +197,5 @@ elif compctl &> /dev/null; then
read -l compl
reply=(${(f)"$(_z --complete "$compl")"})
}
- compctl -Q -U -K _z_zsh_tab_completion _z
+ compctl -U -K _z_zsh_tab_completion _z
fi

0 comments on commit 175a6d9

Please sign in to comment.