# completion settings for the fc built-in
# written by magicant
# vim: set ft=sh ts=8 sts=8 sw=8 noet:

complete -C "$1" -X -F comp/fc

complete -C "$1" -O e -O --editor -c \
	-D "specify an editor to edit the command"
complete -C "$1" -O l -O --list \
	-D "just print command history"
complete -C "$1" -O n -O --no-numbers \
	-D "don't print history numbers in listing"
complete -C "$1" -O q -O --quiet \
	-D "don't print the command before re-executing"
complete -C "$1" -O r -O --reverse \
	-D "reverse the order of commands"
complete -C "$1" -O s -O --silent \
	-D "re-execute the command without editing"
complete -C "$1" -O v -O --verbose \
	-D "print history in detail (with -l)"
complete -C "$1" -O --help

function comp/fc {
	typeset num cmd
	while read num cmd; do
		complete -D "$num" -- "$cmd"
	done <(fc -l 1)
}
