Diff
1diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh
2index 3b9548168c13c0a4ef907052f9d66e1b1ce02586..cf54713bd83d3237101a5ec8575d488caf29fcb6 100755
3--- a/plugins/wd/wd.sh
4+++ b/plugins/wd/wd.sh
5@@ -8,7 +8,7 @@
6 # @github.com/mfaerevaag/wd
7
8 # version
9-readonly WD_VERSION=0.4
10+readonly WD_VERSION=0.4.2
11
12 # colors
13 readonly WD_BLUE="\033[96m"
14@@ -143,7 +143,7 @@ wd_warp()
15 fi
16 elif [[ ${points[$point]} != "" ]]
17 then
18- cd ${points[$point]}
19+ cd ${points[$point]/#\~/$HOME}
20 else
21 wd_exit_fail "Unknown warp point '${point}'"
22 fi
23@@ -169,7 +169,7 @@ wd_add()
24 elif [[ ${points[$2]} == "" ]] || $force
25 then
26 wd_remove $point > /dev/null
27- printf "%q:%s\n" "${point}" "${PWD}" >> $WD_CONFIG
28+ printf "%q:%s\n" "${point}" "${PWD/#$HOME/~}" >> $WD_CONFIG
29
30 wd_print_msg $WD_GREEN "Warp point added"
31
32@@ -203,6 +203,21 @@ wd_list_all()
33 {
34 wd_print_msg $WD_BLUE "All warp points:"
35
36+ entries=$(sed "s:${HOME}:~:g" $WD_CONFIG)
37+
38+ max_warp_point_length=0
39+ while IFS= read -r line
40+ do
41+ arr=(${(s,:,)line})
42+ key=${arr[1]}
43+
44+ length=${#key}
45+ if [[ length -gt max_warp_point_length ]]
46+ then
47+ max_warp_point_length=$length
48+ fi
49+ done <<< $entries
50+
51 while IFS= read -r line
52 do
53 if [[ $line != "" ]]
54@@ -213,16 +228,16 @@ wd_list_all()
55
56 if [[ -z $wd_quiet_mode ]]
57 then
58- printf "%20s -> %s\n" $key $val
59+ printf "%${max_warp_point_length}s -> %s\n" $key $val
60 fi
61 fi
62- done <<< $(sed "s:${HOME}:~:g" $WD_CONFIG)
63+ done <<< $entries
64 }
65
66 wd_ls()
67 {
68 wd_getdir $1
69- ls $dir
70+ ls ${dir/#\~/$HOME}
71 }
72
73 wd_path()
74@@ -248,6 +263,7 @@ wd_show()
75 local wd_matches
76 wd_matches=()
77 # do a reverse lookup to check whether PWD is in $points
78+ PWD="${PWD/$HOME/~}"
79 if [[ ${points[(r)$PWD]} == $PWD ]]
80 then
81 for name in ${(k)points}