summaryrefslogtreecommitdiff
path: root/plugins/wd/_wd.sh
diff options
context:
space:
mode:
authorMarkus Færevaag <m@frv.ag>2017-11-01 22:03:34 +0900
committerRobby Russell <robby@planetargon.com>2017-11-01 06:03:34 -0700
commit2102d10896fe14e912ed6ed8075bb0ddd3a5bc6a (patch)
tree86a2ac77fd0c7095665a792207010cc4bbbf07d3 /plugins/wd/_wd.sh
parent2e4539b0d4613e8e5081c81b80959e506038d295 (diff)
downloadzsh-2102d10896fe14e912ed6ed8075bb0ddd3a5bc6a.tar.gz
zsh-2102d10896fe14e912ed6ed8075bb0ddd3a5bc6a.tar.bz2
zsh-2102d10896fe14e912ed6ed8075bb0ddd3a5bc6a.zip
[wd] Update wd plugin to latest version (#6371)
* [wd] Update wd plugin to v0.4.3 * [wd] Update wd plugin to v0.4.4
Diffstat (limited to 'plugins/wd/_wd.sh')
-rw-r--r--plugins/wd/_wd.sh21
1 files changed, 20 insertions, 1 deletions
diff --git a/plugins/wd/_wd.sh b/plugins/wd/_wd.sh
index b67f4a1e2..65fa1ddde 100644
--- a/plugins/wd/_wd.sh
+++ b/plugins/wd/_wd.sh
@@ -16,6 +16,19 @@ function _wd() {
warp_points=( "${(f)mapfile[$CONFIG]//$HOME/~}" )
+ typeset -A points
+ while read -r line
+ do
+ arr=(${(s,:,)line})
+ name=${arr[1]}
+ path=${arr[2]}
+
+ # replace ~ from path to fix completion (#17)
+ path=${path/#\~/$HOME}
+
+ points[$name]=$path
+ done < $CONFIG
+
commands=(
'add:Adds the current working directory to your warp points'
'add!:Overwrites existing warp point'
@@ -34,13 +47,15 @@ function _wd() {
'1: :->first_arg' \
'2: :->second_arg' && ret=0
+ local target=$words[2]
+
case $state in
first_arg)
_describe -t warp_points "Warp points" warp_points && ret=0
_describe -t commands "Commands" commands && ret=0
;;
second_arg)
- case $words[2] in
+ case $target in
add\!|rm)
_describe -t points "Warp points" warp_points && ret=0
;;
@@ -56,6 +71,10 @@ function _wd() {
path)
_describe -t points "Warp points" warp_points && ret=0
;;
+ *)
+ # complete sub directories from the warp point
+ _path_files -W "(${points[$target]})" -/ && ret=0
+ ;;
esac
;;
esac