summaryrefslogtreecommitdiff
path: root/plugins/wd/_wd.sh
diff options
context:
space:
mode:
authorMarc Cornellà <marc.cornella@live.com>2020-06-03 18:35:51 +0200
committerMarc Cornellà <marc.cornella@live.com>2020-06-03 18:36:17 +0200
commit82f02e80a669d099d79a531cf8fb6a0e34d4478c (patch)
tree266ac5739d40ea1d9983d0406fcf7cd8dfa26815 /plugins/wd/_wd.sh
parent0fd11130a3541e33aded41ff64bec47c6ceefa39 (diff)
downloadzsh-82f02e80a669d099d79a531cf8fb6a0e34d4478c.tar.gz
zsh-82f02e80a669d099d79a531cf8fb6a0e34d4478c.tar.bz2
zsh-82f02e80a669d099d79a531cf8fb6a0e34d4478c.zip
wd: update to latest version (#8530)
Diffstat (limited to 'plugins/wd/_wd.sh')
-rw-r--r--plugins/wd/_wd.sh17
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
;;