Solved tmux vs screen

Argentum

Aspiring Daemon

Reaction score: 296
Messages: 621

Hello!

I have been a long-time sysutils/screen user, now trying to switch to sysutils/tmux. In general, I am pleased, but there is a little annoyance I cannot solve:
  • When using less <file> under scren the displayed content remains on the terminal after less exits;
  • with tmux when less exits the terminal window is cleared. This is annoying, because I need often to copy and paste that information;
  • I have no idea how to change this behavior;
  • TERM=xterm-256color
 

Geezer

Aspiring Daemon

Reaction score: 446
Messages: 757

I also used to use screen and have changed to tmux. It is different, a bit chunkier, but overall I think it is better.
  • When using less <file> under scren the displayed content remains on the terminal after less exits;
  • with tmux when less exits the terminal window is cleared. This is annoying, because I need often to copy and paste that information;

Well, leave it open then.

  • TERM=xterm-256color

In /usr/local/etc/tmux.conf set -g default-terminal "screen-256color"

It needs a bit of time to get this file to the stage where you are happy. I also use a few aliases for starting tmux for different purposes.
 

T-Daemon

Daemon

Reaction score: 926
Messages: 1,813

  • When using less <file> under scren the displayed content remains on the terminal after less exits;
  • with tmux when less exits the terminal window is cleared. This is annoying, because I need often to copy and paste that information;
  • I have no idea how to change this behavior;
  • TERM=xterm-256color
Code:
pkg info -l tmux
        ...
        /usr/local/share/examples/tmux/example_tmux.conf
        ...

../example_tmux.conf
Code:
...
# Change the default $TERM to tmux-256color
set -g default-terminal "tmux-256color"
...

For 'xterm-256color' change accordingly in ~/.tmux.conf.
 

T-Daemon

Daemon

Reaction score: 926
Messages: 1,813

tmux-set_TERM.png
Try 'xterm-256color'. Notice at the image bottom cat .tmux.conf.
 
OP
Argentum

Argentum

Aspiring Daemon

Reaction score: 296
Messages: 621

I am missing something - in tmux.conf I have now

Code:
set -g default-terminal "screen-256color"
set-window-option -g alternate-screen off

But it still clears the screen after less or other programs exiting.
 

covacat

Aspiring Daemon

Reaction score: 308
Messages: 618

use less -X until you find a better way and PAGER=less -X for manpages
 

T-Daemon

Daemon

Reaction score: 926
Messages: 1,813

Something wrong with set -g default-terminal "xterm-256color" in ~/.tmux.conf or /usr/local/etc/tmux.conf ?

tmux-TERM-xterm-256color.png
 
OP
Argentum

Argentum

Aspiring Daemon

Reaction score: 296
Messages: 621

In combination with PAGER set to less(1) & set-window-option -g alternate-screen off in your (local) tmux(1) conf file (e.g.: ~/.tmux.conf); try:
$ setenv LESS "-X"
That works as a workaround, but the same issue is with many other applications - vi for example and many others...
 

VladiBG

Daemon

Reaction score: 568
Messages: 1,247

Start the tmux then press " ctrl+b" then " :" and type into the tmux console " showw -g" and check the status of "alternate-screen"
 

Erichans

Member

Reaction score: 63
Messages: 72

Something wrong with set -g default-terminal "xterm-256color" in ~/.tmux.conf or /usr/local/etc/tmux.conf ?
With me that also works.

EDIT:
The tmux FAQ does not mention the value "xterm-256-color"; only "screen-256color" and "tmux-256color". However, the "similar" seems to leave some room for alternatives:
Inside tmux TERM must be "screen", "tmux" or similar (such as "tmux-256color").

____
That works as a workaround, but the same issue is with many other applications - vi for example and many others...
I've tried what I mentioned and the option that T-Daemon mentions; unfortunately I can not replicate your problematic behaviour. With me, vi text stays on screen after exiting.
 
OP
Argentum

Argentum

Aspiring Daemon

Reaction score: 296
Messages: 621

I've tried what I mentioned and the option that T-Daemon mentions; unfortunately I can not replicate your problematic behaviour. With me, vi text stays on screen after exiting.
That is interesting. I have the same behavior on three different desktop installations.
 
OP
Argentum

Argentum

Aspiring Daemon

Reaction score: 296
Messages: 621

Start the tmux then press " ctrl+b" then " :" and type into the tmux console " showw -g" and check the status of "alternate-screen"
It was on. Thanks! If I set it manually, the problem is solved. For some reason, I think, it is not reading the configuration file.
 

VladiBG

Daemon

Reaction score: 568
Messages: 1,247

The system wide configuration of /usr/local/etc/tmux.conf is loaded first if exists and then the user configuration from ~/.tmux.conf is loaded.
Can you show the output of both files if they exists?
cat /usr/local/etc/tmux.conf
cat ~/.tmux.conf
 

AngryChris

Member

Reaction score: 17
Messages: 23

I have this in my .tmux.rc file:
Code:
# Set a key that lets us reload the configuration without restarting.
bind-key R source-file ~/.tmux.conf\; display-message "Config reloaded..."
I just hit the prefix key (^B by default, ^A for me) and then hit R and it reloads the config file immediately.
 

Erichans

Member

Reaction score: 63
Messages: 72

I have this in my .tmux.rc file:
Code:
# Set a key that lets us reload the configuration without restarting.
bind-key R source-file ~/.tmux.conf\; display-message "Config reloaded..."
I just hit the prefix key (^B by default, ^A for me) and then hit R and it reloads the config file immediately.
Looking at tmux(1), you probably meant: .tmux.conf (not .tmux.rc). If you specifically want to use .tmux.rc then you must use that in the definition of bind-key R and you must specify that when starting tmux:
$ tmux -f .tmux.rc

As this definition is also mentioned in tmux(1) it will probably work for most changes. However, changing your .tmux.conf on the fly (for example by sourcing it inside a tmux session) will not always work as intended with every setting. The setting for default-terminal happens to be such a setting. As mentioned in the tmux FAQ the correct terminal setting is very important.

Starting tmux(1) with .tmux.conf with:
set -g default-terminal "blurp-256color"
results in:
Code:
tcsh: The terminal database could not be opened.
tcsh: using dumb terminal settings.

Editing that value in ~/.tmux.conf while tmux is running and changing that in a correct value, for example:
set -g default-terminal "screen-256color"
then sourcing it by using "ctrl+b" then ":" and then typing in the tmux console:
source-file ~/.tmux.conf
does not result in a changed behaviour with respect to the terminal setting.

Exiting tmux (you may want to kill a running tmux server as mentioned by Geezer in this earlier message) and restarting tmux with the changed ~/.tmux.conf gives the intended result. This is to be expected because the terminal setting has such a profound influence on tmux
 
Top