mirror of https://github.com/Hilbis/Hilbish
fix: handle prompt properly and remove global
parent
237bc19f68
commit
6b9bbb615d
6
api.go
6
api.go
|
@ -174,10 +174,8 @@ These will be formatted and replaced with the appropriate values.
|
|||
--- @param str string
|
||||
*/
|
||||
func hlprompt(L *lua.LState) int {
|
||||
prompt = L.CheckString(1)
|
||||
if lr != nil {
|
||||
lr.SetPrompt(fmtPrompt())
|
||||
}
|
||||
prompt := L.CheckString(1)
|
||||
lr.SetPrompt(fmtPrompt(prompt))
|
||||
|
||||
return 0
|
||||
}
|
||||
|
|
5
main.go
5
main.go
|
@ -114,6 +114,7 @@ func main() {
|
|||
|
||||
go handleSignals()
|
||||
luaInit()
|
||||
lr = newLineReader("")
|
||||
// If user's config doesn't exixt,
|
||||
if _, err := os.Stat(defaultConfPath); os.IsNotExist(err) && *configflag == defaultConfPath {
|
||||
// Read default from current directory
|
||||
|
@ -162,12 +163,10 @@ func main() {
|
|||
os.Exit(0)
|
||||
}
|
||||
|
||||
lr = newLineReader("")
|
||||
input:
|
||||
for interactive {
|
||||
running = false
|
||||
|
||||
lr.SetPrompt(fmtPrompt())
|
||||
input, err := lr.Read()
|
||||
|
||||
if err == io.EOF {
|
||||
|
@ -225,7 +224,7 @@ func continuePrompt(prev string) (string, error) {
|
|||
}
|
||||
|
||||
// This semi cursed function formats our prompt (obviously)
|
||||
func fmtPrompt() string {
|
||||
func fmtPrompt(prompt string) string {
|
||||
host, _ := os.Hostname()
|
||||
cwd, _ := os.Getwd()
|
||||
|
||||
|
|
Loading…
Reference in New Issue