From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: kerolasa@iki.fi
Subject: [PATCH 06/10] bash-completion: schedutils
Date: Wed, 27 Mar 2013 22:07:48 +0000 [thread overview]
Message-ID: <1364422072-23552-7-git-send-email-kerolasa@iki.fi> (raw)
In-Reply-To: <1364422072-23552-1-git-send-email-kerolasa@iki.fi>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
shell-completion/chrt | 32 ++++++++++++++++++++++++++++++++
shell-completion/ionice | 34 ++++++++++++++++++++++++++++++++++
shell-completion/taskset | 38 ++++++++++++++++++++++++++++++++++++++
3 files changed, 104 insertions(+)
create mode 100644 shell-completion/chrt
create mode 100644 shell-completion/ionice
create mode 100644 shell-completion/taskset
diff --git a/shell-completion/chrt b/shell-completion/chrt
new file mode 100644
index 0000000..08912c9
--- /dev/null
+++ b/shell-completion/chrt
@@ -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=$(\ls -d /proc/[0-9]* | sed 's|/proc/||')
+ 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
index 0000000..3087c4a
--- /dev/null
+++ b/shell-completion/ionice
@@ -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=$(\ls -d /proc/[0-9]* | sed 's|/proc/||')
+ 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
index 0000000..81247cd
--- /dev/null
+++ b/shell-completion/taskset
@@ -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=$(\ls -d /proc/[0-9]* | sed 's|/proc/||')
+ 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
--
1.8.2
next prev parent reply other threads:[~2013-03-27 22:08 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-27 22:07 [PATCH 00/10] [pull] bash-completion Sami Kerola
2013-03-27 22:07 ` [PATCH 01/10] bash-completion: add bash completetion configure option Sami Kerola
2013-03-28 11:22 ` Sami Kerola
2013-03-29 9:42 ` Karel Zak
2013-03-27 22:07 ` [PATCH 02/10] bash-completion: disk-utils Sami Kerola
2013-03-28 1:42 ` Dave Reisner
2013-04-01 15:54 ` Sami Kerola
2013-03-28 9:54 ` Karel Zak
2013-04-01 17:00 ` Sami Kerola
2013-03-27 22:07 ` [PATCH 03/10] bash-completion: fdisks Sami Kerola
2013-03-28 10:01 ` Karel Zak
2013-03-27 22:07 ` [PATCH 04/10] bash-completion: login-utils Sami Kerola
2013-03-28 1:42 ` Dave Reisner
2013-04-01 16:05 ` Sami Kerola
2013-03-28 10:05 ` Karel Zak
2013-04-01 16:06 ` Sami Kerola
2013-03-27 22:07 ` [PATCH 05/10] bash-completion: misc-utils Sami Kerola
2013-03-28 1:42 ` Dave Reisner
2013-04-01 16:52 ` Sami Kerola
2013-03-27 22:07 ` Sami Kerola [this message]
2013-03-27 22:07 ` [PATCH 07/10] bash-completion: sys-utils Sami Kerola
2013-03-29 16:33 ` Karel Zak
2013-04-01 16:32 ` Sami Kerola
2013-04-05 14:44 ` Karel Zak
2013-03-27 22:07 ` [PATCH 08/10] bash-completion: term-utils Sami Kerola
2013-03-28 10:06 ` Karel Zak
2013-03-27 22:07 ` [PATCH 09/10] bash-completion: text-utils Sami Kerola
2013-03-27 22:07 ` [PATCH 10/10] bash-completion: add completion files to Makefile.am Sami Kerola
2013-03-28 1:42 ` [PATCH 00/10] [pull] bash-completion Dave Reisner
2013-03-28 9:37 ` Karel Zak
2013-03-31 23:49 ` Sami Kerola
2013-04-01 15:44 ` Sami Kerola
2013-04-05 14:11 ` Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1364422072-23552-7-git-send-email-kerolasa@iki.fi \
--to=kerolasa@iki.fi \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox