feat(aa-log): add bash & improve zsh completion.
This commit is contained in:
parent
0177b68308
commit
80bb01ad3c
2 changed files with 35 additions and 8 deletions
26
root/usr/share/bash-completion/completions/aa-log
Normal file
26
root/usr/share/bash-completion/completions/aa-log
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
# aa-log completion
|
||||||
|
|
||||||
|
_aa-log() {
|
||||||
|
COMPREPLY=()
|
||||||
|
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
local args=(-f -d -h)
|
||||||
|
local lastarg="${COMP_WORDS[$COMP_CWORD-1]}"
|
||||||
|
COMPREPLY+=($(compgen -W "${args[*]}" -- ${cur}))
|
||||||
|
if [[ $lastarg == "-f" ]]; then
|
||||||
|
COMPREPLY+=($(compgen -W "$(__aa_files)" -- ${cur}))
|
||||||
|
COMPREPLY+=($(compgen -o filenames -A file -- ${cur}))
|
||||||
|
else
|
||||||
|
COMPREPLY+=($(compgen -W "${args[*]}" -- ${cur}))
|
||||||
|
COMPREPLY+=($(compgen -W "$(__aa_profiles)" -- ${cur}))
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
__aa_files() {
|
||||||
|
find /var/log/audit/ -type f -printf '%P\n' | cut -d '.' -f 3
|
||||||
|
}
|
||||||
|
|
||||||
|
__aa_profiles() {
|
||||||
|
find -L /etc/apparmor.d -maxdepth 1 -type f -printf '%P\n' | sort
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -F _aa-log aa-log
|
||||||
|
|
@ -1,22 +1,23 @@
|
||||||
#compdef aa-log
|
#compdef aa-log
|
||||||
#autoload
|
#autoload
|
||||||
|
|
||||||
_aa-log () {
|
_aa-log() {
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
_arguments : \
|
_arguments : \
|
||||||
-f'[set a logfile or a prefix to the default log file]:_files' \
|
-f'[set a logfile or a prefix to the default log file]:FILE:__aa_files' \
|
||||||
|
-d'[show dbus session event]' \
|
||||||
-h'[display help information]'
|
-h'[display help information]'
|
||||||
|
|
||||||
_values -C 'profile names' ${$(__aa_profiles):-""}
|
_values -C 'profile names' ${$(__aa_profiles):-""}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__aa_files() {
|
||||||
|
find /var/log/audit/ -type f -printf '%P\n' | cut -d '.' -f 3
|
||||||
|
_files
|
||||||
|
}
|
||||||
|
|
||||||
__aa_profiles() {
|
__aa_profiles() {
|
||||||
find -L /etc/apparmor.d -type f -printf '%P\n' \
|
find -L /etc/apparmor.d -maxdepth 1 -type f -printf '%P\n' | sort
|
||||||
| sed -e '/abi/d' \
|
|
||||||
-e '/abstractions/d' \
|
|
||||||
-e '/local/d' \
|
|
||||||
-e '/tunables/d' \
|
|
||||||
| sort
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_aa-log
|
_aa-log
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue