From 8681f71084894db6d1e258be17db1f80bb669314 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Mon, 22 Nov 2021 21:34:09 +0300 Subject: Add parameters to `msg create-window` subcommand Alacritty's `msg create-window` subcommand would previously inherit all the CLI parameters from the original executable. However not only could this lead to unexpected behavior, it also prevents multi-window users from making use of parameters like `-e`, `--working-directory`, or `--hold`. This is solved by adding a JSON-based message format to the IPC socket messages which instructs the Alacritty server on which CLI parameters should be used to create the new window. Fixes #5562. Fixes #5561. Fixes #5560. --- extra/alacritty-msg.man | 16 +++++++++++++--- extra/completions/_alacritty | 12 ++++++++---- extra/completions/alacritty.bash | 30 +++++++++++++++++++++--------- extra/completions/alacritty.fish | 9 ++++++--- 4 files changed, 48 insertions(+), 19 deletions(-) (limited to 'extra') diff --git a/extra/alacritty-msg.man b/extra/alacritty-msg.man index 818169d0..5ccb3014 100644 --- a/extra/alacritty-msg.man +++ b/extra/alacritty-msg.man @@ -2,18 +2,28 @@ .SH NAME alacritty-msg \- Send messages to Alacritty .SH "SYNOPSIS" -alacritty msg [OPTIONS] [MESSAGES] +alacritty msg [OPTIONS] [MESSAGE_OPTIONS] .SH DESCRIPTION This command communicates with running Alacritty instances through a socket, making it possible to control Alacritty without directly accessing it. .SH "OPTIONS" -.TP \fB\-s\fR, \fB\-\-socket\fR Path for IPC socket creation .SH "MESSAGES" -.TP \fBcreate-window\fR Create a new window in the same Alacritty process +.TP +.SH "\tOPTIONS" +.RS 12 +\fB\-\-hold\fR +Remain open after child process exits + +\fB\-\-working\-directory\fR +Start the shell in the specified working directory + +\fB\-e\fR, \fB\-\-command\fR ... +Command and args to execute (must be last argument) +.RE .SH "SEE ALSO" See the alacritty github repository at https://github.com/alacritty/alacritty for the full documentation. .SH "BUGS" diff --git a/extra/completions/_alacritty b/extra/completions/_alacritty index 32086910..59ed92b2 100644 --- a/extra/completions/_alacritty +++ b/extra/completions/_alacritty @@ -19,18 +19,18 @@ _alacritty() { '--title=[Defines the window title \[default: Alacritty\]]' \ '--class=[Defines window class/app_id on X11/Wayland \[default: Alacritty\]]' \ '--embed=[Defines the X11 window ID (as a decimal integer) to embed Alacritty within]' \ -'--working-directory=[Start the shell in the specified working directory]' \ '--config-file=[Specify alternative configuration file \[default: $XDG_CONFIG_HOME/alacritty/alacritty.yml\]]' \ '--socket=[Path for IPC socket creation]' \ -'*-e+[Command and args to execute (must be last argument)]' \ -'*--command=[Command and args to execute (must be last argument)]' \ '*-o+[Override configuration file options \[example: cursor.style=Beam\]]' \ '*--option=[Override configuration file options \[example: cursor.style=Beam\]]' \ +'--working-directory=[Start the shell in the specified working directory]' \ +'*-e+[Command and args to execute (must be last argument)]' \ +'*--command=[Command and args to execute (must be last argument)]' \ '--print-events[Print all events to stdout]' \ '--ref-test[Generates ref test]' \ -'--hold[Remain open after child process exits]' \ '(-v)*-q[Reduces the level of verbosity (the min level is -qq)]' \ '(-q)*-v[Increases the level of verbosity (the max level is -vvv)]' \ +'--hold[Remain open after child process exit]' \ '-h[Prints help information]' \ '--help[Prints help information]' \ '-V[Prints version information]' \ @@ -63,6 +63,10 @@ case $state in case $line[1] in (create-window) _arguments "${_arguments_options[@]}" \ +'--working-directory=[Start the shell in the specified working directory]' \ +'*-e+[Command and args to execute (must be last argument)]' \ +'*--command=[Command and args to execute (must be last argument)]' \ +'--hold[Remain open after child process exit]' \ '-h[Prints help information]' \ '--help[Prints help information]' \ '-V[Prints version information]' \ diff --git a/extra/completions/alacritty.bash b/extra/completions/alacritty.bash index 0a9b286e..7ce57f9d 100644 --- a/extra/completions/alacritty.bash +++ b/extra/completions/alacritty.bash @@ -29,7 +29,7 @@ _alacritty() { case "${cmd}" in alacritty) - opts=" -q -v -h -V -t -e -o --print-events --ref-test --hold --help --version --title --class --embed --working-directory --config-file --socket --command --option msg help" + opts=" -q -v -h -V -t -o -e --print-events --ref-test --hold --help --version --title --class --embed --config-file --socket --option --working-directory --command msg help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -52,31 +52,31 @@ _alacritty() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --working-directory) + --config-file) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --config-file) + --socket) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --socket) + --option) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --command) + -o) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - -e) + --working-directory) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - --option) + --command) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; - -o) + -e) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; @@ -127,13 +127,25 @@ _alacritty() { return 0 ;; alacritty__msg__create__window) - opts=" -h -V --help --version " + opts=" -h -V -e --hold --help --version --working-directory --command " if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 fi case "${prev}" in + --working-directory) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --command) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -e) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; *) COMPREPLY=() ;; diff --git a/extra/completions/alacritty.fish b/extra/completions/alacritty.fish index 48f118c2..09cc6c0f 100644 --- a/extra/completions/alacritty.fish +++ b/extra/completions/alacritty.fish @@ -1,16 +1,16 @@ complete -c alacritty -n "__fish_use_subcommand" -s t -l title -d 'Defines the window title [default: Alacritty]' complete -c alacritty -n "__fish_use_subcommand" -l class -d 'Defines window class/app_id on X11/Wayland [default: Alacritty]' complete -c alacritty -n "__fish_use_subcommand" -l embed -d 'Defines the X11 window ID (as a decimal integer) to embed Alacritty within' -complete -c alacritty -n "__fish_use_subcommand" -l working-directory -d 'Start the shell in the specified working directory' complete -c alacritty -n "__fish_use_subcommand" -l config-file -d 'Specify alternative configuration file [default: $XDG_CONFIG_HOME/alacritty/alacritty.yml]' complete -c alacritty -n "__fish_use_subcommand" -l socket -d 'Path for IPC socket creation' -complete -c alacritty -n "__fish_use_subcommand" -s e -l command -d 'Command and args to execute (must be last argument)' complete -c alacritty -n "__fish_use_subcommand" -s o -l option -d 'Override configuration file options [example: cursor.style=Beam]' +complete -c alacritty -n "__fish_use_subcommand" -l working-directory -d 'Start the shell in the specified working directory' +complete -c alacritty -n "__fish_use_subcommand" -s e -l command -d 'Command and args to execute (must be last argument)' complete -c alacritty -n "__fish_use_subcommand" -l print-events -d 'Print all events to stdout' complete -c alacritty -n "__fish_use_subcommand" -l ref-test -d 'Generates ref test' -complete -c alacritty -n "__fish_use_subcommand" -l hold -d 'Remain open after child process exits' complete -c alacritty -n "__fish_use_subcommand" -s q -d 'Reduces the level of verbosity (the min level is -qq)' complete -c alacritty -n "__fish_use_subcommand" -s v -d 'Increases the level of verbosity (the max level is -vvv)' +complete -c alacritty -n "__fish_use_subcommand" -l hold -d 'Remain open after child process exit' complete -c alacritty -n "__fish_use_subcommand" -s h -l help -d 'Prints help information' complete -c alacritty -n "__fish_use_subcommand" -s V -l version -d 'Prints version information' complete -c alacritty -n "__fish_use_subcommand" -f -a "msg" -d 'Available socket messages' @@ -20,6 +20,9 @@ complete -c alacritty -n "__fish_seen_subcommand_from msg" -s h -l help -d 'Prin complete -c alacritty -n "__fish_seen_subcommand_from msg" -s V -l version -d 'Prints version information' complete -c alacritty -n "__fish_seen_subcommand_from msg" -f -a "create-window" -d 'Create a new window in the same Alacritty process' complete -c alacritty -n "__fish_seen_subcommand_from msg" -f -a "help" -d 'Prints this message or the help of the given subcommand(s)' +complete -c alacritty -n "__fish_seen_subcommand_from create-window" -l working-directory -d 'Start the shell in the specified working directory' +complete -c alacritty -n "__fish_seen_subcommand_from create-window" -s e -l command -d 'Command and args to execute (must be last argument)' +complete -c alacritty -n "__fish_seen_subcommand_from create-window" -l hold -d 'Remain open after child process exit' complete -c alacritty -n "__fish_seen_subcommand_from create-window" -s h -l help -d 'Prints help information' complete -c alacritty -n "__fish_seen_subcommand_from create-window" -s V -l version -d 'Prints version information' complete -c alacritty -n "__fish_seen_subcommand_from help" -s h -l help -d 'Prints help information' -- cgit v1.2.3