goterm icon indicating copy to clipboard operation
goterm copied to clipboard

Width incorrectly reported inside tmux

Open vbauerster opened this issue 8 years ago • 3 comments

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)
	}
}

Width reported correctly without tmux: normalf.gif

Width reported incorrectly inside tmux: tmux.gif

vbauerster avatar Jan 25 '17 09:01 vbauerster

Any idea how to fix under tmux?

vbauerster avatar Jan 25 '17 09:01 vbauerster

I added a w32 call that works to retrieve Windows console dimensions - won't help on tmux though...

harmon25 avatar Apr 04 '17 15:04 harmon25

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.

c032 avatar Dec 04 '17 20:12 c032