bash-completion: sys-utils

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2013-03-24 17:19:09 +00:00
parent 18b0017ae6
commit c6f8c3f5ce
30 changed files with 1219 additions and 0 deletions

View File

@ -0,0 +1,25 @@
_blkdiscard_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-o'|'--offset'|'-l'|'--length')
COMPREPLY=( $(compgen -W "num" -- $cur) )
return 0
;;
esac
case $cur in
-*)
OPTS="-o --offset -l --length -s --secure -v --verbose -h --help -V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
local DEVS
DEVS=''; while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
return 0
}
complete -F _blkdiscard_module blkdiscard

44
shell-completion/chcpu Normal file
View File

@ -0,0 +1,44 @@
_chcpu_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-e'|'--enable')
local CPULIST
# FIXME: will propose only binding to a cpu.
# Maybe this should add comma, and continue?
CPULIST=$(sed 's/^/{/; s/-/../g; s/,/} {/g; s/$/}/' /sys/devices/system/cpu/offline)
COMPREPLY=( $(compgen -W "$(eval echo $CPULIST)" -- $cur) )
return 0
;;
'-d'|'--disable')
local CPULIST
# FIXME: will propose only binding to a cpu.
# Maybe this should add comma, and continue?
CPULIST=$(sed 's/^/{/; s/-/../g; s/,/} {/g; s/$/}/' /sys/devices/system/cpu/online)
COMPREPLY=( $(compgen -W "$(eval echo $CPULIST)" -- $cur) )
return 0
;;
'-c'|'--configure'|'-g'|'--deconfigure')
COMPREPLY=( $(compgen -W "cpu-list" -- $cur) )
return 0
;;
'-p'|'--dispatch')
COMPREPLY=( $(compgen -W "horizontal vertical" -- $cur) )
return 0
;;
esac
OPTS="-h --help
-e --enable
-d --disable
-c --configure
-g --deconfigure
-p --dispatch
-r --rescan
-V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
}
complete -F _chcpu_module chcpu

View File

@ -0,0 +1,11 @@
_ctrlaltdel_module()
{
local cur
cur="${COMP_WORDS[COMP_CWORD]}"
COMPREPLY=()
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $(compgen -W "hard soft" -- $cur) )
fi
return 0
}
complete -F _ctrlaltdel_module ctrlaltdel

37
shell-completion/cytune Normal file
View File

@ -0,0 +1,37 @@
_cytune_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-s'|'--set-threshold'|'-S'|'--set-default-threshold'|'-t'|'--set-flush'|'-T'|'--set-default-flush')
COMPREPLY=( $(compgen -W "num" -- $cur) )
return 0
;;
'-i'|'--interval')
COMPREPLY=( $(compgen -W "seconds" -- $cur) )
return 0
;;
esac
case $cur in
-*)
OPTS="-s --set-threshold
-g --get-threshold
-S --set-default-threshold
-t --set-flush
-G --get-glush
-T --set-default-flush
-q --stats
-i --interval
-h --help
-V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
compopt -o filenames
COMPREPLY=( $(compgen -f -- ${cur:-"/dev/tty"}) )
return 0
}
complete -F _cytune_module cytune

53
shell-completion/dmesg Normal file
View File

@ -0,0 +1,53 @@
_dmesg_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-F'|'--file')
compopt -o filenames
COMPREPLY=( $(compgen -f -- $cur) )
return 0
;;
'-f'|'--facility')
COMPREPLY=( $(compgen -W "kern user mail daemon auth syslog lpr news" -- $cur) )
return 0
;;
'-l'|'--level'|'-n'|'--console-level')
COMPREPLY=( $(compgen -W "emerg alert crit err warn notice info debug" -- $cur) )
return 0
;;
'-s'|'--buffer-size')
COMPREPLY=( $(compgen -W "size" -- $cur) )
return 0
;;
esac
OPTS="-C --clear
-c --read-clear
-D --console-off
-d --show-delta
-e --reltime
-E --console-on
-F --file
-f --facility
-H --human
-k --kernel
-L --color
-l --level
-n --console-level
-P --nopager
-r --raw
-S --syslog
-s --buffer-size
-T --ctime
-t --notime
-u --userspace
-w --follow
-x --decode
-h --help
-V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
}
complete -F _dmesg_module dmesg

