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

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

complete -C "$1" -O c -O --clear \
	-D "clear the entire history"
complete -C "$1" -O d -O --delete -F comp/history \
	-D "clear the specified history item"
complete -C "$1" -O F -O --flush-file \
	-D "refresh the history file"
complete -C "$1" -O r -O --read -f \
	-D "read history from the specified file"
complete -C "$1" -O s -O --set -F comp/history \
	-D "replace the last history item with the specified command"
complete -C "$1" -O w -O --write -f \
	-D "write history to the specified file"
complete -C "$1" -O --help

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