From 79dc3f340fbc6896d58b5149e756cdb5f7b3c84c Mon Sep 17 00:00:00 2001 From: rupa Date: Mon, 25 Jul 2011 16:46:10 -0400 Subject: [PATCH] only cd to completions if we've actually tab completed them We decide you've tab completed if the last argument begins with /, and is an existing directory. This may still cause unexpected behavior if you do that without tab completing. --- z.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/z.sh b/z.sh index 1be055c..7938b5d 100755 --- a/z.sh +++ b/z.sh @@ -98,7 +98,8 @@ _z() { [ "$fnd" ] || local list=1 # if we hit enter on a completion just go there - [ -d "$last" ] && cd "$last" && return + # completions will always start with / + [ -z "$list" -a -d "$last" -a "${last:0:1}" = "/" ] && cd "$last" && return # no file yet [ -f "$datafile" ] || return