61
shell-completion/eject Normal file
View File

@ -0,0 +1,61 @@
_eject_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-a'|'--auto'|'-i'|'--manualeject')
COMPREPLY=( $(compgen -W "off on" -- $cur) )
return 0
;;
'-c'|'--changerslot')
# FIXME: there must be way to determine slots
COMPREPLY=( $(compgen -W "slot" -- $cur) )
return 0
;;
'-x'|'--cdspeed')
COMPREPLY=( $(compgen -W "$(eject -X)" -- $cur) )
return 0
;;
esac
case $cur in
-*)
OPTS="-a --auto
-c --changerslot
-d --default
-f --floppy
-F --force
-i --manualeject
-m --no-unmount
-M --no-partitions-unmount
-n --noop
-p --proc
-q --tape
-r --cdrom
-s --scsi
-t --trayclose
-T --traytoggle
-v --verbose
-x --cdspeed
-X --listspeed
-h --help
-V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
local DEVS
DEVS="$(for I in /sys/class/block/*/removable; do
if [ $(cat $I) -ne 0 ]; then
OLD_IFS=$IFS
IFS='/';
ARR=($I)
echo "/dev/${ARR[4]}"
IFS=$OLD_IFS
fi
done)"
COMPREPLY=( $(compgen -W "$DEVS" $cur) )
return 0
}
complete -F _eject_module eject

View File

@ -0,0 +1,24 @@
_fallocate_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-o'|'--offset'|'-l'|'--length')
COMPREPLY=( $(compgen -W "bytes" -- $cur) )
return 0
;;
esac
case $cur in
-*)
OPTS="-n --keep-size -p --punch-hole -o --offset -l --length -h --help -V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
compopt -o filenames
COMPREPLY=( $(compgen -f -- $cur) )
return 0
}
complete -F _fallocate_module fallocate

42
shell-completion/flock Normal file
View File

@ -0,0 +1,42 @@
_flock_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-w'|'--timeout')
COMPREPLY=( $(compgen -W "seconds" -- $cur) )
return 0
;;
'-E'|'--conflict-exit-code')
COMPREPLY=( $(compgen -W "$(echo {0..255})" -- $cur) )
return 0
;;
'-c'|'--command')
compopt -o bashdefault
COMPREPLY=( $(compgen -c -- $cur) )
return 0
;;
esac
case $cur in
-*)
OPTS="-s --shared
-x --exclusive
-u --unlock
-n --nonblock
-w --timeout
-E --conflict-exit-code
-o --close
-c --command
-h --help
-V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
compopt -o filenames
COMPREPLY=( $(compgen -f -- ${cur:-"/"}) )
return 0
}
complete -F _flock_module flock

18
shell-completion/fsfreeze Normal file
View File

@ -0,0 +1,18 @@
_fsfreeze_module()
{
local cur OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
case $cur in
-*)
OPTS="-f --freeze -u --unfreeze -h --help -V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
local MPOINT
MPOINT="$(findmnt -t ext2,ext3,ext4,reiserfs,jfs,xfs -o TARGET -n -r)"
COMPREPLY=( $(compgen -W "$MPOINT" -- $cur) )
return 0
}
complete -F _fsfreeze_module fsfreeze

25
shell-completion/fstrim Normal file
View File

@ -0,0 +1,25 @@
_fstrim_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-o'|'--offset'|'-l'|'--length'|'-m'|'--minimum')
COMPREPLY=( $(compgen -W "num" -- $cur) )
return 0
;;
esac
case $cur in
-*)
OPTS="-o --offset -l --length -m --minimum -v --verbose -h --help -V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
local MPOINTS
MPOINTS=$(findmnt -rno SOURCE | grep ^/dev)
COMPREPLY=( $(compgen -W "$MPOINTS" -- $cur) )
return 0
}
complete -F _fstrim_module fstrim

