Add basic tab completion to terminal
This commit is contained in:
parent
e2acf8ce4a
commit
e273949f37
@ -51,6 +51,17 @@ func (t *Term) Run() (error, int) {
|
|||||||
if t.conf != nil && t.conf.Aliases != nil {
|
if t.conf != nil && t.conf.Aliases != nil {
|
||||||
cmds.Merge(t.conf.Aliases)
|
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)
|
fullHistoryFile, err := config.GetConfigFilePath(historyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Unable to load history file: %v.", err)
|
fmt.Printf("Unable to load history file: %v.", err)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user