diff options
author | 2021-02-13 20:14:28 +0000 | |
---|---|---|
committer | 2021-02-13 20:14:28 +0000 | |
commit | 3eac07647ad20e8a5115d0d8721e0734f2131833 (patch) | |
tree | 2af76d567677b8af1f8486ab19bfba1237bdf78a /src/bash_completion/firejail.bash_completion.in | |
parent | mkasc.sh: fix typo of Calculating (diff) | |
parent | Add first version of zsh completion (diff) | |
download | firejail-3eac07647ad20e8a5115d0d8721e0734f2131833.tar.gz firejail-3eac07647ad20e8a5115d0d8721e0734f2131833.tar.zst firejail-3eac07647ad20e8a5115d0d8721e0734f2131833.zip |
Merge pull request #3864 from haraldkubota/master
Add first version of zsh completion
Diffstat (limited to 'src/bash_completion/firejail.bash_completion.in')
-rw-r--r-- | src/bash_completion/firejail.bash_completion.in | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/src/bash_completion/firejail.bash_completion.in b/src/bash_completion/firejail.bash_completion.in new file mode 100644 index 000000000..00f04c310 --- /dev/null +++ b/src/bash_completion/firejail.bash_completion.in | |||
@@ -0,0 +1,122 @@ | |||
1 | # bash completion for firejail -*- shell-script -*- | ||
2 | #******************************************************************** | ||
3 | # Script based on completions/configure script in bash-completion package in | ||
4 | # Debian. The original package is release under GPL v2 license, the webpage is | ||
5 | # http://bash-completion.alioth.debian.org | ||
6 | #******************************************************************* | ||
7 | |||
8 | __interfaces(){ | ||
9 | cut -f 1 -d ':' /proc/net/dev | tail -n +3 | grep -v lo | xargs | ||
10 | } | ||
11 | |||
12 | _profiles() { | ||
13 | if [[ -d "$1" ]] ; then | ||
14 | ls -1 $1/*.profile 2>/dev/null | sed -E 's;^.*\/;;g' | ||
15 | fi | ||
16 | } | ||
17 | _all_profiles() { | ||
18 | local sys_profiles=$(_profiles _SYSCONFDIR_/firejail) | ||
19 | local user_profiles=$(_profiles $HOME/.config/firejail) | ||
20 | COMPREPLY=($(compgen -W "${sys_profiles} ${user_profiles}" -- "$cur")) | ||
21 | } | ||
22 | |||
23 | |||
24 | _firejail() | ||
25 | { | ||
26 | local cur prev words cword split | ||
27 | _init_completion -s || return | ||
28 | |||
29 | case $prev in | ||
30 | --help|--version|-debug-caps|--debug-syscalls|--debug-syscalls32|--list|--tree|--top|--join|--shutdown) | ||
31 | return 0 | ||
32 | ;; | ||
33 | --profile) | ||
34 | _all_profiles | ||
35 | return 0 | ||
36 | ;; | ||
37 | --hosts-file) | ||
38 | _filedir | ||
39 | return 0 | ||
40 | ;; | ||
41 | --chroot) | ||
42 | _filedir -d | ||
43 | return 0 | ||
44 | ;; | ||
45 | --cgroup) | ||
46 | _filedir -d | ||
47 | return 0 | ||
48 | ;; | ||
49 | --tmpfs) | ||
50 | _filedir | ||
51 | return 0 | ||
52 | ;; | ||
53 | --blacklist) | ||
54 | _filedir | ||
55 | return 0 | ||
56 | ;; | ||
57 | --noblacklist) | ||
58 | _filedir | ||
59 | return 0 | ||
60 | ;; | ||
61 | --whitelist) | ||
62 | _filedir | ||
63 | return 0 | ||
64 | ;; | ||
65 | --nowhitelist) | ||
66 | _filedir | ||
67 | return 0 | ||
68 | ;; | ||
69 | --read-only) | ||
70 | _filedir | ||
71 | return 0 | ||
72 | ;; | ||
73 | --read-write) | ||
74 | _filedir | ||
75 | return 0 | ||
76 | ;; | ||
77 | --bind) | ||
78 | _filedir | ||
79 | return 0 | ||
80 | ;; | ||
81 | --private) | ||
82 | _filedir | ||
83 | return 0 | ||
84 | ;; | ||
85 | --netfilter) | ||
86 | _filedir | ||
87 | return 0 | ||
88 | ;; | ||
89 | --shell) | ||
90 | _filedir | ||
91 | return 0 | ||
92 | ;; | ||
93 | --audit) | ||
94 | _filedir | ||
95 | return 0 | ||
96 | ;; | ||
97 | --net) | ||
98 | comps=$(__interfaces) | ||
99 | COMPREPLY=( $(compgen -W '$comps' -- "$cur") ) | ||
100 | return 0 | ||
101 | ;; | ||
102 | esac | ||
103 | |||
104 | $split && return 0 | ||
105 | |||
106 | # if $COMP_CONFIGURE_HINTS is not null, then completions of the form | ||
107 | # --option=SETTING will include 'SETTING' as a contextual hint | ||
108 | [[ "$cur" != -* ]] && _command && return 0 | ||
109 | |||
110 | if [[ -n $COMP_CONFIGURE_HINTS ]]; then | ||
111 | COMPREPLY=( $( compgen -W "$( $1 --help 2>&1 | \ | ||
112 | awk '/^ --[A-Za-z]/ { print $1; \ | ||
113 | if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,].*//g' )" \ | ||
114 | -- "$cur" ) ) | ||
115 | [[ $COMPREPLY == *=* ]] && compopt -o nospace | ||
116 | else | ||
117 | COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) | ||
118 | [[ $COMPREPLY == *= ]] && compopt -o nospace | ||
119 | fi | ||
120 | |||
121 | } && | ||
122 | complete -F _firejail firejail | ||