summaryrefslogtreecommitdiff
path: root/plugins/wd/_wd.sh
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2017-11-12 19:36:24 -0700
committerTuowen Zhao <ztuowen@gmail.com>2017-11-12 19:36:24 -0700
commit5e1ad5efbf59a40ef6dc6d404c6f403dff8ed436 (patch)
tree2c9ab05f372ad5da84662e18a4d7e258b75d3b17 /plugins/wd/_wd.sh
parent6bcf7764f8d8094695c7c04bb9532a0ede40ab37 (diff)
parent41eedd37005f6b3668fcebe2a5f5a26324753519 (diff)
downloadzsh-5e1ad5efbf59a40ef6dc6d404c6f403dff8ed436.tar.gz
zsh-5e1ad5efbf59a40ef6dc6d404c6f403dff8ed436.tar.bz2
zsh-5e1ad5efbf59a40ef6dc6d404c6f403dff8ed436.zip
Merge branch 'master' of https://github.com/robbyrussell/oh-my-zsh
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