example: change (Ctrl+C), (Ctrl+D) to shell-like

This commit is contained in:
Cheney 2015-11-20 11:26:58 +08:00
parent db2e5eae91
commit 5660cc8cb6
1 changed files with 6 additions and 4 deletions

View File

@ -46,9 +46,11 @@ var completer = readline.NewPrefixCompleter(
func main() {
l, err := readline.NewEx(&readline.Config{
Prompt: "\033[31m»\033[0m ",
HistoryFile: "/tmp/readline.tmp",
AutoComplete: completer,
Prompt: "\033[31m»\033[0m ",
HistoryFile: "/tmp/readline.tmp",
AutoComplete: completer,
InterruptPrompt: "\nInterrupt",
EOFPrompt: "exit",
})
if err != nil {
panic(err)
@ -58,7 +60,7 @@ func main() {
log.SetOutput(l.Stderr())
for {
line, err := l.Readline()
if err != nil {
if err == io.EOF {
break
}
line = strings.TrimSpace(line)