foot/completions/bash/footclient
Daniel Eklöf fc9625678f
config: add toplevel-tag=TAG
Add support for the new xdg-toplevel-tag-v1 Wayland protocol, by
exposing a new config option, `toplevel-tag`, and a corresponding
command option, `--toplevel-tag` (in both `foot` and `footclient`).

This can help the compositor with session management, or custom window
rules.

Closes #2212
2025-11-12 11:04:25 +01:00

82 lines
2.5 KiB
Text

# Bash completion script for footclient
_footclient()
{
COMPREPLY=()
local cur prev flags word commands match previous_words i offset
flags=(
"--app-id"
"--toplevel-tag"
"--fullscreen"
"--help"
"--hold"
"--login-shell"
"--log-level"
"--log-colorize"
"--maximized"
"--override"
"--client-environment"
"--server-socket"
"--term"
"--title"
"--version"
"--window-size-pixels"
"--window-size-chars"
"--working-directory"
)
flags="${flags[@]}"
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
# Check if positional argument is completed
previous_words=( "${COMP_WORDS[@]}" )
unset previous_words[-1]
commands=$(compgen -c | grep -vFx "$(compgen -k)" | grep -vE '^([.:[]|footclient)$' | sort -u)
i=0
for word in "${previous_words[@]}" ; do
match=$(printf "$commands" | grep -Fx "$word" 2>/dev/null)
if [[ ! -z "$match" ]] ; then
if [[ ${COMP_WORDS[i-1]} =~ ^(--app-id|--toplevel-tag|--log-level|--server-socket|--term|--title|--window-size-pixels|--window-size-chars|--working-directory)$ ]] ; then
(( i++ ))
continue
fi
# Positional argument found
offset=$i
fi
(( i++ ))
done
if [[ ! -z "$offset" ]] ; then
# Depends on bash_completion being available
declare -F _command_offset >/dev/null || return 1
_command_offset $offset
return 0
elif [[ ${cur} == --* ]] ; then
COMPREPLY=( $(compgen -W "${flags}" -- ${cur}) )
return 0
fi
case "$prev" in
--server-socket|-s)
compopt -o default ;;
--working-directory|-D)
compopt -o dirnames ;;
--term|-t)
command -v toe > /dev/null || return 1
COMPREPLY=( $(compgen -W "$(toe -a | awk '$1 ~ /[+]/ {next}; {print $1}')" -- ${cur}) ) ;;
--log-level|-d)
COMPREPLY=( $(compgen -W "none error warning info" -- ${cur}) ) ;;
--log-colorize|-l)
COMPREPLY=( $(compgen -W "never always auto" -- ${cur}) ) ;;
--app-id|--toplevel-tag|--help|--override|--title|--version|--window-size-chars|--window-size-pixels|-[ahoTvWw])
# Don't autocomplete for these flags
: ;;
*)
# Complete commands from $PATH
COMPREPLY=( $(compgen -c -- ${cur}) ) ;;
esac
return 0
}
complete -F _footclient footclient