goterm
goterm copied to clipboard
Width incorrectly reported inside tmux
Given the code:
package main
import (
"fmt"
"time"
"github.com/buger/goterm"
)
func main() {
for {
w := goterm.Width()
fmt.Printf("\rwidth: %d", w)
time.Sleep(100 * time.Millisecond)
}
}
Any idea how to fix under tmux?
I added a w32 call that works to retrieve Windows console dimensions - won't help on tmux though...
A veeery crude fix is checking whether the TMUX
environment variable is set, and then parse the output of the command tmux display -p '#{pane_width} #{pane_height}'
. I bet it can also be done by communicating with its socket, but couldn't find any documentation on that.
I'd like to know how WeeChat handles this.