1# (C) 2010 magicant
2
3# Completion script for the "history" built-in command.
4
5function completion/history {
6
7	typeset OPTIONS ARGOPT PREFIX
8	OPTIONS=( #>#
9	"c --clear; clear the history completely"
10	"d: --delete:; clear the specified history item"
11	"F --flush-file; refresh the history file"
12	"r: --read:; read history from the specified file"
13	"s: --set:; replace the last history item with the specified command"
14	"w: --write:; write history to the specified file"
15	"--help"
16	) #<#
17
18	command -f completion//parseoptions -es
19	case $ARGOPT in
20	(-)
21		command -f completion//completeoptions
22		;;
23	(d|--delete|s|--set)
24		typeset num cmd
25		while read -r num cmd; do
26			complete -P "$PREFIX" -D "$num" -- "$cmd"
27		done <(fc -l 1)
28		;;
29	(r|--read|w|--write)
30		complete -P "$PREFIX" -f
31		;;
32	(*)
33		;;
34	esac
35
36}
37
38
39# vim: set ft=sh ts=8 sts=8 sw=8 noet:
40