Skip to content

Commit

Permalink
Fix issue with interactive mode on bash
Browse files Browse the repository at this point in the history
  • Loading branch information
aandrew-me committed Jan 14, 2024
1 parent e7ad4bc commit 99cef50
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"flag"
"fmt"
"os"
"os/exec"
"os/signal"
"runtime"
"strings"
Expand All @@ -17,7 +18,7 @@ import (
"github.com/olekukonko/ts"
)

const localVersion = "2.4.3"
const localVersion = "2.4.4"

var bold = color.New(color.Bold)
var boldBlue = color.New(color.Bold, color.FgBlue)
Expand Down Expand Up @@ -170,7 +171,6 @@ func main() {

for {
blue.Println("╭─ You")

input := Prompt.Input("╰─> ", historyCompleter,
Prompt.OptionHistory(history),
Prompt.OptionPrefixTextColor(Prompt.Blue),
Expand All @@ -185,6 +185,12 @@ func main() {
if len(input) > 1 {
if input == "exit" {
bold.Println("Exiting...")
if runtime.GOOS != "windows" {
rawModeOff := exec.Command("stty", "-raw", "echo")
rawModeOff.Stdin = os.Stdin
_ = rawModeOff.Run()
rawModeOff.Wait()
}
os.Exit(0)
}
previousMessages += getData(input, true, previousMessages)
Expand Down Expand Up @@ -387,5 +393,13 @@ func historyCompleter(d Prompt.Document) []Prompt.Suggest {

func exit(_ *Prompt.Buffer) {
bold.Println("Exiting...")

if runtime.GOOS != "windows" {
rawModeOff := exec.Command("stty", "-raw", "echo")
rawModeOff.Stdin = os.Stdin
_ = rawModeOff.Run()
rawModeOff.Wait()
}

os.Exit(0)
}

0 comments on commit 99cef50

Please sign in to comment.