Skip to content

Commit

Permalink
let shells do the quoting in completions, like they should
Browse files Browse the repository at this point in the history
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
rupa committed Aug 10, 2012
1 parent 66898d0 commit 175a6d9
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions z.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand All @@ -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.