From 7b03d4264e241f8a2aba9e54908e17c9adb21c3c Mon Sep 17 00:00:00 2001 From: Aaron Hamid Date: Mon, 24 Jul 2017 13:24:33 -0400 Subject: [PATCH] add support for argument to x, to enable removing (not-current) directory --- z.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/z.sh b/z.sh index fbc2f04..19718e3 100644 --- a/z.sh +++ b/z.sh @@ -22,6 +22,7 @@ # * z -t foo # cd to most recently accessed dir matching foo # * z -l foo # list matches instead of cd # * z -c foo # restrict matches to subdirs of $PWD +# * z -x foo # removes dir `foo` from z database [ -d "${_Z_DATA:-$HOME/.z}" ] && { echo "ERROR: z.sh's datafile (${_Z_DATA:-$HOME/.z}) is a directory." @@ -116,7 +117,9 @@ _z() { l) local list=1;; r) local typ="rank";; t) local typ="recent";; - x) sed -i -e "\:^${PWD}|.*:d" "$datafile";; + x) local xdir="${PWD}" + if [ $# -gt 1 ]; then xdir="$2"; shift; fi + sed -i -e "\:^${xdir}|.*:d" "$datafile";; esac; opt=${opt:1}; done;; *) local fnd="$fnd${fnd:+ }$1";; esac; local last=$1; [ "$#" -gt 0 ] && shift; done