1
0
mirror of https://github.com/robbyrussell/oh-my-zsh.git synced 2025-12-06 07:20:40 +01:00

wd: update to latest version (#8530)

This commit is contained in:
Marc Cornellà
2020-06-03 18:35:51 +02:00
parent 0fd11130a3
commit 82f02e80a6
4 changed files with 209 additions and 97 deletions

View File

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