diff options
author | Robby Russell <robby@planetargon.com> | 2013-12-03 00:02:47 -0800 |
---|---|---|
committer | Robby Russell <robby@planetargon.com> | 2013-12-03 00:02:47 -0800 |
commit | b764fad27136a2ab3b7eaccc18ca16bbfe21ed68 (patch) | |
tree | 1b38205d6f522b20980e0d8bc86371a2007e9be8 /plugins/wd/_wd.sh | |
parent | cd219f70a418fb9a904d9e34daa389cb3c0e456f (diff) | |
parent | b4ffe5cf0a9e0a076fc1c52f6a46eefe05ad5627 (diff) | |
download | zsh-b764fad27136a2ab3b7eaccc18ca16bbfe21ed68.tar.gz zsh-b764fad27136a2ab3b7eaccc18ca16bbfe21ed68.tar.bz2 zsh-b764fad27136a2ab3b7eaccc18ca16bbfe21ed68.zip |
Merge pull request #2262 from mfaerevaag/master
Fixed and improved wd plugin
Diffstat (limited to 'plugins/wd/_wd.sh')
-rw-r--r-- | plugins/wd/_wd.sh | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/plugins/wd/_wd.sh b/plugins/wd/_wd.sh new file mode 100644 index 000000000..950564435 --- /dev/null +++ b/plugins/wd/_wd.sh @@ -0,0 +1,48 @@ +#compdef wd.sh + +zstyle ":completion:*:descriptions" format "%B%d%b" + +CONFIG=$HOME/.warprc + +local -a main_commands +main_commands=( + add:'Adds the current working directory to your warp points' + #add'\!':'Overwrites existing warp point' # TODO: Fix + rm:'Removes the given warp point' + ls:'Outputs all stored warp points' + show:'Outputs warp points to current directory' +) + +local -a points +while read line +do + points+=$(awk "{ gsub(/\/Users\/$USER|\/home\/$USER/,\"~\"); print }" <<< $line) +done < $CONFIG + +_wd() +{ + # init variables + local curcontext="$curcontext" state line + typeset -A opt_args + + # init state + _arguments \ + '1: :->command' \ + '2: :->argument' + + case $state in + command) + compadd "$@" add rm ls show + _describe -t warp-points 'Warp points:' points && ret=0 + ;; + argument) + case $words[2] in + rm|add!) + _describe -t warp-points 'warp points' points && ret=0 + ;; + *) + esac + esac +} + +_wd "$@" |