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() {
local curcontext="$curcontext" state line
local curcontext="$curcontext" state line ret=1
typeset -A opt_args
_arguments -C \
@ -49,12 +48,12 @@ _tmuxp() {
"*::options:->options" \
"--log-level[log level(default info)]: :(debug info warning error critical)" \
'(- *)'{-h,--help}'[display usage information]' \
'(- *)'{-V,--version}'[show version number and exit]'
'(- *)'{-V,--version}'[show version number and exit]' \
&& ret=0
case $state in
(command)
local -a subcommands
subcommands=(
local -a subcommands=(
'load:Load tmuxp workspaces'
'shell:launch python shell for tmux server, session, window and pane'
'import:Import a teamocil/tmuxinator config'
@ -64,19 +63,19 @@ _tmuxp() {
'edit: run $EDITOR on config'
'freeze:Snapshot a session into a config'
)
_describe -t commands 'commands' subcommands
_describe -t commands 'commands' subcommands && ret=0
;;
(options)
case $line[1] in
(load)
__tmuxp_load
__tmuxp_load && ret=0
;;
(import)
__tmuxp_import
__tmuxp_import && ret=0
;;
(freeze)
local sessions="$(__tmux_sessions)"
_arguments -C \
_arguments \
'(- *)'{-h,--help}'[show help message and exit]' \
'-S[pass-through for tmux -S]: :_files' \
'-L[pass-through for tmux -L]: :' \
@ -85,16 +84,18 @@ _tmuxp() {
'(-y --yes)'{-y,--yes}'[always answer yes]' \
'(-q --quiet)'{-q,--quiet}"[don't prompt for confirmation]" \
'--force[overwrite the config file]'\
"1::session name:compadd $sessions"
"1::session name:compadd $sessions" \
&& ret=0
;;
(convert)
_arguments -C \
'1:: :_files -g "*.(json|yaml|yml)"'
_arguments \
'1:: :_files -g "*.(json|yaml|yml)"' \
&& ret=0
;;
(shell)
local sessions="$(__tmux_sessions)"
local windows="$(__tmux_windows)"
_arguments -C \
_arguments \
'(- *)'{-h,--help}'[show help message and exit]' \
'-S[pass-through for tmux -S]: :_files' \
'-L[pass-through for tmux -L]: :' \
@ -105,25 +106,29 @@ _tmuxp() {
'--ptpython[use ptpython]' \
'--ipython[use ipython]' \
'--bpython[use bpython]' \
(--no-startup)'--use-pythonrc[load PYTHONSTARTUP env var and ~/.pythonrc.py script in --code]' \
(--use-pythonrc)'--no-startup[do not load PYTHONSTARTUP env var and ~/.pythonrc.py script in --code]' \
(--no-vi-mode)'--use-vi-mode[use vi-mode in ptpython/ptipython]' \
(--vi-mode)'--no-vi-mode[do not use vi-mode in ptpython/ptipython]' \
'(--no-startup --use-pythonrc)--use-pythonrc[load PYTHONSTARTUP env var and ~/.pythonrc.py script in --code]' \
'(--no-startup --use-pythonrc)--no-startup[do not load PYTHONSTARTUP env var and ~/.pythonrc.py script in --code]' \
'(--use-vi-mode --no-vi-mode)--use-vi-mode[use vi-mode in ptpython/ptipython]' \
'(--use-vi-mode --no-vi-mode)--no-vi-mode[do not use vi-mode in ptpython/ptipython]' \
"1::session name:compadd $sessions" \
"2::window name:compadd $windows"
"2::window name:compadd $windows" \
&& ret=0
;;
(ls|debug-info)
_arguments -C \
'(- *)'{-h,--help}'[show help message and exit]'
_arguments \
'(- *)'{-h,--help}'[show help message and exit]' \
&& ret=0
;;
(edit)
_arguments -C \
_arguments \
'(- *)'{-h,--help}'[show help message and exit]' \
'1:: :_files -g "*.(json|yaml|yml)"'
'1:: :_files -g "*.(json|yaml|yml)"' \
&& ret=0
;;
esac
esac
return ret
}
__tmuxp_load() {
@ -188,7 +193,6 @@ __tmux_windows () {
_tmuxp "$@"
# Local Variables:
# mode: Shell-Script
# sh-indentation: 2