zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] Completion for chrt and ionice
@ 2008-09-21 13:59 Jörg Sommer
  2008-09-22 16:53 ` Jörg Sommer
  0 siblings, 1 reply; 7+ messages in thread
From: Jörg Sommer @ 2008-09-21 13:59 UTC (permalink / raw)
  To: zsh-workers

Hi,

commit 14b01890163625d1aa41610beb46e00155090308
Author: Jörg Sommer <joerg@alea.gnuu.de>
Date:   Sun Sep 21 15:51:36 2008 +0200

    Completion for the Linux command ionice
    
    The command ionice is used on Linux to get or set the IO scheduling
    attributes of a process.

diff --git a/Completion/Linux/Command/_ionice b/Completion/Linux/Command/_ionice
new file mode 100644
index 0000000..e3b64aa
--- /dev/null
+++ b/Completion/Linux/Command/_ionice
@@ -0,0 +1,23 @@
+#compdef ionice
+
+local context state line
+typeset -A opt_args
+
+_arguments \
+  '(* -)-h[display usage information]' \
+  '-p[interpret args as process ID]' \
+  '-c[scheduling class]:class:(( 1\:realtime 2\:best-effort 3\:idle ))' \
+  '-n[scheduling class priority]:class-pririty:((
+    0\:high\ priority
+    {1..6}\:
+    7\:low\ priority
+  ))' \
+  '*::command or pid:->cmd_or_pid' \
+  && return 0
+
+if (( $+opt_args[-p] ))
+then
+    _pids
+else
+    _normal
+fi

commit fc7231b2bd501b2a3dc753567c2ae8c4deddf9e7
Author: Jörg Sommer <joerg@alea.gnuu.de>
Date:   Sun Sep 21 15:50:10 2008 +0200

    Completion for the Linux command chrt
    
    The command chrt is used on Linux to get or set the real‐time attributes
    of a process.

diff --git a/Completion/Linux/Command/_chrt b/Completion/Linux/Command/_chrt
new file mode 100644
index 0000000..f82ec8b
--- /dev/null
+++ b/Completion/Linux/Command/_chrt
@@ -0,0 +1,61 @@
+#compdef chrt
+
+local context state line
+typeset -A opt_args
+
+_arguments \
+  '(* -)'{-h,--help}'[display usage information]' \
+  '(* -)'{-V,--version}'[output version information]' \
+  {-v,--verbose}'[display status information]' \
+  {-p,--pid}'[interpret args as process ID]' \
+  '(-b --batch -f --fifo -o --other -r --rr)'{-b,--batch}'[set scheduling policy to SCHED_BATCH]' \
+  '(-b --batch -f --fifo -o --other -r --rr)'{-f,--fifo}'[set scheduling policy to SCHED_FIFO]' \
+  '(-b --batch -f --fifo -o --other -r --rr)'{-o,--other}'[set policy scheduling policy to SCHED_OTHER]' \
+  '(-b --batch -f --fifo -o --other -r --rr)'{-r,--rr}'[set scheduling policy to SCHED_RR]' \
+  '(* -)'{-m,--max}'[show minimum and maximum valid priorities, then exit]' \
+  '*::command or priority:->cmd_or_prio' \
+  && return 0
+
+_chrt_priority()
+{
+    local ty
+    if (( $+opt_args[-b] || $+opt_args[--batch] ))
+    then
+        ty=BATCH
+    elif (( $+opt_args[-f] || $+opt_args[--fifo] ))
+    then
+        ty=FIFO
+    elif (( $+opt_args[-o] || $+opt_args[--other] ))
+    then
+        ty=OTHER
+    else
+        ty=RR
+    fi
+    local range
+    range=${${"$(_call_program priorities chrt --max)"#*SCHED_$ty*: }%$'\n'*}
+    if [[ $range = 0/0 ]]
+    then
+        compadd 0
+    else
+        _message -e priority "priority in the range $range"
+    fi
+}
+
+if (( $+opt_args[-p] || $+opt_args[--pid] ))
+then
+    if [[ $CURRENT -eq 1 ]]
+    then
+        _alternative \
+          'priority:priority:_chrt_priority' \
+          'processes:process IDs:_pids'
+    else
+        _pids
+    fi
+elif [[ $CURRENT -eq 1 ]]
+then
+    _chrt_priority
+else
+    shift words
+    (( CURRENT-- ))
+    _normal
+fi

Bye, Jörg.
-- 
Macht besitzen und nicht ausüben ist wahre Größe.
                                                   (Friedl Beutelrock)


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-10-04 18:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-21 13:59 [PATCH] Completion for chrt and ionice Jörg Sommer
2008-09-22 16:53 ` Jörg Sommer
2008-09-23  5:28   ` Clint Adams
2008-10-03  1:11   ` Jörg Sommer
2008-10-03  2:32     ` Clint Adams
2008-10-03 16:07       ` Jörg Sommer
2008-10-04 18:15         ` Clint Adams

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).