diff options
author | Tuowen Zhao <ztuowen@gmail.com> | 2020-07-04 11:54:44 -0600 |
---|---|---|
committer | Tuowen Zhao <ztuowen@gmail.com> | 2020-07-04 11:54:44 -0600 |
commit | 59344b5c59b7190ad3b14a2e8e02db8b5559141b (patch) | |
tree | a8e7ede89d3b896967d7d18d071107bd06c77897 /plugins/wd/_wd.sh | |
parent | a3be2e4084285d7625e63bfe4b951c58143e3c9c (diff) | |
parent | a15f0f0e9ff17c1ca5c6d694d732e72c7c03a62b (diff) | |
download | zsh-59344b5c59b7190ad3b14a2e8e02db8b5559141b.tar.gz zsh-59344b5c59b7190ad3b14a2e8e02db8b5559141b.tar.bz2 zsh-59344b5c59b7190ad3b14a2e8e02db8b5559141b.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'plugins/wd/_wd.sh')
-rw-r--r-- | plugins/wd/_wd.sh | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/plugins/wd/_wd.sh b/plugins/wd/_wd.sh index 4354a71f4..8d5cf15a2 100644 --- a/plugins/wd/_wd.sh +++ b/plugins/wd/_wd.sh @@ -1,6 +1,6 @@ #compdef wd -zstyle ':completion:*:descriptions' format '%B%d%b' +zstyle ':completion::complete:wd:*:descriptions' format '%B%d%b' zstyle ':completion::complete:wd:*:commands' group-name commands zstyle ':completion::complete:wd:*:warp_points' group-name warp_points zstyle ':completion::complete:wd::' list-grouped @@ -8,13 +8,13 @@ zstyle ':completion::complete:wd::' list-grouped zmodload zsh/mapfile function _wd() { - local CONFIG=$HOME/.warprc + local WD_CONFIG=${WD_CONFIG:-$HOME/.warprc} local ret=1 local -a commands local -a warp_points - warp_points=( "${(f)mapfile[$CONFIG]//$HOME/~}" ) + warp_points=( "${(f)mapfile[$WD_CONFIG]//$HOME/~}" ) typeset -A points while read -r line @@ -27,11 +27,12 @@ function _wd() { target_path=${target_path/#\~/$HOME} points[$name]=$target_path - done < $CONFIG + done < $WD_CONFIG commands=( 'add:Adds the current working directory to your warp points' 'add!:Overwrites existing warp point' + 'export:Export warp points as static named directories' 'rm:Removes the given warp point' 'list:Outputs all stored warp points' 'ls:Show files from given warp point' @@ -72,8 +73,12 @@ function _wd() { _describe -t points "Warp points" warp_points && ret=0 ;; *) - # complete sub directories from the warp point - _path_files -W "(${points[$target]})" -/ && ret=0 + if [[ -v points[$target] ]]; then + # complete sub directories from the warp point + _path_files -W "(${points[$target]})" -/ && ret=0 + fi + + # don't complete anything if warp point is not valid ;; esac ;; |