aaronjanse / 3mux

Terminal multiplexer inspired by i3
MIT License
1.82k stars 45 forks source link

3mux can leave SGR enabled after displaying the interactive session prompt #72

Closed scrosland closed 4 years ago

scrosland commented 4 years ago

If you start 3mux with no arguments when a session is already running and then CTRL-C exit after the menu of available sessions is displayed an SGR attribute will be left enabled changing the font colour.

Here's a slightly rough screencast:

3mux-crop

I think it's SGR 2 that is being left enabled and that the problem is here in main.go:

        fmt.Print("\x1b[1;36m> " + options[0] + "\x1b[39;2m\r\n")

        for _, option := range options[1:] {
            fmt.Print("  " + option + "\x1b[39m\r\n")
        }

        fmt.Print("+ create new session\r")
        fmt.Printf("\x1b[%dA", len(options))

        clearOptions := func() {

The solution may be to add a fmt.Printf("\x1b[m") before the definition of clearOptions.

Note that if you enter a new session name the problem is not exhibited which looks to be because promptNewSessionName() resets SGR attributes in the second line here:

        fmt.Print("\x1b[22mName of new session:\r\n")
        fmt.Print("\x1b[22;36m? \x1b[m")
aaronjanse commented 4 years ago

Thank you! I've noticed this issue, but I didn't know where it was coming from. Would you mind making a pull request?

scrosland commented 4 years ago

Will do. It might take me a little while, I hope that's OK.

aaronjanse commented 4 years ago

No problem at all