0

I am making an script in zsh on mac that uses tmux and after the amazing https://unix.stackexchange.com/users/22565/st%c3%a9phane-chazelas answer, I found out that when I use tmux, it uses a different interpreter that that of my host machine.

Therefore, as I am outputing the same literals to both tty and tmux pane from my script tput commands, I wanted to know whether there was some incompatibility on the ANSI escape sequences I am producing.

I found that $TERM is xterm-256color in my mac and screen-256color within a tmux pane, therefore I issued

%> infocmp xterm-256color screen-256color

I am using code that uses tput clear, civis, sgr0, cnorm, rc, sc, home, cd, cr, el, cub1, cud, cuf. The code is working, the ouput is produced in the xterm context with tput and is well rendered on both tty and tmux when tee'ed.

But according to infocmp, clear for instance has difference escape sequences on both terms:

comparing xterm-256color to screen-256color.
        clear: '\E[H\E[2J', '\E[H\E[J'

so how can it work?

As a side-question, msot of my commands don't show up in the comparison, does thi mean they are not theoretically supported or that they are common in both terms?

1 Answer 1

1

It works because in a (ECMA-48) standard terminal, there is no difference in the effect of the two strings. Both send the cursor to the upper left corner of the screen. Then one (\E[J) clears the remainder of the screen while the other (\E[2J) clears the whole screen:

CSI Ps J  Erase in Display (ED), VT100.
            Ps = 0  ⇒  Erase Below (default).
            Ps = 1  ⇒  Erase Above.
            Ps = 2  ⇒  Erase All.
            Ps = 3  ⇒  Erase Saved Lines, xterm.

(from XTerm Control Sequences)

1
  • Interesting thanks! I looked deep into it and could not find such low-level details
    – Whimusical
    Commented Mar 25 at 13:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .