fix tmuxp completion

- fix wrong exclusive options
This commit is contained in:
Shohei YOSHIDA 2026-03-08 21:40:00 +09:00
parent f103e01de0
commit 530a4f68ed
No known key found for this signature in database
GPG Key ID: C9A1BB11BB940CF2
1 changed files with 80 additions and 76 deletions

View File

@ -40,8 +40,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
_tmuxp() { _tmuxp() {
local curcontext="$curcontext" state line ret=1
local curcontext="$curcontext" state line
typeset -A opt_args typeset -A opt_args
_arguments -C \ _arguments -C \
@ -49,81 +48,87 @@ _tmuxp() {
"*::options:->options" \ "*::options:->options" \
"--log-level[log level(default info)]: :(debug info warning error critical)" \ "--log-level[log level(default info)]: :(debug info warning error critical)" \
'(- *)'{-h,--help}'[display usage information]' \ '(- *)'{-h,--help}'[display usage information]' \
'(- *)'{-V,--version}'[show version number and exit]' '(- *)'{-V,--version}'[show version number and exit]' \
&& ret=0
case $state in case $state in
(command) (command)
local -a subcommands local -a subcommands=(
subcommands=( 'load:Load tmuxp workspaces'
'load:Load tmuxp workspaces' 'shell:launch python shell for tmux server, session, window and pane'
'shell:launch python shell for tmux server, session, window and pane' 'import:Import a teamocil/tmuxinator config'
'import:Import a teamocil/tmuxinator config' 'convert:Convert a tmuxp config between JSON and YAML'
'convert:Convert a tmuxp config between JSON and YAML' 'debug-info:print out all diagnostic info'
'debug-info:print out all diagnostic info' 'ls:list sessions in config directory'
'ls:list sessions in config directory' 'edit: run $EDITOR on config'
'edit: run $EDITOR on config' 'freeze:Snapshot a session into a config'
'freeze:Snapshot a session into a config' )
) _describe -t commands 'commands' subcommands && ret=0
_describe -t commands 'commands' subcommands ;;
;; (options)
(options) case $line[1] in
case $line[1] in (load)
(load) __tmuxp_load && ret=0
__tmuxp_load ;;
;; (import)
(import) __tmuxp_import && ret=0
__tmuxp_import ;;
;; (freeze)
(freeze) local sessions="$(__tmux_sessions)"
local sessions="$(__tmux_sessions)" _arguments \
_arguments -C \ '(- *)'{-h,--help}'[show help message and exit]' \
'(- *)'{-h,--help}'[show help message and exit]' \ '-S[pass-through for tmux -S]: :_files' \
'-S[pass-through for tmux -S]: :_files' \ '-L[pass-through for tmux -L]: :' \
'-L[pass-through for tmux -L]: :' \ '(-f --config-format)'{-f,--config-format}'[format to save in]: :(yaml json)' \
'(-f --config-format)'{-f,--config-format}'[format to save in]: :(yaml json)' \ '(-o --save-to)'{-o,--save-to}'[file to save to]: :_files' \
'(-o --save-to)'{-o,--save-to}'[file to save to]: :_files' \ '(-y --yes)'{-y,--yes}'[always answer yes]' \
'(-y --yes)'{-y,--yes}'[always answer yes]' \ '(-q --quiet)'{-q,--quiet}"[don't prompt for confirmation]" \
'(-q --quiet)'{-q,--quiet}"[don't prompt for confirmation]" \ '--force[overwrite the config file]'\
'--force[overwrite the config file]'\ "1::session name:compadd $sessions" \
"1::session name:compadd $sessions" && ret=0
;; ;;
(convert) (convert)
_arguments -C \ _arguments \
'1:: :_files -g "*.(json|yaml|yml)"' '1:: :_files -g "*.(json|yaml|yml)"' \
;; && ret=0
(shell) ;;
local sessions="$(__tmux_sessions)" (shell)
local windows="$(__tmux_windows)" local sessions="$(__tmux_sessions)"
_arguments -C \ local windows="$(__tmux_windows)"
'(- *)'{-h,--help}'[show help message and exit]' \ _arguments \
'-S[pass-through for tmux -S]: :_files' \ '(- *)'{-h,--help}'[show help message and exit]' \
'-L[pass-through for tmux -L]: :' \ '-S[pass-through for tmux -S]: :_files' \
'--best[use best shell available in site packages]' \ '-L[pass-through for tmux -L]: :' \
'--pdb[use plain pdb]' \ '--best[use best shell available in site packages]' \
"--code[use stdlib's code.interact()]" \ '--pdb[use plain pdb]' \
'--ptipython[use ptpython + ipython]' \ "--code[use stdlib's code.interact()]" \
'--ptpython[use ptpython]' \ '--ptipython[use ptpython + ipython]' \
'--ipython[use ipython]' \ '--ptpython[use ptpython]' \
'--bpython[use bpython]' \ '--ipython[use ipython]' \
(--no-startup)'--use-pythonrc[load PYTHONSTARTUP env var and ~/.pythonrc.py script in --code]' \ '--bpython[use bpython]' \
(--use-pythonrc)'--no-startup[do not load PYTHONSTARTUP env var and ~/.pythonrc.py script in --code]' \ '(--no-startup --use-pythonrc)--use-pythonrc[load PYTHONSTARTUP env var and ~/.pythonrc.py script in --code]' \
(--no-vi-mode)'--use-vi-mode[use vi-mode in ptpython/ptipython]' \ '(--no-startup --use-pythonrc)--no-startup[do not load PYTHONSTARTUP env var and ~/.pythonrc.py script in --code]' \
(--vi-mode)'--no-vi-mode[do not use vi-mode in ptpython/ptipython]' \ '(--use-vi-mode --no-vi-mode)--use-vi-mode[use vi-mode in ptpython/ptipython]' \
"1::session name:compadd $sessions" \ '(--use-vi-mode --no-vi-mode)--no-vi-mode[do not use vi-mode in ptpython/ptipython]' \
"2::window name:compadd $windows" "1::session name:compadd $sessions" \
;; "2::window name:compadd $windows" \
(ls|debug-info) && ret=0
_arguments -C \ ;;
'(- *)'{-h,--help}'[show help message and exit]' (ls|debug-info)
;; _arguments \
(edit) '(- *)'{-h,--help}'[show help message and exit]' \
_arguments -C \ && ret=0
'(- *)'{-h,--help}'[show help message and exit]' \ ;;
'1:: :_files -g "*.(json|yaml|yml)"' (edit)
;; _arguments \
esac '(- *)'{-h,--help}'[show help message and exit]' \
esac '1:: :_files -g "*.(json|yaml|yml)"' \
&& ret=0
;;
esac
esac
return ret
} }
__tmuxp_load() { __tmuxp_load() {
@ -188,7 +193,6 @@ __tmux_windows () {
_tmuxp "$@" _tmuxp "$@"
# Local Variables: # Local Variables:
# mode: Shell-Script # mode: Shell-Script
# sh-indentation: 2 # sh-indentation: 2