chiark / gitweb /
cryptsetup-generator: Add support for naming luks devices on kernel cmdline
[elogind.git] / shell-completion / zsh / _coredumpctl
1 #compdef coredumpctl
2
3 _coredumpctl_command(){
4     local -a _coredumpctl_cmds
5     _coredumpctl_cmds=(
6             'list:List available coredumps'
7             'dump:Print coredump to stdout'
8             'gdb:Start gdb on a coredump'
9     )
10     if (( CURRENT == 1 )); then
11         _describe -t commands 'coredumpctl command' _coredumpctl_cmds
12     else
13         local curcontext="$curcontext"
14         local -a _dumps
15         cmd="${${_coredumpctl_cmds[(r)$words[1]:*]%%:*}}"
16         if (( $#cmd  )); then
17             # user can set zstyle ':completion:*:*:coredumpctl:*' sort no for coredumps to be ordered by date, otherwise they get ordered by pid
18             _dumps=( "${(foa)$(coredumpctl list | awk 'BEGIN{OFS=":"} /^\s/ {sub(/[[ \t]+/, ""); print $5,$0}' 2>/dev/null)}" )
19             if [[ -n "$_dumps" ]]; then
20                 _describe -t pids 'coredumps' _dumps
21             else
22                 _message "no coredumps"
23             fi
24         else
25             _message "no more options"
26         fi
27     fi
28 }
29
30 _arguments \
31     {-o+,--output=}'[Write output to FILE]:output file:_files' \
32     {-F+,--field=}'[Show field in list output]:field' \
33     '--no-pager[Do not pipe output into a pager]' \
34     {-h,--help}'[Show this help]' \
35     '--version[Show package version]' \
36     '*::coredumpctl commands:_coredumpctl_command'