2014-06-19 15:46:01 +04:00
#compdef coredumpctl
2013-07-29 23:09:10 +04:00
2014-06-19 15:46:01 +04:00
_coredumpctl_command(){
local -a _coredumpctl_cmds
_coredumpctl_cmds=(
2013-07-29 23:09:10 +04:00
'list:List available coredumps'
2015-01-12 23:26:27 +03:00
'info:Show detailed information about one or more coredumps'
2013-08-02 15:58:56 +04:00
'dump:Print coredump to stdout'
'gdb:Start gdb on a coredump'
2013-07-29 23:09:10 +04:00
)
if (( CURRENT == 1 )); then
2014-06-19 15:46:01 +04:00
_describe -t commands 'coredumpctl command' _coredumpctl_cmds
2013-07-29 23:09:10 +04:00
else
local curcontext="$curcontext"
local -a _dumps
2014-06-19 15:46:01 +04:00
cmd="${${_coredumpctl_cmds[(r)$words[1]:*]%%:*}}"
2013-07-29 23:09:10 +04:00
if (( $#cmd )); then
2014-06-19 15:46:01 +04:00
# user can set zstyle ':completion:*:*:coredumpctl:*' sort no for coredumps to be ordered by date, otherwise they get ordered by pid
2016-04-19 07:23:01 +03:00
_dumps=( "${(foa)$(coredumpctl list --no-legend | awk 'BEGIN{OFS=":"} {sub(/[[ \t]+/, ""); print $5,$0}' 2>/dev/null)}" )
2013-07-29 23:09:10 +04:00
if [[ -n "$_dumps" ]]; then
_describe -t pids 'coredumps' _dumps
else
_message "no coredumps"
fi
else
_message "no more options"
fi
fi
}
_arguments \
2013-08-21 07:06:54 +04:00
{-o+,--output=}'[Write output to FILE]:output file:_files' \
{-F+,--field=}'[Show field in list output]:field' \
2015-01-12 23:26:27 +03:00
'-1[Show information about most recent entry only]' \
2017-02-14 17:08:46 +03:00
{-r,--reverse}'[Show the newest entries first]' \
2013-07-29 23:09:10 +04:00
'--no-pager[Do not pipe output into a pager]' \
2015-01-12 23:26:27 +03:00
'--no-legend[Do not print the column headers]' \
2013-07-29 23:09:10 +04:00
{-h,--help}'[Show this help]' \
'--version[Show package version]' \
2014-06-19 15:46:01 +04:00
'*::coredumpctl commands:_coredumpctl_command'