]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
bash-completion: schedutils
authorSami Kerola <kerolasa@iki.fi>
Sun, 24 Mar 2013 17:10:55 +0000 (17:10 +0000)
committerSami Kerola <kerolasa@iki.fi>
Mon, 1 Apr 2013 16:41:55 +0000 (17:41 +0100)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
shell-completion/chrt [new file with mode: 0644]
shell-completion/ionice [new file with mode: 0644]
shell-completion/taskset [new file with mode: 0644]

diff --git a/shell-completion/chrt b/shell-completion/chrt
new file mode 100644 (file)
index 0000000..b85775a
--- /dev/null
@@ -0,0 +1,32 @@
+_chrt_module()
+{
+       local cur OPTS
+       COMPREPLY=()
+       cur="${COMP_WORDS[COMP_CWORD]}"
+       # FIXME: -p is ambiguous, it takes either pid or priority as an
+       # argument depending on whether user wanted to get or set the
+       # values.  Perhaps the command interface should be reconsidered.
+       case $cur in
+               -*)
+                       OPTS="-b --batch
+                               -f --fifo
+                               -i --idle
+                               -o --other
+                               -r --rr
+                               -R --reset-on-fork
+                               -a --all-tasks
+                               -h --help
+                               -m --max
+                               -p --pid
+                               -v --verbose
+                               -V --version"
+                       COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+                       return 0
+                       ;;
+       esac
+       local PIDS
+       PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done)
+       COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
+       return 0
+}
+complete -F _chrt_module chrt
diff --git a/shell-completion/ionice b/shell-completion/ionice
new file mode 100644 (file)
index 0000000..2180718
--- /dev/null
@@ -0,0 +1,34 @@
+_ionice_module()
+{
+       local cur prev OPTS
+       COMPREPLY=()
+       cur="${COMP_WORDS[COMP_CWORD]}"
+       prev="${COMP_WORDS[COMP_CWORD-1]}"
+       case $prev in
+               '-c'|'--class')
+                       COMPREPLY=( $(compgen -W "$(echo {0..3}) none realtime best-effort idle" -- $cur) )
+                       return 0
+                       ;;
+               '-n'|'--classdata')
+                       COMPREPLY=( $(compgen -W "$(echo {0..7})" -- $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
+                       ;;
+       esac
+       case $cur in
+               -*)
+                       OPTS="-c --class -n --classdata -p --pid -t --ignore -V --version -h --help"
+                       COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+                       return 0
+                       ;;
+       esac
+       compopt -o filenames
+       COMPREPLY=( $(compgen -f -- $cur) )
+       return 0
+}
+complete -F _ionice_module ionice
diff --git a/shell-completion/taskset b/shell-completion/taskset
new file mode 100644 (file)
index 0000000..5311316
--- /dev/null
@@ -0,0 +1,38 @@
+_taskset_module()
+{
+       local cur prev OPTS
+       COMPREPLY=()
+       cur="${COMP_WORDS[COMP_CWORD]}"
+       prev="${COMP_WORDS[COMP_CWORD-1]}"
+       case $prev in
+               '-c'|'--cpu-list')
+                       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
+                       ;;
+               '-p'|'--pid')
+                       local PIDS
+                       # FIXME: the pid argument is ambiguous.  When
+                       # setting an affinity the optarg has to be cpu
+                       # mask.  The following is good only for getting
+                       # affinity.
+                       PIDS=$(for I in /proc/[0-9]*; do echo ${I##"/proc/"}; done)
+                       COMPREPLY=( $(compgen -W "$PIDS" -- $cur) )
+                       return 0
+                       ;;
+       esac
+       case $cur in
+               -*)
+                       OPTS="-a --all-tasks -p --pid -c --cpu-list -h --help -V --version"
+                       COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+                       return 0
+                       ;;
+       esac
+       compopt -o bashdefault
+       COMPREPLY=( $(compgen -c -- $cur) )
+       return 0
+}
+complete -F _taskset_module taskset