53
shell-completion/hwclock Normal file
View File

@ -0,0 +1,53 @@
_hwclock_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-f'|'--rtc'|'--adjfile')
compopt -o filenames
COMPREPLY=( $(compgen -f -- $cur) )
return 0
;;
'--date')
COMPREPLY=( $(compgen -W "date" -- $cur) )
return 0
;;
'--epoch')
COMPREPLY=( $(compgen -W "year" -- $cur) )
return 0
;;
esac
case $cur in
-*)
OPTS="-h --help
-r --show
--set
-s --hctosys
-w --systohc
--systz
--adjust
-c --compare
--getepoch
--setepoch
--predict
-V --version
-u --utc
--localtime
-f --rtc
--directisa
--badyear
--date
--epoch
--noadjfile
--adjfile
--test
-D --debug"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
return 0
}
complete -F _hwclock_module hwclock

59
shell-completion/ipcrm Normal file
View File

@ -0,0 +1,59 @@
_ipcrm_module()
{
local cur prev OPTS KEYIDS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-m'|'--shmem-id')
KEYIDS="$(ipcs -m | awk '{if (3 < NR) {print $2}}')"
COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) )
return 0
;;
'-M'|'--shmem-key')
KEYIDS="$(ipcs -m | awk '{if (3 < NR) {print $1}}')"
COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) )
return 0
;;
'-q'|'--queue-id')
KEYIDS="$(ipcs -q | awk '{if (3 < NR) {print $2}}')"
COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) )
return 0
;;
'-Q'|'--queue-key')
KEYIDS="$(ipcs -q | awk '{if (3 < NR) {print $1}}')"
COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) )
return 0
;;
'-s'|'--semaphore-id')
KEYIDS="$(ipcs -s | awk '{if (3 < NR) {print $2}}')"
COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) )
return 0
;;
'-S'|'--semaphore-key')
KEYIDS="$(ipcs -s | awk '{if (3 < NR) {print $1}}')"
COMPREPLY=( $(compgen -W "$KEYIDS" -- $cur) )
return 0
;;
esac
case $cur in
'=')
cur=${cur#=}
COMPREPLY=( $(compgen -W "shm msg sem" -- $cur) )
return 0
;;
esac
OPTS=" -m --shmem-id
-M --shmem-key
-q --queue-id
-Q --queue-key
-s --semaphore-id
-S --semaphore-key
-a= --all=
-v --verbose
-h --help
-V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
}
complete -F _ipcrm_module ipcrm

30
shell-completion/ipcs Normal file
View File

@ -0,0 +1,30 @@
_ipcs_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-i'|'--id')
COMPREPLY=( $(compgen -W "id" -- $cur) )
return 0
;;
esac
OPTS="-i --id
-h --help
-V --version
-m --shmems
-q --queues
-s --semaphores
-a --all
-t --time
-p --pid
-c --creator
-l --limits
-u --summary
--human
-b --bytes"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
}
complete -F _ipcs_module ipcs

54
shell-completion/ldattach Normal file
View File

