Solved tmux vs screen

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
 
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.
 
  • 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.
 
tmux-set_TERM.png
Try 'xterm-256color'. Notice at the image bottom cat .tmux.conf.
 
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.
 
Start the tmux then press " ctrl+b" then " :" and type into the tmux console " showw -g" and check the status of "alternate-screen"
 
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.
 
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.
 
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.
 
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
 
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.
 
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
 
Back
Top