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.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
;;