From b26ab85c7818b9fcd72f58efbc833f8687cefed9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20B=C3=B8cker-Larsen?= Date: Wed, 4 Nov 2015 00:08:07 +0545 Subject: [PATCH] Added No desk activated. plugin --- plugins/desk/desk.plugin.zsh | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 plugins/desk/desk.plugin.zsh diff --git a/plugins/desk/desk.plugin.zsh b/plugins/desk/desk.plugin.zsh new file mode 100644 index 00000000..b52a6242 --- /dev/null +++ b/plugins/desk/desk.plugin.zsh @@ -0,0 +1,50 @@ +#compdef desk + +# +# Completes available desks for `desk` +# +# Requires: desk https://github.com/jamesob/desk +# Author: Michael Bøcker-Larsen (@mblarsen) +# + +_desk() { + local state ret=1 + local desk_files_location desk_files + local -a desks + + # In case non-standard location is used + desk_files_location=${DESK_DESKS_DIR:-~/.desk/desks} + desk_files=("$desk_files_location"/*.sh) + + # Build list of files without extension + for file in $desk_files; do + filename="${file##*/}" + desks+=${filename%.*} + done + + _arguments \ + '1:command:->cmds' \ + '2:desk:->desk' + + case $state in + (cmds) + _values "desk commands" \ + 'go[Activate a desk]' \ + 'init[Initialize desk configuration]' \ + 'list[List all desks along with description]' + ret=0 + ;; + (desk) + case $words[2] in + (go) + _values "available desks" ${desks[@]} + ret=0 + ;; + esac + ret=0 + ;; + esac + return ret +} + +compdef _desk desk \ No newline at end of file