1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
#autoload
# This function completes POSIX capabilities for Linux.
# Many command line utilities expect different syntax to encode various kinds
# of capability names or sets, so this function tries to be as generic as
# possible. It accepts compadd options to allow variations on the exact
# generated completion matches.
#
# Usage examples:
#
# Complete full capability names:
# _capabilities -p cap_
# Sort the completion list by capability number:
# _capabilities -o nosort
# The list of Linux capabilities is taken from include/uapi/linux/capability.h
# and subject to the following pipe filter:
# grep 'define CAP' | sed -r 's/^[[:space:]]*#define[[:space:]]+CAP_//; s/[[:space:]]+[0-9]+$//' | tr '[[:upper:]]' '[[:lower:]]'
local -a caplist=(
chown
dac_override
dac_read_search
fowner
fsetid
kill
setgid
setuid
setpcap
linux_immutable
net_bind_service
net_broadcast
net_admin
net_raw
ipc_lock
ipc_owner
sys_module
sys_rawio
sys_chroot
sys_ptrace
sys_pacct
sys_admin
sys_boot
sys_nice
sys_resource
sys_time
sys_tty_config
mknod
lease
audit_write
audit_control
setfcap
mac_override
mac_admin
syslog
wake_alarm
block_suspend
audit_read
perfmon
bpf
checkpoint_restore
)
local -a expl
_description capabilities expl "Linux capability"
compadd "${(@)expl}" "$@" -a - caplist
|