feat(aa-log): add bash & improve zsh completion.

This commit is contained in:
Alexandre Pujol 2022-09-13 18:15:47 +01:00
parent 0177b68308
commit 80bb01ad3c
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
2 changed files with 35 additions and 8 deletions

View 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