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
|
--- @param str string
|
||||||
*/
|
*/
|
||||||
func hlprompt(L *lua.LState) int {
|
func hlprompt(L *lua.LState) int {
|
||||||
prompt = L.CheckString(1)
|
prompt := L.CheckString(1)
|
||||||
if lr != nil {
|
lr.SetPrompt(fmtPrompt(prompt))
|
||||||
lr.SetPrompt(fmtPrompt())
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
5
main.go
5
main.go
|
@ -114,6 +114,7 @@ func main() {
|
||||||
|
|
||||||
go handleSignals()
|
go handleSignals()
|
||||||
luaInit()
|
luaInit()
|
||||||
|
lr = newLineReader("")
|
||||||
// If user's config doesn't exixt,
|
// If user's config doesn't exixt,
|
||||||
if _, err := os.Stat(defaultConfPath); os.IsNotExist(err) && *configflag == defaultConfPath {
|
if _, err := os.Stat(defaultConfPath); os.IsNotExist(err) && *configflag == defaultConfPath {
|
||||||
// Read default from current directory
|
// Read default from current directory
|
||||||
|
@ -162,12 +163,10 @@ func main() {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
lr = newLineReader("")
|
|
||||||
input:
|
input:
|
||||||
for interactive {
|
for interactive {
|
||||||
running = false
|
running = false
|
||||||
|
|
||||||
lr.SetPrompt(fmtPrompt())
|
|
||||||
input, err := lr.Read()
|
input, err := lr.Read()
|
||||||
|
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
|
@ -225,7 +224,7 @@ func continuePrompt(prev string) (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This semi cursed function formats our prompt (obviously)
|
// This semi cursed function formats our prompt (obviously)
|
||||||
func fmtPrompt() string {
|
func fmtPrompt(prompt string) string {
|
||||||
host, _ := os.Hostname()
|
host, _ := os.Hostname()
|
||||||
cwd, _ := os.Getwd()
|
cwd, _ := os.Getwd()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue