metacharacters in directory names
* quote metachars in tab completions because bash doesn't, or at least, I can't figure out how to tell it to yet. * tell zsh NOT to quote metachars in tab completions because it does, by default. this is irritating, as i'm sure it's better than me at it. * do the irritating metachar quoting that's been a PITA on a copy of the variable, so we can return the original, because gsub modifies in place. TODO: if we're going to be taking over metacharacter quoting, we ought to do it less halfhazardly
This commit is contained in:
1 parent
ae7f1d1660
commit
66898d08c8
1 file changed
+10
-8
@@ -86,7 +86,10 @@ _z() {
|
|||||||
} else {
|
} else {
|
||||||
for( i in fnd ) $1 !~ fnd[i] && $1 = ""
|
for( i in fnd ) $1 !~ fnd[i] && $1 = ""
|
||||||
}
|
}
|
||||||
if( $1 ) print $1
|
if( $1 ) {
|
||||||
|
gsub(/[\(\)\[\]\| ]/, "\\\\&", $1)
|
||||||
|
print $1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
' 2>/dev/null
|
' 2>/dev/null
|
||||||
|
|
||||||
@@ -140,12 +143,11 @@ _z() {
|
|||||||
if( matches[i] && (!short || length(i) < length(short)) ) short = i
|
if( matches[i] && (!short || length(i) < length(short)) ) short = i
|
||||||
}
|
}
|
||||||
if( short == "/" ) return
|
if( short == "/" ) return
|
||||||
|
# shortest match must be common to each match. escape special characters in
|
||||||
# escape regex chars in right hand side
|
# a copy when testing, so we can return the original.
|
||||||
gsub(/[\(\)\[\]\|]/, "\\\\&", short)
|
clean_short = short
|
||||||
|
gsub(/[\(\)\[\]\|]/, "\\\\&", clean_short)
|
||||||
# shortest match must be common to each match
|
for( i in matches ) if( matches[i] && i !~ clean_short ) return
|
||||||
for( i in matches ) if( matches[i] && i !~ short ) return
|
|
||||||
return short
|
return short
|
||||||
}
|
}
|
||||||
BEGIN { split(q, a, " ") }
|
BEGIN { split(q, a, " ") }
|
||||||
@@ -198,5 +200,5 @@ elif compctl &> /dev/null; then
|
|||||||
read -l compl
|
read -l compl
|
||||||
reply=(${(f)"$(_z --complete "$compl")"})
|
reply=(${(f)"$(_z --complete "$compl")"})
|
||||||
}
|
}
|
||||||
compctl -U -K _z_zsh_tab_completion _z
|
compctl -Q -U -K _z_zsh_tab_completion _z
|
||||||
fi
|
fi
|
||||||
Reference in new issue
Block a user