@ -0,0 +1,54 @@
_ldattach_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-s'|'--speed')
COMPREPLY=( $(compgen -W "speed" -- $cur) )
return 0
;;
'-i'|'--iflag')
local IFLAGS
IFLAGS="BRKINT ICRNL IGNBRK IGNCR IGNPAR IMAXBEL
INLCR INPCK ISTRIP IUCLC IUTF8 IXANY
IXOFF IXON PARMRK
-BRKINT -ICRNL -IGNBRK -IGNCR -IGNPAR -IMAXBEL
-INLCR -INPCK -ISTRIP -IUCLC -IUTF8 -IXANY
-IXOFF -IXON -PARMRK"
COMPREPLY=( $(compgen -W "$IFLAGS" -- $cur) )
return 0
;;
esac
case $cur in
-*)
OPTS="-d --debug
-s --speed
-7 --sevenbits
-8 --eightbits
-n --noparity
-e --evenparity
-o --oddparity
-1 --onestopbit
-2 --twostopbits
-i --iflag
-h --help
-V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
/*)
compopt -o filenames
COMPREPLY=( $(compgen -f -- $cur) )
return 0
;;
esac
local LDISC_DEVICE
LDISC_DEVICE="6PACK AX25 GIGASET GIGASET_M101 HCI HDLC IRDA M101
MOUSE PPP PPS R3964 SLIP STRIP SYNCPPP SYNC_PPP
TTY X25 /dev/"
COMPREPLY=( $(compgen -W "$LDISC_DEVICE" -- $cur) )
return 0
}
complete -F _ldattach_module ldattach

64
shell-completion/losetup Normal file
View File

@ -0,0 +1,64 @@
_losetup_module()
{
local cur prev OPTS ARG
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-d'|'--detach')
ARG="$(losetup --output NAME | awk '{if (1 < NR) {print}}')"
COMPREPLY=( $(compgen -W "$ARG" -- $cur) )
return 0
;;
'-j'|'--associated')
ARG="$(losetup --output BACK-FILE | awk '{if (1 < NR) {print}}')"
COMPREPLY=( $(compgen -W "$ARG" -- $cur) )
return 0
;;
'-c'|'--set-capacity')
ARG="$(for I in /dev/loop[0-9]*; do if [ -e $I ]; then echo $I; fi; done)"
COMPREPLY=( $(compgen -W "$ARG" -- $cur) )
return 0
;;
'-o'|'--offset'|'--sizelimit')
COMPREPLY=( $(compgen -W "number" -- $cur) )
return 0
;;
'-O'|'--output')
# FIXME: how to append to a string with compgen?
local OUTPUT
OUTPUT="NAME AUTOCLEAR BACK-FILE BACK-INO
BACK-MAJ:MIN MAJ:MIN OFFSET PARTSCAN RO
SIZELIMIT"
compopt -o nospace
COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
return 0
;;
esac
case $cur in
-*)
OPTS="-a --all
-d --detach
-D --detach-all
-f --find
-c --set-capacity
-j --associated
-l --list
-o --offset
-O --output
--sizelimit
-P --partscan
-r --read-only
--show
-v --verbose
-h --help
-V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
compopt -o filenames
COMPREPLY=( $(compgen -f -- $cur) )
return 0
}
complete -F _losetup_module losetup

45
shell-completion/lscpu Normal file
View File

@ -0,0 +1,45 @@
_lscpu_module()
{
local cur OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'--extended'|'=')
cur=${cur#=}
# FIXME: how to append to a string with compgen?
OPTS="CPU,
CORE,
SOCKET,
NODE,
BOOK,
CACHE,
POLARIZATION,
ADDRESS,
CONFIGURED,
ONLINE,"
compopt -o nospace
COMPREPLY=( $(compgen -W "$OPTS" -- $cur) )
return 0
;;
esac
case $cur in
-*)
OPTS="-a --all
-b --online
-c --offline
-e= --extended=
-p= --parse=
-s --sysroot
-x --hex
-h --help
-V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
compopt -o filenames
COMPREPLY=( $(compgen -f -- $cur) )
return 0
}
complete -F _lscpu_module lscpu

View File

@ -0,0 +1,24 @@
_mountpoint_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-f'|'--fixme')
COMPREPLY=( $(compgen -W "fixme" -- $cur) )
return 0
;;
esac
case $cur in
-*)
OPTS="-q --quiet -d --fs-devno -x --devno -h --help -V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
compopt -o filenames
COMPREPLY=( $(compgen -f -- ${cur:-"/"}) )
return 0
}
complete -F _mountpoint_module mountpoint

44
shell-completion/nsenter Normal file
View File

@ -0,0 +1,44 @@
_nsenter_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-t'|'--target')
local PIDS
PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done)
COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
return 0
;;
esac
case $cur in
'=')
# FIXME: --root and --wd should use get only
# directories as compgen output. If $cur is
# overwrote the same way as below in case segment
# for $prev the command-line will get mangled.
cur=${cur#=}
;;
-*)
OPTS="-t --target
-m= --mount=
-u= --uts=
-i= --ipc=
-n= --net=
-p= --pid=
-U= --user=
-r= --root=
-w= --wd=
-F --no-fork
-h --help
-V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
compopt -o filenames
COMPREPLY=( $(compgen -f -- $cur) )
return 0
}
complete -F _nsenter_module nsenter

View File

@ -0,0 +1,14 @@
_pivot_root_module()
{
local cur
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
case $COMP_CWORD in
1|2)
compopt -o filenames
COMPREPLY=( $(compgen -o dirnames -- ${cur:-"/"}) )
;;
esac
return 0
}
complete -F _pivot_root_module pivot_root

60
shell-completion/prlimit Normal file
View File

@ -0,0 +1,60 @@
_prlimit_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-p'|'--pid')
PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done)
COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
return 0
;;
'-o'|'--output')
# FIXME: how to append to a string with compgen?
local OUTPUT
OUTPUT="DESCRIPTION RESOURCE SOFT HARD UNITS"
compopt -o nospace
COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
return 0
;;
esac
case $cur in
'=')
cur=${cur#=}
# FIXME: is there anything what could be printed
# as limit value(s)
;;
-*)
OPTS="-p --pid
-o --output
--noheadings
--raw
--verbose
-h --help
-V --version
-c= --core=
-d= --data=
-e= --nice=
-f= --fsize=
-i= --sigpending=
-l= --memlock=
-m= --rss=
-n= --nofile=
-q= --msgqueue=
-r= --rtprio=
-s= --stack=
-t= --cpu=
-u= --nproc=
-v= --as=
-x= --locks=
-y --rttime"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
compopt -o bashdefault
COMPREPLY=( $(compgen -c -- $cur) )
return 0
}
complete -F _prlimit_module prlimit

View File

@ -0,0 +1,33 @@
_readprofile_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-m'|'--mapfile'|'-p'|'--profile')
compopt -o filenames
COMPREPLY=( $(compgen -f -- $cur) )
return 0
;;
'-M'|'--multiplier')
COMPREPLY=( $(compgen -W "multiplier" -- $cur) )
return 0
;;
esac
OPTS="-m --mapfile
-p --profile
-M --multiplier
-i --info
-v --verbose
-a --all
-b --histbin
-s --counters
-r --reset
-n --no-auto
-h --help
-V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
}
complete -F _readprofile_module readprofile

38
shell-completion/renice Normal file
View File

@ -0,0 +1,38 @@
_renice_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-g'|'--pgrp')
local PGRP
PGRP=$(ps -ax -opgrp | sed '1d')
COMPREPLY=( $(compgen -W "$PGRP" -- $cur) )
return 0
;;
'-n'|'--priority')
COMPREPLY=( $(compgen -W "$(echo {-20..20})" -- $cur) )
return 0
;;
'-p'|'--pid')
local PIDS
PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done)
COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
return 0
;;
'-u'|'--user')
COMPREPLY=( $(compgen -u -- $cur) )
return 0
;;
esac
OPTS="-g --pgrp
-n --priority
-p --pid
-u --user
-h --help
-V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
}
complete -F _renice_module renice

40
shell-completion/rtcwake Normal file
View File

@ -0,0 +1,40 @@
_rtcwake_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-d'|'--device')
local RTC_DEVS
RTC_DEVS=$(cd /sys/class/rtc/ && echo *)
COMPREPLY=( $(compgen -W "$RTC_DEVS" -- $cur) )
return 0
;;
'-m'|'--mode')
COMPREPLY=( $(compgen -W "standby mem disk off no on disable show" -- $cur) )
return 0
;;
'-s'|'--seconds')
COMPREPLY=( $(compgen -W "seconds" -- $cur) )
return 0
;;
'-t'|'--time')
COMPREPLY=( $(compgen -W "time_t" -- $cur) )
return 0
;;
esac
OPTS="-d --device
-n --dry-run
-l --local
-m --mode
-s --seconds
-t --time
-u --utc
-v --verbose
-h --help
-V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
}
complete -F _rtcwake_module rtcwake

42
shell-completion/setarch Normal file
View File

@ -0,0 +1,42 @@
_setarch_module()
{
local cur OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $(compgen -W "linux32 linux64 ppc32 ppc ppc64
ppc64pseries ppc64iseries i386
i486 i586 i686 athlon x86_64
ia64 parisc32 parisc parisc64
s390 s390x sparc sparc32bash
sparc32 sparc64 mips32 mips
mips64 alpha alphaev5 alphaev56
alphaev6 alphaev67" -- $cur) )
return 0
fi
case $cur in
-*)
OPTS="-v, --verbose
-R, --addr-no-randomize
-F, --fdpic-funcptrs
-Z, --mmap-page-zero
-L, --addr-compat-layout
-X, --read-implies-exec
-B, --32bit
-I, --short-inode
-S, --whole-seconds
-T, --sticky-timeouts
-3, --3gb
--4gb
--uname-2.6
-h, --help
-V, --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
compopt -o bashdefault
COMPREPLY=( $(compgen -c -- $cur) )
return 0
}
complete -F _setarch_module setarch

82
shell-completion/setpriv Normal file
View File

@ -0,0 +1,82 @@
_setpriv_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'--inh-caps'|'--bounding-set')
# FIXME: how to append to a string with compgen?
local INHERIT
INHERIT=$(setpriv --list-caps| awk '{print $1, "-" $1}')
compopt -o nospace
COMPREPLY=( $(compgen -W "all $INHERIT" -S ',' -- $cur) )
return 0
;;
'--ruid'|'--euid'|'--reuid')
local UIDS
UIDS=$(getent passwd | awk -F: '{print $3}')
COMPREPLY=( $(compgen -W "$UIDS" -- $cur) )
return 0
;;
'--rgid'|'--egid'|'--regid')
local GIDS
GIDS=$(getent group | awk -F: '{print $3}')
COMPREPLY=( $(compgen -W "$GIDS" -- $cur) )
return 0
;;
'--groups')
# FIXME: how to append to a string with compgen?
local GIDS
GIDS=$(getent group | awk -F: '{print $3}')
compopt -o nospace
COMPREPLY=( $(compgen -W "$GIDS" -S ',' -- $cur) )
return 0
;;
'--securebits')
local SBITS
SBITS="noroot noroot_locked no_setuid_fixup no_setuid_fixup_locked keep_caps_locked
-noroot -noroot_locked -no_setuid_fixup -no_setuid_fixup_locked -keep_caps_locked"
COMPREPLY=( $(compgen -W "$SBITS" -- $cur) )
return 0
;;
'--selinux-label')
# FIXME: how to list selinux labels?
COMPREPLY=( $(compgen -W "label" -- $cur) )
return 0
;;
'--apparmor-profile')
# FIXME: how to list apparmor profiles?
COMPREPLY=( $(compgen -W "profile" -- $cur) )
return 0
;;
esac
case $cur in
-*)
OPTS="-d --dump
--nnp --no-new-privs
--inh-caps
--bounding-set
--ruid
--euid
--rgid
--egid
--reuid
--regid
--clear-groupsclear
--keep-groupskeep
--groups
--securebits
--selinux-label
--apparmor-profile
-h --help
-V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
compopt -o bashdefault
COMPREPLY=( $(compgen -c -- $cur) )
return 0
}
complete -F _setpriv_module setpriv

17
shell-completion/setsid Normal file
View File

@ -0,0 +1,17 @@
_setsid_module()
{
local cur OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
case $cur in
-*)
OPTS="-c --ctty -h --help -V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
compopt -o bashdefault
COMPREPLY=( $(compgen -c -- $cur) )
return 0
}
complete -F _setsid_module setsid

48
shell-completion/swapon Normal file
View File

@ -0,0 +1,48 @@
_swapon_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-p'|'--priority')
# Priority range is -1 to 32767. Perhaps these
# few are enough.
COMPREPLY=( $(compgen -W "$(echo {-1..9} 32767)" -- $cur) )
return 0
;;
'--show')
# FIXME: how to append to a string with compgen?
local OUTPUT
OUTPUT="NAME TYPE SIZE USED PRIO"
compopt -o nospace
COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
return 0
;;
esac
case $cur in
-*)
OPTS="-a --all
-d --discard
-e --ifexists
-f --fixpgsz
-p --priority
-s --summary
--show
--noheadings
--raw
--bytes
-v --verbose
-h --help
-V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
# FIXME: compgen will split SPEC= from '=' point. The append
# comma separated value problem is very similar.
compopt -o filenames
COMPREPLY=( $(compgen -f -- $cur) )
return 0
}
complete -F _swapon_module swapon

48
shell-completion/tunelp Normal file
View File

@ -0,0 +1,48 @@
_tunelp_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-i'|'--irq'|'-c'|'--chars')
COMPREPLY=( $(compgen -W "number" -- $cur) )
return 0
;;
'-t'|'--time')
COMPREPLY=( $(compgen -W "milliseconds" -- $cur) )
return 0
;;
'-w'|'--wait')
COMPREPLY=( $(compgen -W "microseconds" -- $cur) )
return 0
;;
'-a'|'--abort'|'-o'|'--check-status'|'-C'|'--careful'|'-T'|'--trust-irq'|'-q'|'--print-irq')
COMPREPLY=( $(compgen -W "off on" -- $cur) )
return 0
;;
esac
case $cur in
-*)
OPTS="-i --irq
-t --time
-c --chars
-w --wait
-a --abort
-o --check-status
-C --careful
-s --status
-T --trust-irq
-r --reset
-q --print-irq
-h --help
-V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
compopt -o filenames
COMPREPLY=( $(compgen -f -- ${cur:-"/dev/lp"}) )
return 0
}
complete -F _tunelp_module tunelp

24
shell-completion/unshare Normal file
View File

@ -0,0 +1,24 @@
_unshare_module()
{
local cur OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
case $cur in
-*)
OPTS="-m --mount
-u --uts
-i --ipc
-n --net
-p --pid
-U --user
-h --help
-V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
compopt -o bashdefault
COMPREPLY=( $(compgen -c -- $cur) )
return 0
}
complete -F _unshare_module unshare

60
shell-completion/wdctl Normal file
View File

@ -0,0 +1,60 @@
_wdctl_module()
{
local cur prev OPTS
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
case $prev in
'-f'|'--flags')
local FLAGS
FLAGS="ALARMONLY
CARDRESET
EXTERN1
EXTERN2
FANFAULT
KEEPALIVEPING
MAGICCLOSE
OVERHEAT
POWEROVER
POWERUNDER
PRETIMEOUT
SETTIMEOUT"
COMPREPLY=( $(compgen -W "$FLAGS" -- $cur) )
return 0
;;
'-o'|'--output')
# FIXME: how to append to a string with compgen?
local OUTPUT
OUTPUT="FLAG DESCRIPTION STATUS BOOT-STATUS DEVICE"
compopt -o nospace
COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
return 0
;;
'-s'|'--settimeout')
COMPREPLY=( $(compgen -W "seconds" -- $cur) )
return 0
;;
esac
case $cur in
-*)
OPTS="-f --flags
-F --noflags
-I --noident
-n --noheadings
-O --oneline
-o --output
-r --raw
-T --notimeouts
-s --settimeout
-x --flags-only
-h --help
-V --version"
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
return 0
;;
esac
compopt -o filenames
COMPREPLY=( $(compgen -f -- ${cur:-"/dev/"}) )
return 0
}
complete -F _wdctl_module wdctl