dotfiles/.zsh_functions/_alacritty

63 lines
2.2 KiB
Plaintext
Raw Normal View History

2021-11-13 19:24:20 +01:00
#compdef alacritty
# Completions available for the first parameter.
_alacritty_first_param() {
# Main subcommands.
_describe "command" "(msg:'Available socket messages')"
# Default options.
_alacritty_main
}
# Completions available for parameters after the first.
_alacritty_following_param() {
case $words[2] in
msg)
_alacritty_msg;;
*)
_alacritty_main;;
esac
}
# Completions for the main Alacritty executable.
_alacritty_main() {
# Limit some suggestions to the first option.
local ignore
(( $#words > 2 )) && ignore='!'
_arguments \
"$ignore(-)"{-h,--help}"[print help information]" \
"$ignore(-)"{-V,--version}"[print version information]" \
"--print-events[print all events to stdout]" \
'(-v)'{-q,-qq}"[reduce the level of verbosity (min is -qq)]" \
"--ref-test[generate ref test]" \
"--hold[remain open after child process exits]" \
'(-q)'{-v,-vv,-vvv}"[increase the level of verbosity (max is -vvv)]" \
"--class=[define the window class]:class" \
"--embed=[define the X11 window ID (as a decimal integer) to embed Alacritty within]:windowId" \
"(-e --command)"{-e,--command}"[execute command (must be last arg)]:program: _command_names -e:*::program arguments: _normal" \
"--config-file=[specify an alternative config file]:file:_files" \
"*"{-o=,--option=}"[override config file options]:option" \
"(-t --title)"{-t=,--title=}"[define the window title]:title" \
"--working-directory=[start shell in specified directory]:directory:_directories"\
"--socket=[Path for IPC socket creation]:file:_files"
}
# Completions for the `msg` subcommand.
_alacritty_msg() {
# Limit some suggestions to the first option.
local ignore
(( $#words > 3 )) && ignore='!'
_arguments \
"$ignore(-)"{-h,--help}"[print help information]" \
"$ignore(-)"{-V,--version}"[print version information]" \
"(-s --socket)"{-s=,--socket=}"[Path for IPC socket creation]:file:_files" \
"*: :((create-window:'Create a new window in the same Alacritty process'))"
}
# Handle arguments based on their position.
_arguments \
"1: :_alacritty_first_param" \
"*: :_alacritty_following_param"