Skip to content

Commit

Permalink
Rewrite the zsh completion script
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertAudi committed Jun 2, 2019
1 parent 7fa2172 commit ec5da36
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions share/zsh/_tsm
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#compdef tsm
#autoload

_tsm_commands=(
local context state line curcontext="$curcontext" ret=1
local -a cmds
cmds=(
'list:List saved sessions'
'show:Show details about a session'
'save:Save the current session'
Expand All @@ -16,9 +18,30 @@ _tsm_commands=(
'help:Show usage information'
)

_arguments '*:: :->command'
_arguments -C \
'1:tsm command:->subcommand' \
'*:: :->args' \
&& ret=0

if (( CURRENT == 1 )); then
_describe -t commands "tsm commands" _tsm_commands
return
fi
case $state in
subcommand)
_describe -t commands 'tsm commands' cmds && ret=0
;;
esac

case "$line[1]" in
show|remove|rename|copy|duplicate|restore|resume)
local -a session_files
session_files=("${TSM_SESSIONS_DIR}"/*.txt(.NOmf:gu+r::t:r))

_values 'Sessions' $session_files && ret=0
;;
help)
_describe -t commands 'tsm commands' cmds && ret=0
;;
list|quit|version)
_message -e 'no more arguments' && ret=1
;;
esac

return ret

0 comments on commit ec5da36

Please sign in to comment.