summaryrefslogtreecommitdiff
path: root/plugins/wd/_wd.sh
diff options
context:
space:
mode:
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..4354a71f4 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]}
+ target_path=${arr[2]}
+
+ # replace ~ from path to fix completion (#17)
+ target_path=${target_path/#\~/$HOME}
+
+ points[$name]=$target_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