17

To start tmux on every shell login, the following was added to the ~/.bashrc (on the server):

if [ $TERM != "screen-256color" ] && [  $TERM != "screen" ]; then
    tmux attach || tmux new; exit
fi

I also want to change the window title to something like user@server (instead of user@localhost) when ssh into a host. Here's my ~/.tmux.conf:

set -g prefix C-a
unbind C-b
bind C-a send-prefix

set -g set-titles on
set -g set-titles-string "#T"

bind-key o split-window -v
bind-key e split-window -h

bind-key w kill-pane

set -g terminal-overrides 'xterm*:smcup@:rmcup@'

As you can see, set-titles was set to on, but it doesn't work as expected.

More informations:

Outside of tmux:

$ echo $TERM
xterm

Inside of tmux:

$ echo $TERM
screen

show -g: https://clbin.com/h7oDh

tmux info: http://sprunge.us/XHCB

And here're the logs when running tmux -vvvvv for a bit:

If I comment out the lines in ~/.bashrc, from my laptop, ssh to the server, the title bar shows correctly (quanta@server), then start tmux from there also works as expected.

But if I want to start tmux immediately after login, the title bar remains to be quanta@Ubuntu after ssh.


UPDATE Fri May 10 07:51:23 ICT 2013

I have deleted the exit command in order not to close the shell session when the last tmux window is closed:

if [ $TERM != "screen-256color" ] && [  $TERM != "screen" ]; then
    tmux attach || tmux new
fi

The strange thing is:

  • ssh to server -> the title bar: quanta@Ubuntu
  • detach from tmux -> the title bar switch to quanta@server
  • attach to tmux again -> the title bar still shows correctly quanta@server

I'm not sure if it's related to the PROMPT_COMMAND environment variable or not:

Outside of tmux:

$ echo $PROMPT_COMMAND 
echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\007"

Inside of tmux:

$ echo $PROMPT_COMMAND
echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\033\\"
  • In case it isn't obvious in this question. His setup works fine, just not when he attempts to run it from his .bashrc. – slm May 9 '13 at 18:39
  • Please provide the output from tmux info. – slm May 10 '13 at 7:47
15

Problem solved!

To enable native xterm mouse scrolling in tmux, a lot of wiki, Q & A site, blog post suggest adding a line like:

set -g terminal-overrides 'xterm*:smcup@:rmcup@'

to ~/.tmux.conf. And it is the culprit.

To allow xterm titles in terminal window, you also need to add the XT flag, something like this:

set -g terminal-overrides "xterm*:XT:smcup@:rmcup@"

Source: http://opennomad.com/content/goodbye-screen-hello-tmux

  • 3
    Thank for your post. In my case with rxvt, the setting is set -ga terminal-overrides ",rxvt*:XT" – favadi May 11 '13 at 4:39
  • 2
    As @favadi pointed out, the proper fix for this is to use the -a option with set to append the smcup/rmcup overrides. This will fix other weird issues, like not being able to set the cursor shape properly. – blueyed Nov 5 '14 at 16:27
2

Came across this thread from the tmux-users mailing list. The thread was titled: set-titles not working. There are a couple of things from this thread to try. There's a cleaner version of the thread here as well.

XTerm Resources

For starters the eventual fix was to add the following line to your XTerm Resources file, ~/.Xresources:

XTerm*allowSendEvents: true

Debugging tmux tips

There were also some debugging tips in this thread that may help you as well.

verbose tmux

  1. close all tmux sessions
  2. run the command: tmux -vvvvv
  3. run the command: vi foo
  4. save the file
  5. exit tmux

After doing so you should have 3 files, something like these:

  • tmux-out-21594.log
  • tmux-client-21592.log
  • tmux-server-21594.log

tmux info

$ tmux info
tmux 1.4, pid 22182, started Fri May 10 04:00:37 2013
socket path /var/run/tmux/tmux-500/default, debug level 0
system is Linux 2.6.35.14-106.fc14.x86_64 #1 SMP Wed Nov 23 13:07:52 UTC 2011 x86_64
configuration file is /home/saml/.tmux.conf
protocol version is 6

Clients:
 0: /dev/pts/12 (8, 11): 0 [132x24 xterm] [flags=0x1/0x38, references=0]

Sessions: [5/10]
 0: 0: 1 windows (created Fri May 10 04:00:37 2013) [132x23] [flags=0x0]
   0: bash [132x23] [flags=0x8, references=1, last layout=-1]
     0: /dev/pts/48 22183 13 1/23, 135 bytes; UTF-8 0/23, 0 bytes

Terminals:
xterm [references=1, flags=0x0]:
 1: acsc: (string) ``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~
 0: AX: (flag) true
 2: bel: (string) \007
 ...
 ...
144: smul: (string) \033[4m
145: vpa: (string) \033[%i%p1%dd
146: xenl: (flag) true

Jobs:
  • I already read that thread before asking here. XTerm*allowSendEvents: true didn't work. The log files has been uploaded. See my updated question. – quanta May 10 '13 at 8:29
  • In the future you should include these types of items in your question, so as to not waste everyone's time rehashing things you've already tried. – slm May 10 '13 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.