]> git.ipfire.org Git - thirdparty/systemd.git/blame - shell-completion/zsh/_coredumpctl
TODO: update
[thirdparty/systemd.git] / shell-completion / zsh / _coredumpctl
CommitLineData
f4bab169 1#compdef coredumpctl
70e104c4 2
f4bab169
LP
3_coredumpctl_command(){
4 local -a _coredumpctl_cmds
5 _coredumpctl_cmds=(
70e104c4 6 'list:List available coredumps'
a217fdc9
ZJS
7 'dump:Print coredump to stdout'
8 'gdb:Start gdb on a coredump'
70e104c4
WG
9 )
10 if (( CURRENT == 1 )); then
f4bab169 11 _describe -t commands 'coredumpctl command' _coredumpctl_cmds
70e104c4
WG
12 else
13 local curcontext="$curcontext"
14 local -a _dumps
f4bab169 15 cmd="${${_coredumpctl_cmds[(r)$words[1]:*]%%:*}}"
70e104c4 16 if (( $#cmd )); then
f4bab169
LP
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)}" )
70e104c4
WG
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 \
862f4963
WG
31 {-o+,--output=}'[Write output to FILE]:output file:_files' \
32 {-F+,--field=}'[Show field in list output]:field' \
70e104c4
WG
33 '--no-pager[Do not pipe output into a pager]' \
34 {-h,--help}'[Show this help]' \
35 '--version[Show package version]' \
f4bab169 36 '*::coredumpctl commands:_coredumpctl_command'