Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add commandline option for case insensitive matching #219

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions z.1
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ match by recent access only
.TP
\fB\-x\fR
remove the current directory from the datafile
.TP
\fB\-i\fR
perform case insensitive matching
.SH EXAMPLES
.TP 14
\fBz foo\fR
Expand Down
5 changes: 3 additions & 2 deletions z.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ _z() {
r) local typ="rank";;
t) local typ="recent";;
x) sed -i -e "\:^${PWD}|.*:d" "$datafile";;
i) local icase=1;;
esac; opt=${opt:1}; done;;
*) local fnd="$fnd${fnd:+ }$1";;
esac; local last=$1; [ "$#" -gt 0 ] && shift; done
Expand All @@ -135,7 +136,7 @@ _z() {
[ -f "$datafile" ] || return

local cd
cd="$( < <( _z_dirs ) awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" '
cd="$( < <( _z_dirs ) awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v icase="$icase" -v q="$fnd" -F"|" '
function frecent(rank, time) {
# relate frequency and time
dx = t - time
Expand Down Expand Up @@ -184,7 +185,7 @@ _z() {
} else if( typ == "recent" ) {
rank = $3 - t
} else rank = frecent($2, $3)
if( $1 ~ q ) {
if( $1 ~ q && !icase ) {
matches[$1] = rank
} else if( tolower($1) ~ tolower(q) ) imatches[$1] = rank
if( matches[$1] && matches[$1] > hi_rank ) {
Expand Down