summaryrefslogtreecommitdiff
path: root/plugins/z
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/z')
-rw-r--r--plugins/z/z.sh25
1 files changed, 13 insertions, 12 deletions
diff --git a/plugins/z/z.sh b/plugins/z/z.sh
index 5fe6d5266..5c5771d62 100644
--- a/plugins/z/z.sh
+++ b/plugins/z/z.sh
@@ -89,7 +89,7 @@ _z() {
if [ $? -ne 0 -a -f "$datafile" ]; then
env rm -f "$tempfile"
else
- [ "$_Z_OWNER" ] && chown $_Z_OWNER:$(id -ng $_Z_OWNER) "$tempfile"
+ [ "$_Z_OWNER" ] && chown $_Z_OWNER:"$(id -ng $_Z_OWNER)" "$tempfile"
env mv -f "$tempfile" "$datafile" || env rm -f "$tempfile"
fi
@@ -110,20 +110,21 @@ _z() {
else
# list/go
+ local echo fnd last list opt typ
while [ "$1" ]; do case "$1" in
- --) while [ "$1" ]; do shift; local fnd="$fnd${fnd:+ }$1";done;;
- -*) local opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in
- c) local fnd="^$PWD $fnd";;
- e) local echo=1;;
+ --) while [ "$1" ]; do shift; fnd="$fnd${fnd:+ }$1";done;;
+ -*) opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in
+ c) fnd="^$PWD $fnd";;
+ e) echo=1;;
h) echo "${_Z_CMD:-z} [-cehlrtx] args" >&2; return;;
- l) local list=1;;
- r) local typ="rank";;
- t) local typ="recent";;
+ l) list=1;;
+ r) typ="rank";;
+ t) typ="recent";;
x) sed -i -e "\:^${PWD}|.*:d" "$datafile";;
esac; opt=${opt:1}; done;;
- *) local fnd="$fnd${fnd:+ }$1";;
- esac; local last=$1; [ "$#" -gt 0 ] && shift; done
- [ "$fnd" -a "$fnd" != "^$PWD " ] || local list=1
+ *) fnd="$fnd${fnd:+ }$1";;
+ esac; last=$1; [ "$#" -gt 0 ] && shift; done
+ [ "$fnd" -a "$fnd" != "^$PWD " ] || list=1
# if we hit enter on a completion just go there
case "$last" in
@@ -147,7 +148,7 @@ _z() {
function output(matches, best_match, common) {
# list or return the desired directory
if( list ) {
- cmd = "sort -n >&2"
+ cmd = "sort -g >&2"
for( x in matches ) {
if( matches[x] ) {
printf "%-10s %s\n", matches[x], x | cmd