Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: stty #2184

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: stty
CristhianF7 committed May 30, 2024

Verified

This commit was signed with the committer’s verified signature.
CristhianF7 Cristhian Fernández
commit 0e2a2fb2a41ffa6afdb5305be4b19543328dd074
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -10,6 +10,8 @@ import (
"fmt"
stdLog "log"
"os"
"os/signal"
"syscall"
"time"

"golang.org/x/exp/slices"
@@ -131,11 +133,21 @@ func main() {
if canRunBubbleTea {
progress.InitializeProgressTerminal()

// Handle interrupts to restore terminal settings
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
<-c
progress.Progress.Quit()
os.Exit(0)
}()

go func() {
cmd.Execute()
}()

progress.Progress.Run()

} else {
cmd.Execute()
}
16 changes: 16 additions & 0 deletions tools/stty.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Save terminal settings before running the program
stty -g > before.txt

# Run your program
go run . k3d create

# Save terminal settings after running the program
stty -g > after.txt

# Compare the settings
diff before.txt after.txt

# Clean up
rm before.txt after.txt