diff --git a/lua.go b/lua.go index 4e9ae57..9b225b8 100644 --- a/lua.go +++ b/lua.go @@ -25,6 +25,7 @@ func LuaInit() { l.SetGlobal("_ver", lua.LString(version)) l.SetGlobal("prompt", l.NewFunction(hshprompt)) + l.SetGlobal("multiprompt", l.NewFunction(hshmlprompt)) l.SetGlobal("alias", l.NewFunction(hshalias)) // Add fs module to Lua @@ -76,6 +77,12 @@ func hshprompt(L *lua.LState) int { return 0 } +func hshmlprompt(L *lua.LState) int { + multilinePrompt = L.ToString(1) + + return 0 +} + func hshalias(L *lua.LState) int { alias := L.ToString(1) source := L.ToString(2) diff --git a/main.go b/main.go index 1f78414..ee570ad 100644 --- a/main.go +++ b/main.go @@ -21,6 +21,8 @@ const version = "0.3.0-dev" var l *lua.LState // User's prompt, this will get set when lua side is initialized var prompt string +var multilinePrompt = "> " + // Map of builtin/custom commands defined in the commander lua module var commands = map[string]bool{} // Command aliases @@ -113,7 +115,7 @@ func main() { } func ContinuePrompt(prev string) (string, error) { - fmt.Printf("> ") + fmt.Print(multilinePrompt) reader := bufio.NewReader(os.Stdin) diff --git a/shell.go b/shell.go index f1e4ad5..44e2bce 100644 --- a/shell.go +++ b/shell.go @@ -162,7 +162,7 @@ func StartMultiline(prev string, sb *strings.Builder) bool { // save input from previous prompts if sb.String() == "" { sb.WriteString(prev + "\n") } - fmt.Printf("sh> ") + fmt.Print(multilinePrompt) reader := bufio.NewReader(os.Stdin)