Permalink
Browse files

smartcase in completions - ie only case sensitive if there is an uppe…

…rcase letter in search
  • Loading branch information...
1 parent 10e2de9 commit 0f7f16b22900252ba88fbdeb97bc449bd006f8c6 @rupa committed Feb 15, 2010
Showing with 11 additions and 2 deletions.
  1. +11 −2 z.sh
View
13 z.sh
@@ -44,10 +44,19 @@ z() {
elif [ "$1" = "--complete" ]; then
# tab completion
awk -v q="$2" -F"|" '
- BEGIN { split(substr(q,3),fnd," ") }
+ BEGIN {
+ if( q == tolower(q) ) nocase = 1
+ split(substr(q,3),fnd," ")
+ }
{
if( system("test -d \"" $1 "\"") ) next
- for( i in fnd ) tolower($1) !~ tolower(fnd[i]) && $1 = ""; if( $1 ) print $1
+ if( nocase ) {
+ for( i in fnd ) tolower($1) !~ tolower(fnd[i]) && $1 = ""
+ if( $1 ) print $1
+ } else {
+ for( i in fnd ) $1 !~ fnd[i] && $1 = ""
+ if( $1 ) print $1
+ }
}
' $datafile 2>/dev/null
else

0 comments on commit 0f7f16b

Please sign in to comment.