Skip to content

Commit

Permalink
smartcase in completions - ie only case sensitive if there is an uppe…
Browse files Browse the repository at this point in the history
…rcase letter in search
  • Loading branch information
rupa committed Feb 15, 2010
1 parent 10e2de9 commit 0f7f16b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions z.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0f7f16b

Please sign in to comment.