From 76852ebb49c5505117ef86fdda11b2d5fa69fcd1 Mon Sep 17 00:00:00 2001 From: rupa Date: Sun, 3 Mar 2013 02:49:11 -0500 Subject: [PATCH 1/4] Allow options to be combined e.g -clt --- z.1 | 2 +- z.sh | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/z.1 b/z.1 index bed5d3b..e94d81b 100644 --- a/z.1 +++ b/z.1 @@ -4,7 +4,7 @@ NAME z \- jump around .SH SYNOPSIS -z [\-c] [\-h] [\-l] [\-r] [\-t] [regex1 regex2 ... regexn] +z [\-chlrt] [regex1 regex2 ... regexn] .SH AVAILABILITY bash, zsh diff --git a/z.sh b/z.sh index 7b0f02e..c54872e 100755 --- a/z.sh +++ b/z.sh @@ -101,12 +101,14 @@ _z() { else # list/go while [ "$1" ]; do case "$1" in - -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";; --) while [ "$1" ]; do shift; local fnd="$fnd $1";done;; + -*) local opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in + c) local fnd="$PWD $fnd";; + h) echo "${_Z_CMD:-z} [-chlrt] args" >&2; return;; + l) local list=1;; + r) local typ="rank";; + t) local typ="recent";; + esac; opt=${opt:1}; done;; *) local fnd="$fnd $1";; esac; local last=$1; shift; done [ "$fnd" -a "$fnd" != "$PWD " ] || local list=1 From 2c2ebc2b28786daf834d4f24e6b90284ad3c1e42 Mon Sep 17 00:00:00 2001 From: rupa Date: Sun, 3 Mar 2013 02:51:50 -0500 Subject: [PATCH 2/4] update README to match man page --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 40e7af4..7169b0a 100644 --- a/README +++ b/README @@ -6,7 +6,7 @@ NAME z - jump around SYNOPSIS - z [-c] [-h] [-l] [-r] [-t] [regex1 regex2 ... regexn] + z [-chlrt] [regex1 regex2 ... regexn] AVAILABILITY bash, zsh From 2ce7fca7aff6a790ad407d4494fe2d8fb0acaf28 Mon Sep 17 00:00:00 2001 From: rupa Date: Sun, 3 Mar 2013 02:54:55 -0500 Subject: [PATCH 3/4] Remove extra . from man page. --- README | 2 +- z.1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README b/README index 7169b0a..6225b2d 100644 --- a/README +++ b/README @@ -105,7 +105,7 @@ ENVIRONMENT The environment variable $_Z_NO_RESOLVE_SYMLINKS can be set to prevent resolving of symlinks. If it is not set, symbolic links will be - resolved when added to the datafile.. + resolved when added to the datafile. In bash, z prepends a command to the PROMPT_COMMAND environment vari- able to maintain its database. In zsh, z appends a function _z_precmd diff --git a/z.1 b/z.1 index e94d81b..2ba6de7 100644 --- a/z.1 +++ b/z.1 @@ -129,7 +129,7 @@ location. If it is not defined, the location defaults to \fB$HOME/.z\fR. .P The environment variable \fB$_Z_NO_RESOLVE_SYMLINKS\fR can be set to prevent resolving of symlinks. If it is not set, symbolic links will be resolved when -added to the datafile.. +added to the datafile. .P In bash, \fBz\fR prepends a command to the \fBPROMPT_COMMAND\fR environment variable to maintain its database. In zsh, \fBz\fR appends a function From b82dadc1a80f4b8abe8d56d0f88615efb23b69d6 Mon Sep 17 00:00:00 2001 From: rupa Date: Sun, 3 Mar 2013 09:47:02 -0500 Subject: [PATCH 4/4] Be explicit that -c matches should start with cwd, not just contain it. --- z.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/z.sh b/z.sh index c54872e..705e428 100755 --- a/z.sh +++ b/z.sh @@ -103,7 +103,7 @@ _z() { while [ "$1" ]; do case "$1" in --) while [ "$1" ]; do shift; local fnd="$fnd $1";done;; -*) local opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in - c) local fnd="$PWD $fnd";; + c) local fnd="^$PWD $fnd";; h) echo "${_Z_CMD:-z} [-chlrt] args" >&2; return;; l) local list=1;; r) local typ="rank";; @@ -111,7 +111,7 @@ _z() { esac; opt=${opt:1}; done;; *) local fnd="$fnd $1";; esac; local last=$1; shift; done - [ "$fnd" -a "$fnd" != "$PWD " ] || local list=1 + [ "$fnd" -a "$fnd" != "^$PWD " ] || local list=1 # if we hit enter on a completion just go there case "$last" in