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!
This commit is contained in:
rupa committed 2012-08-10 03:03:20 -04:00
1 parent 66898d08c8
commit 175a6d9723
1 file changed
+3 -6
+3 -6
View File
@@ -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