summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Cornellà <marc.cornella@live.com>2015-11-27 16:51:05 +0100
committerMarc Cornellà <marc.cornella@live.com>2015-11-27 16:51:05 +0100
commitbefb5b66c5d5b5af294dc18ea0d122754a42de89 (patch)
tree5c2d984e7c56a01ee2b0b0dd317debfb6f2e94e7
parent424800e881ba8140e7c6472687314c51f14b1605 (diff)
parent7d9648e6314d184800cc4549db2fd7b7d13bdec7 (diff)
downloadzsh-befb5b66c5d5b5af294dc18ea0d122754a42de89.tar.gz
zsh-befb5b66c5d5b5af294dc18ea0d122754a42de89.tar.bz2
zsh-befb5b66c5d5b5af294dc18ea0d122754a42de89.zip
Merge pull request #4634 from mfaerevaag/master
[wd] update minor version (v0.4.2)
-rwxr-xr-xplugins/wd/wd.sh28
1 files changed, 22 insertions, 6 deletions
diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh
index 3b9548168..cf54713bd 100755
--- a/plugins/wd/wd.sh
+++ b/plugins/wd/wd.sh
@@ -8,7 +8,7 @@
# @github.com/mfaerevaag/wd
# version
-readonly WD_VERSION=0.4
+readonly WD_VERSION=0.4.2
# colors
readonly WD_BLUE="\033[96m"
@@ -143,7 +143,7 @@ wd_warp()
fi
elif [[ ${points[$point]} != "" ]]
then
- cd ${points[$point]}
+ cd ${points[$point]/#\~/$HOME}
else
wd_exit_fail "Unknown warp point '${point}'"
fi
@@ -169,7 +169,7 @@ wd_add()
elif [[ ${points[$2]} == "" ]] || $force
then
wd_remove $point > /dev/null
- printf "%q:%s\n" "${point}" "${PWD}" >> $WD_CONFIG
+ printf "%q:%s\n" "${point}" "${PWD/#$HOME/~}" >> $WD_CONFIG
wd_print_msg $WD_GREEN "Warp point added"
@@ -203,6 +203,21 @@ wd_list_all()
{
wd_print_msg $WD_BLUE "All warp points:"
+ entries=$(sed "s:${HOME}:~:g" $WD_CONFIG)
+
+ max_warp_point_length=0
+ while IFS= read -r line
+ do
+ arr=(${(s,:,)line})
+ key=${arr[1]}
+
+ length=${#key}
+ if [[ length -gt max_warp_point_length ]]
+ then
+ max_warp_point_length=$length
+ fi
+ done <<< $entries
+
while IFS= read -r line
do
if [[ $line != "" ]]
@@ -213,16 +228,16 @@ wd_list_all()
if [[ -z $wd_quiet_mode ]]
then
- printf "%20s -> %s\n" $key $val
+ printf "%${max_warp_point_length}s -> %s\n" $key $val
fi
fi
- done <<< $(sed "s:${HOME}:~:g" $WD_CONFIG)
+ done <<< $entries
}
wd_ls()
{
wd_getdir $1
- ls $dir
+ ls ${dir/#\~/$HOME}
}
wd_path()
@@ -248,6 +263,7 @@ wd_show()
local wd_matches
wd_matches=()
# do a reverse lookup to check whether PWD is in $points
+ PWD="${PWD/$HOME/~}"
if [[ ${points[(r)$PWD]} == $PWD ]]
then
for name in ${(k)points}