Debian Codegraph @

completions/bash/footclient

raw
1 # Bash completion script for footclient
2 _footclient()
3 {
4 COMPREPLY=()
5
6 local cur prev flags word commands match previous_words i offset
7 flags=(
8 "--app-id"
9 "--toplevel-tag"
10 "--fullscreen"
11 "--help"
12 "--hold"
13 "--login-shell"
14 "--log-level"
15 "--log-colorize"
16 "--maximized"
17 "--override"
18 "--client-environment"
19 "--server-socket"
20 "--term"
21 "--title"
22 "--version"
23 "--window-size-pixels"
24 "--window-size-chars"
25 "--working-directory"
26 )
27 flags="${flags[@]}"
28 cur=${COMP_WORDS[COMP_CWORD]}
29 prev=${COMP_WORDS[COMP_CWORD-1]}
30
31 # Check if positional argument is completed
32 previous_words=( "${COMP_WORDS[@]}" )
33 unset previous_words[-1]
34 commands=$(compgen -c | grep -vFx "$(compgen -k)" | grep -vE '^([.:[]|footclient)$' | sort -u)
35 i=0
36 for word in "${previous_words[@]}" ; do
37 match=$(printf "$commands" | grep -Fx "$word" 2>/dev/null)
38 if [[ ! -z "$match" ]] ; then
39 if [[ ${COMP_WORDS[i-1]} =~ ^(--app-id|--toplevel-tag|--log-level|--server-socket|--term|--title|--window-size-pixels|--window-size-chars|--working-directory)$ ]] ; then
40 (( i++ ))
41 continue
42 fi
43 # Positional argument found
44 offset=$i
45 fi
46 (( i++ ))
47 done
48
49 if [[ ! -z "$offset" ]] ; then
50 # Depends on bash_completion being available
51 declare -F _command_offset >/dev/null || return 1
52 _command_offset $offset
53 return 0
54 elif [[ ${cur} == --* ]] ; then
55 COMPREPLY=( $(compgen -W "${flags}" -- ${cur}) )
56 return 0
57 fi
58
59 case "$prev" in
60 --server-socket|-s)
61 compopt -o default ;;
62 --working-directory|-D)
63 compopt -o dirnames ;;
64 --term|-t)
65 command -v toe > /dev/null || return 1
66 COMPREPLY=( $(compgen -W "$(toe -a | awk '$1 ~ /[+]/ {next}; {print $1}')" -- ${cur}) ) ;;
67 --log-level|-d)
68 COMPREPLY=( $(compgen -W "none error warning info" -- ${cur}) ) ;;
69 --log-colorize|-l)
70 COMPREPLY=( $(compgen -W "never always auto" -- ${cur}) ) ;;
71 --app-id|--toplevel-tag|--help|--override|--title|--version|--window-size-chars|--window-size-pixels|-[ahoTvWw])
72 # Don't autocomplete for these flags
73 : ;;
74 *)
75 # Complete commands from $PATH
76 COMPREPLY=( $(compgen -c -- ${cur}) ) ;;
77 esac
78
79 return 0
80 }
81
82 complete -F _footclient footclient