mirror of https://github.com/Hilbis/Hilbish
Compare commits
3 Commits
3babf36c43
...
4a4cb3409f
Author | SHA1 | Date |
---|---|---|
TorchedSammy | 4a4cb3409f | |
TorchedSammy | 853dfa369f | |
TorchedSammy | 738939e4c9 |
|
@ -69,6 +69,8 @@ func binaryComplete(query, ctx string, fields []string) ([]string, string) {
|
|||
}
|
||||
}
|
||||
|
||||
completions = removeDupes(completions)
|
||||
|
||||
return completions, query
|
||||
}
|
||||
|
||||
|
|
4
exec.go
4
exec.go
|
@ -9,7 +9,7 @@ import (
|
|||
"time"
|
||||
|
||||
"hilbish/util"
|
||||
|
||||
|
||||
"github.com/yuin/gopher-lua"
|
||||
"mvdan.cc/sh/v3/shell"
|
||||
//"github.com/yuin/gopher-lua/parse"
|
||||
|
@ -245,7 +245,7 @@ func splitInput(input string) ([]string, string) {
|
|||
func cmdFinish(code uint8, cmdstr, oldInput string) {
|
||||
// if input has space at the beginning, dont put in history
|
||||
if !strings.HasPrefix(oldInput, " ") || interactive {
|
||||
handleHistory(cmdstr)
|
||||
handleHistory(strings.TrimSpace(oldInput))
|
||||
}
|
||||
util.SetField(l, hshMod, "exitCode", lua.LNumber(code), "Exit code of last exected command")
|
||||
hooks.Em.Emit("command.exit", code, cmdstr)
|
||||
|
|
14
main.go
14
main.go
|
@ -187,6 +187,7 @@ input:
|
|||
|
||||
input = strings.TrimSpace(input)
|
||||
if len(input) == 0 {
|
||||
running = true
|
||||
hooks.Em.Emit("command.exit", 0)
|
||||
continue
|
||||
}
|
||||
|
@ -268,3 +269,16 @@ func expandHome(path string) string {
|
|||
|
||||
return strings.Replace(defaultHistDir, "~", homedir, 1)
|
||||
}
|
||||
|
||||
func removeDupes(slice []string) []string {
|
||||
all := make(map[string]bool)
|
||||
newSlice := []string{}
|
||||
for _, item := range slice {
|
||||
if _, val := all[item]; !val {
|
||||
all[item] = true
|
||||
newSlice = append(newSlice, item)
|
||||
}
|
||||
}
|
||||
|
||||
return newSlice
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue