Skip to content
Open
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
4 changes: 3 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ NAME
z - jump around

SYNOPSIS
z [-chlrtx] [regex1 regex2 ... regexn]
z [-chlrtxv] [regex1 regex2 ... regexn]

AVAILABILITY
bash, zsh
Expand All @@ -25,6 +25,8 @@ OPTIONS

-e echo the best match, don't cd

-v cd and echo the new directory

-h show a brief help message

-l list only
Expand Down
7 changes: 6 additions & 1 deletion z.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# * 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 -v foo # cd to most frecent dir matching foo and echo $PWD
# * z -l foo # list matches instead of cd
# * z -e foo # echo the best match, don't cd
# * z -c foo # restrict matches to subdirs of $PWD
Expand Down Expand Up @@ -125,6 +126,7 @@ _z() {
c) fnd="^$PWD $fnd";;
e) echo=1;;
h) echo "${_Z_CMD:-z} [-cehlrtx] args" >&2; return;;
v) verbose=1;;
l) list=1;;
r) typ="rank";;
t) typ="recent";;
Expand Down Expand Up @@ -216,7 +218,10 @@ _z() {

if [ "$?" -eq 0 ]; then
if [ "$cd" ]; then
if [ "$echo" ]; then echo "$cd"; else builtin cd "$cd"; fi
if [ "$echo" ]; then echo "$cd"
else builtin cd "$cd"
if [ "$verbose" ]; then echo $PWD; fi
fi
fi
else
return $?
Expand Down