From e273949f374048e77dea1e65ed5b23f1c6b7822d Mon Sep 17 00:00:00 2001 From: Ilia Choly Date: Thu, 10 Sep 2015 10:09:32 -0400 Subject: [PATCH] Add basic tab completion to terminal --- terminal/terminal.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/terminal/terminal.go b/terminal/terminal.go index 1434613d..71f6db44 100644 --- a/terminal/terminal.go +++ b/terminal/terminal.go @@ -51,6 +51,17 @@ func (t *Term) Run() (error, int) { if t.conf != nil && t.conf.Aliases != nil { cmds.Merge(t.conf.Aliases) } + t.line.SetCompleter(func(line string) (c []string) { + for _, cmd := range cmds.cmds { + for _, alias := range cmd.aliases { + if strings.HasPrefix(alias, strings.ToLower(line)) { + c = append(c, alias) + } + } + } + return + }) + fullHistoryFile, err := config.GetConfigFilePath(historyFile) if err != nil { fmt.Printf("Unable to load history file: %v.", err) -- GitLab