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

tmux mode fix for MacOS #14

Merged
merged 1 commit into from
Nov 29, 2021
Merged
Changes from all commits
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
14 changes: 10 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@ import (
)

func main() {
is_tmux := false
widget.Init()
defer widget.Fini()

if runtime.GOOS == "darwin" {
is_tmux = strings.Contains(os.Getenv("TERM_PROGRAM"), "tmux")
} else {
is_tmux = strings.Contains(os.Getenv("TERM"), "screen")
}
// Change a terminal title.
if strings.Contains(os.Getenv("TERM"), "screen") {
if is_tmux {
os.Stdout.WriteString("\033kgoful\033") // for tmux
} else {
os.Stdout.WriteString("\033]0;goful\007") // for otherwise
Expand All @@ -30,7 +36,7 @@ func main() {
const history = "~/.goful/history/shell"

goful := app.NewGoful(state)
config(goful)
config(goful, is_tmux)
_ = cmdline.LoadHistory(history)

goful.Run()
Expand All @@ -39,7 +45,7 @@ func main() {
_ = cmdline.SaveHistory(history)
}

func config(g *app.Goful) {
func config(g *app.Goful, is_tmux bool) {
look.Set("default") // default, midnight, black, white

if runewidth.EastAsianWidth {
Expand Down Expand Up @@ -114,7 +120,7 @@ func config(g *app.Goful) {
// for not close the terminal when the shell finishes running
const tail = `;read -p "HIT ENTER KEY"`

if strings.Contains(os.Getenv("TERM"), "screen") { // such as screen and tmux
if is_tmux { // such as screen and tmux
return []string{"tmux", "new-window", "-n", cmd, cmd + tail}
}
// To execute bash in gnome-terminal of a new window or tab.
Expand Down