1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-14 01:40:09 +00:00
ohmyzsh/plugins/wd/_wd.sh

66 lines
1.7 KiB
Bash
Raw Normal View History

2014-03-04 19:25:54 +00:00
#compdef wd
zstyle ':completion:*: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
zmodload zsh/mapfile
2014-03-04 19:25:54 +00:00
function _wd() {
local CONFIG=$HOME/.warprc
local ret=1
2014-03-04 19:25:54 +00:00
local -a commands
local -a warp_points
warp_points=( "${(f)mapfile[$CONFIG]//$HOME/~}" )
2014-03-04 19:25:54 +00:00
commands=(
'add:Adds the current working directory to your warp points'
'add!:Overwrites existing warp point'
'rm:Removes the given warp point'
'ls:Outputs all stored warp points'
2014-09-07 19:56:34 +00:00
'show:Outputs all warp points that point to the current directory or shows a specific target directory for a point'
'show:Outputs all warp points that point to the current directory or shows a specific target directory for a point'
2014-03-04 19:25:54 +00:00
'help:Show this extremely helpful text'
'..:Go back to last directory'
)
_arguments -C \
'1: :->first_arg' \
'2: :->second_arg' && ret=0
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
add\!|rm)
_describe -t points "Warp points" warp_points && ret=0
;;
add)
_message 'Write the name of your warp point' && ret=0
;;
2014-09-07 19:56:34 +00:00
show)
_describe -t points "Warp points" warp_points && ret=0
;;
2014-03-04 19:25:54 +00:00
esac
;;
esac
return $ret
}
_wd "$@"
2014-03-04 19:25:54 +00:00
# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et