From 0f3f7a437f8d79c2c822f3d24377449bded127c7 Mon Sep 17 00:00:00 2001 From: rupa Date: Sun, 3 Mar 2013 00:54:40 -0500 Subject: [PATCH] -c option restricts matches to subdirs of cwd. Closes #83 --- README | 4 +++- z.1 | 5 ++++- z.sh | 6 ++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README b/README index 77c0d40..40e7af4 100644 --- a/README +++ b/README @@ -6,7 +6,7 @@ NAME z - jump around SYNOPSIS - z [-h] [-l] [-r] [-t] [regex1 regex2 ... regexn] + z [-c] [-h] [-l] [-r] [-t] [regex1 regex2 ... regexn] AVAILABILITY bash, zsh @@ -18,6 +18,8 @@ DESCRIPTION directory that matches ALL of the regexes given on the command line. OPTIONS + -c restrict matches to subdirectories of the current directory. + -h show a brief help message -l list only diff --git a/z.1 b/z.1 index 9752ab1..bed5d3b 100644 --- a/z.1 +++ b/z.1 @@ -4,7 +4,7 @@ NAME z \- jump around .SH SYNOPSIS -z [\-h] [\-l] [\-r] [\-t] [regex1 regex2 ... regexn] +z [\-c] [\-h] [\-l] [\-r] [\-t] [regex1 regex2 ... regexn] .SH AVAILABILITY bash, zsh @@ -17,6 +17,9 @@ directory that matches ALL of the regexes given on the command line. .SH OPTIONS .TP +\fB\-c\fR +restrict matches to subdirectories of the current directory. +.TP \fB\-h\fR show a brief help message .TP diff --git a/z.sh b/z.sh index b441a5a..aec8967 100755 --- a/z.sh +++ b/z.sh @@ -19,7 +19,8 @@ # * z foo bar # cd to most frecent dir matching foo and bar # * z -r foo # cd to highest ranked dir matching foo # * z -t foo # cd to most recently accessed dir matching foo -# * z -l foo # list all dirs matching foo (by frecency) +# * z -l foo # list matches instead of cd +# * z -c foo # restrict matches to subdirs of $PWD case $- in *i*) ;; @@ -100,7 +101,8 @@ _z() { else # list/go while [ "$1" ]; do case "$1" in - -h) echo "${_Z_CMD:-z} [-h][-l][-r][-t] args" >&2; return;; + -c) local fnd="$PWD $fnd";; + -h) echo "${_Z_CMD:-z} [-c][-h][-l][-r][-t] args" >&2; return;; -l) local list=1;; -r) local typ="rank";; -t) local typ="recent";;