tmux set-titles stopped woorking for rxvt-unicode - tmux

Suddenly my tmux stopped to change terminal window title for rxvt-unicode. The only major change I remember doing last week was updating bash.
It'still working with xterm, so it may be something strictly with rxvt.
Here are my current versions:
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==================-==============-==============-==========================================
ii bash 4.3-7ubuntu1.1 amd64 GNU Bourne Again SHell
ii rxvt-unicode 9.19-1 amd64 RXVT-like terminal emulator with Unicode s
ii tmux 1.8-5 amd64 terminal multiplexer
And here, fragments of my conf files:
.bashrc
# Start tmux at login
# If not running interactively, do not do anything
[[ $- != *i* ]] && return
[[ -z "$TMUX" ]] && exec tmux
.Xdefaults
URxvt.background: #1E2B20
URxvt.foreground: wheat
URxvt.fading: 25
URxvt.scrollBar: 0
!URxvt.font: -*-fixed-medium-r-semicondensed-*-13-*-*-*-*-*-*-*
!URxvt.font: xft:Inconsolata:pixelsize=15
URxvt.font: xft:Ubuntu Mono:pixelsize=15
URxvt.color10: #66ff66
URxvt.color12: #6666ff
URxvt.borderLess: 0
URxvt.termName: rxvt
URxvt.urlLauncher: google-chrome
URxvt.loginShell: 1
! Font resize extension
URxvt.perl-ext-common: ...,font-size
URxvt.keysym.C-S-Up: perl:font-size:increase
URxvt.keysym.C-S-Down: perl:font-size:decrease
.tmux.conf
# turn on window titles
set -g set-titles on
# set wm window title string
set -g set-titles-string '#W'
# automatically set window title
setw -g automatic-rename on
How can I make it work again? Am I forgetting something?

The $TERM is set to rxvt, in .Xdefaults. Setting it to rxvt-unicode fiz the problem.
in .Xdefaults:
URxvt.termName: rxvt-unicode

Related

zsh configuration in tmux

I am using tmux and zsh.
When I am outside tmux, zsh is customized with some Manjaro settings, as per the .zshrc
# Use powerline
USE_POWERLINE="true"
# Source manjaro-zsh-configuration
if [[ -e /usr/share/zsh/manjaro-zsh-config ]]; then
source /usr/share/zsh/manjaro-zsh-config
fi
# Use manjaro zsh prompt
if [[ -e /usr/share/zsh/manjaro-zsh-prompt ]]; then
source /usr/share/zsh/manjaro-zsh-prompt
fi
# Use ssh-agent
if [[ -e /home/marcosh/ssh-agent.zsh ]]; then
source /home/marcosh/ssh-agent.zsh
fi
source /usr/share/nvm/init-nvm.sh
When I am inside tmux though, the customizations are missing, eventhough it is using zsh. This is my .tmux.conf
set-option -g history-limit 50000
# sane scrolling
set-option -g mouse on
set -ga terminal-overrides ',xterm*:smcup#:rmcup#'
# new pane on same folder
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
# use zsh instead of bash
set -g default-command /usr/bin/zsh
What should I do to get the same zsh configuration both when inside and outside tmux?
The problem is tmux is not rendering the UTF-8 characters from the manjaro config properly.
To solve this use:
tmux -u
From the tmux manpage:
-u Write UTF-8 output to the terminal even if the first
environment variable of LC_ALL, LC_CTYPE, or LANG that
is set does not contain "UTF-8" or "UTF8". This is
equivalent to -T UTF-8.

How to automatically rename tmux windows to the current directory

I would like to have tmux to automatically rename the window with the current working directory (cwd). As it is by default, it names the tab/window as the name of the current process, such as zsh or vim.
When I open a new window in tmux, the name is reattach-to-use-namespace and then it immediately switches to zsh.
I'm on OS X 10.10.2, I use zshell, and I have tmux 1.9a.
To be clear, I don't want the entire path in the name of the window, just the current directory, so for example, I want projectName, not /Users/username/Development/projectName.
If you want to see my current tmux.conf, here it is.
With tmux 2.3+, the b: format modifier shows the "basename" (or "tail") of a path.
set-option -g status-interval 5
set-option -g automatic-rename on
set-option -g automatic-rename-format '#{b:pane_current_path}'
The FORMATS section of man tmux describes other modifiers, such as #{d:} and even #{s/foo/bar/:}.
With tmux 2.2 or older, the basename shell command can be used instead.
set-option -g status-interval 5
set-option -g automatic-rename on
set-option -g automatic-rename-format '#(basename "#{pane_current_path}")'
Expanding on what Josef wrote, you can put the basename of the directory in the status using a shell snippet:
# be sure to see note* below
set -g window-status-format '#I:#(pwd="#{pane_current_path}"; echo ${pwd####*/})#F'
set -g window-status-current-format '#I:#(pwd="#{pane_current_path}"; echo ${pwd####*/})#F'
# status bar updates every 15s by default**, change to 1s here
# (this step is optional - a lower latency might have negative battery/cpu usage impacts)
set -g status-interval 1
*Note that what would be ${pwd##*/} is escaped to ${pwd####*/} since # has special meaning in the format string.
**See here for an example default tmux config.
Show the top N components
Showing just the basename generates too much ambiguity, but full paths are too much clutter, so I settled for:
the/last/path
instead of:
/a/very/long/the/last/path
or just:
path
.tmux.conf
set-window-option -g window-status-current-format '#[fg=white,bold]** #{window_index} #[fg=green]#{pane_current_command} #[fg=blue]#(echo "#{pane_current_path}" | rev | cut -d'/' -f-3 | rev) #[fg=white]**|'
set-window-option -g window-status-format '#[fg=white,bold]#{window_index} #[fg=green]#{pane_current_command} #[fg=blue]#(echo "#{pane_current_path}" | rev | cut -d'/' -f-3 | rev) #[fg=white]|'
Trick taken from: Remove part of path on Unix
If that still does not solve ambiguity, I go for:
bind-key -r w choose-window -F '#{window_index} | #{pane_current_command} | #{host} | #{pane_current_path}'
Tested on Tmux 2.1, Ubuntu 16.04.
To get the best of both worlds - window name is path when you're at a shell prompt, but name of executable when you're running something, try this:
set-option -g status-interval 1
set-option -g automatic-rename on
set-option -g automatic-rename-format "#{?#{==:#{pane_current_command},bash},#{b:pane_current_path},#{pane_current_command}}"
Replace "bash" with whatever shell you're using.
Adding this config to your ~/.tmux.conf file should work:
set-option -g window-status-current-format '#I:#{pane_current_path}#F'
set-option -g window-status-format '#I:#{pane_current_path}#F'
set-option -g status-interval 1
It depends however on your Tmux version. I wasn't able to make it work on 1.9a3 (in Cygwin) - but with Tmux 1.8 on Ubuntu (in Vagrant) it worked fine.
I use the following in ~/.tmux.conf to achieve this (working on OSX, zsh, tmux-2.3):
set -g automatic-rename-format '#{pane_current_path}'
set -g status-interval 5
You can set status-interval to 1 to make it respond faster to changing directories.
According to the changelog (https://raw.githubusercontent.com/tmux/tmux/master/CHANGES) this should work in tmux 1.9 and up.
Using ssh into a CentOS machine with tmux 2.3 the window name doesn't change until I press return in the new panel, not sure why that is happening.
Do something like this in a tmux session for zsh shell:
setopt PROMPT_SUBST
export PS1=$'\ek$(basename $(pwd))\e\\> '
If someone uses bash shell:
export PS1="\033k\$(basename \$(pwd))\033\\> "
You can add these commands in the shell initialization file on the condition the $TERM env variable is set to the value "screen"
I am using zsh hook for that
Add following in ~/.zshrc
precmd () {
if [ -n "$TMUX" ]; then
tmux set-window-option -q window-status-format "#[fg=cyan bg=cyan] | #[fg=white, bg=cyan] #I | ${PWD##/*/} #[fg=cyan, bg=cyan] | "
tmux set-window-option -q window-status-current-format "#[fg=cyan, bg=cyan] | #[fg=white, bg=cyan] #I | ${PWD##/*/} #[fg=cyan, bg=cyan] | "
fi
}
This doesn't strictly answer your question--it doesn't automatically rename an existing tmux session to the current working directory.
Rather, when creating a new session, it names that session after the current working directory.
Here's what I did:
to
~/.aliases
add
alias tm='tmux new -s `basename $PWD`'
Open a new terminal window and type:
tm
This now creates a new tmux session which is named after the current working directory.
Note: This relies on basename which does not exist in Windows.
I am sure that you want use this:
set -g status-left '#{pane_current_path} '
To change what you see in the window list you can specify a format when you define the key-binding for the chose-window function like this:
bind-key '"' choose-window -F "#{session_name} | #{window_name} - #{b:pane_current_path} (#{pane_current_command})"

Tmux: unknown option: c0-change-interval

I have compiled tmux 1.9a and added the following to my tmux.conf file:
setw -g c0-change-interval 50
setw -g c0-change-trigger 75
However, this doesn't seem to work (I get some messages at startup that say they're unknown options). When I type setw -g c0-change-trigger 75 into tmux directly, I get:
unknown option: c0-change-interval
when I run tmux -V I get tmux 1.9a. My thinking is that the alias for the tmux PATH is set after I load tmux, and I'm actually running tmux 1.6, but I'm not aware of any way of checking what version of tmux is actually running.
When I run ps -u under COMMAND it just says tmux -2 new. Here is the relevant contents of my .bashrc file:
# this is where the compiled version of tmux 1.9a is:
export PATH="/home/quant/bin:$PATH"
# tmux
# If not running interactively, do not do anything
[[ $- != *i* ]] && return
[[ -z "$TMUX" ]] && exec tmux
What is going on? As far as I know the c0-change-interval command is supported by tmux 1.9a, and this is what I seem to be running.
This isn't the original poster's problem but if anyone is coming up on this now the problem is actually that c0-change-interval and c0-change-trigger have been removed completely.
From: https://raw.githubusercontent.com/tmux/tmux/master/CHANGES
"The c0-* options for rate-limiting have been removed. Instead, a backoff
approach is used."
So you should remove them from your configuration.
My thoughts:
make install doesn't tell your package manager about installed files so
I think there's a problem/conflict with your distribution package and your build :
1) check tmux package in your package-manger or synaptic & delete it & go to tmux build folder run make uninstall & install it again .
Or
2) for a better building process , build deb/rpm/.. packages is the best as it'll tell you package manager so replace the old version with a tool like checkinstall that will be easy,
instead of :
./configure && make
sudo make install
do :
./configure && make
sudo checkinstall
in my case ubuntu 14.04 that make my day happy,(I don't remember if I configureed some options, whatever)

tmux + powerline, bottom is too big

I recently switched from screen to tmux/powerline/tmuxinator
As shown below, there is a big unused space between the window and status bar.
What could be causing it?
.tmux.conf
set -g prefix C-t
unbind C-b
bind C-t send-prefix
set -g status-keys emacs
setw -g mod-keys emacs
set -g status-position bottom
# status bar
set-option -g status-utf8 on
# status bar
# windows
bind-key C-t last-window
# focus on first window#
select-window -t 0
source ~/.local/lib/python2.7/site-packages/powerline/bindings/tmux/powerline.conf
and tmuxinator
# ~/.tmuxinator/zibann.yml
name: zibann
root: ~/Documents/zibann/
# Optional tmux socket
# socket_name: foo
# Runs before everything. Use it to start daemons etc.
# pre: sudo /etc/rc.d/mysqld start
# Runs in each window and pane before window/pane specific commands. Useful for setting up interpreter versions.
# pre_window: rbenv shell 2.0.0-p247
# Pass command line options to tmux. Useful for specifying a different tmux.conf.
# tmux_options: -f ~/.tmux.mac.conf
# Change the command to call tmux. This can be used by derivatives/wrappers like byobu.
# tmux_command: byobu
windows:
- root: ls -l
- emacs: workon zibann && cd momsite && emacs
- cmd: workon zibann && cd momsite
- ipdb: workon zibann && cd momsite && emacs
- dbshell: workon zibann && cd momsite && python manage.py dbshell
- logs:
layout: main-vertical
panes:
- tail -f momsite/momsite/log/celeryd_error.log
- tail -f momsite/momsite/log/celerybeat_error.log
- tail -f momsite/momsite/log/uwsgi_out.log
- tail -f /var/log/nginx/error.log
- supervisor: workon zibann && cd momsite # && python manage.py supervisor --config-file=momsite/conf/supervisord.conf
C-b, D
and detached one of the clients and volla!
(So there must be one and only one client attached at one time I guess)

"tmux set -g mouse-mode on" not scrolling

To allow scrolling a tmux pane with a mouse, I put the following in my ~/.tmux.conf file:
set -g mouse-mode on
However, nothing changes. When I scroll, it still scrolls outside of tmux. Why is this?
So this option has been renamed in version 2.1 (18 October 2015)
From the changelog:
Mouse-mode has been rewritten. There's now no longer options for:
- mouse-resize-pane
- mouse-select-pane
- mouse-select-window
- mode-mouse
Instead there is just one option: 'mouse' which turns on mouse support
So this is what I'm using now in my .tmux.conf file
set -g mouse on
As #Graham42 noted, mouse option has changed in version 2.1. Scrolling now requires for you to enter copy mode first. To enable scrolling almost identical to how it was before 2.1 add following to your .tmux.conf.
set-option -g mouse on
# make scrolling with wheels work
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
bind -n WheelDownPane select-pane -t= \; send-keys -M
This will enable scrolling on hover over a pane and you will be able to scroll that pane line by line.
Source: https://groups.google.com/d/msg/tmux-users/TRwPgEOVqho/Ck_oth_SDgAJ
Just a quick heads-up to anyone else who is losing their mind right now:
https://github.com/tmux/tmux/blob/310f0a960ca64fa3809545badc629c0c166c6cd2/CHANGES#L12
So that's just
:setw -g mouse
this should work:
setw -g mode-mouse on
then resource then config file
tmux source-file ~/.tmux.conf
or kill the server
Paste here in ~/.tmux.conf
set -g mouse on
and run on terminal
tmux source-file ~/.tmux.conf
As #Graham42 said, from version 2.1 mouse options has been renamed but you can use the mouse with any version of tmux adding this to your ~/.tmux.conf:
Bash shells:
is_pre_2_1="[[ $(tmux -V | cut -d' ' -f2) < 2.1 ]] && echo true || echo false"
if-shell "$is_pre_2_1" "setw -g mode-mouse on; set -g mouse-resize-pane on;\
set -g mouse-select-pane on; set -g mouse-select-window on" "set -g mouse on"
Sh (Bourne shell) shells:
is_pre_2_1="tmux -V | cut -d' ' -f2 | awk '{print ($0 < 2.1) ? "true" : "false"}'"
if-shell "$is_pre_2_1" "setw -g mode-mouse on; set -g mouse-resize-pane on;\
set -g mouse-select-pane on; set -g mouse-select-window on" "set -g mouse on"
Hope this helps
You can still using the devil logic of setting options depending on your current Tmux version: see my previous answer.
But since Tmux v1.7, set-option adds "-q" to silence errors and not print out anything (see changelog).
I recommend to use this feature, it's more readable and easily expandable.
Add this to your ~/.tmux.conf:
# from v2.1
set -gq mouse on
# before v2.1
set -gq mode-mouse on
set -gq mouse-resize-pane on
set -gq mouse-select-pane on
set -gq mouse-select-window on
Restar tmux or source-file your new .tmux.conf
Side note: I'm open to remove my old answer if people prefer this one
This line:
set -g mouse-mode on
in your ~/.tmux.conf file won't work.
For one thing, the proper setting is not mouse-mode, but mode-mouse.
Second, it only works on older versions of tmux (pre-version 2; you can run tmux -V to see what version you have, but you can also run man tmux to see if mode-mouse is a supported option).
And third, technically man tmux says to use the mode-mouse option with setw (set-window-option) and not with set (set-option), although I've seen it work with set (as well as setw).
These lines should work:
If your version of tmux is recent enough (that is, if tmux -V shows version 2 or newer), you can put this line in your ~/.tmux.conf file:
set-option -g mouse on
But if you use an older version of tmux, put these lines in your ~/.tmux.conf file:
set-window-option -g mode-mouse on
set-option -g mouse-resize-pane on
set-option -g mouse-select-pane on
set-option -g mouse-select-window on
Again, if you're not absolutely sure which line(s) to put in your ~/.tmux.conf file, run man tmux and search for mouse-mode, mouse-resize-pane, mouse-select-pane, and/or mouse-select-window. If you find them, then use those options (the ones for the older version of tmux).
Putting these lines in will allow you to use the mouse scroll wheel, it will allow you click on various panes to activate them, and it will allow you to resize panes just by clicking-and-dragging on their splitter separator.
You can also copy-and-paste using your mouse. However, you may notice that copying-and-pasting with your mouse may not work like it normally does on your console. To work around this, I've noticed that holding down the SHIFT key while using your mouse's copy/paste abilities makes them work normally again. (On MacOS, fn seems to work for me better than SHIFT.) Or you can learn tmux's approach to copy-and-pasting (which I do recommend).
A note on using tmux's native ability to copy/select/paste:
Personally, I feel that the vi keys make more sense to me than the default emacs keys (for example, it feels more natural to exit selection mode with vi mode's ENTER than with emacs mode's CTRL+w or ALT+w), so I have this in my ~/.tmux.conf file:
# For vi-like keys in copy/paste/selection mode:
set-window-option -g mode-keys vi
However, I've noticed that on older versions on tmux, this line won't work, unless I've also included the line:
set-window-option -g mode-mouse on
Good to know: Occasionally, when you're using the mouse's scroll wheel, you'll discover that your pane/screen appears to be frozen or locked up (it won't respond to keyboard input), and it's not clear what to do to unlock it.
It's not locked up. You're likely in tmux's selection mode. To get out of it, try one of these:
Hit ENTER. (Will likely work in vi mode.)
Hit ALT+w. (Will likely work in emacs mode.)
Hit CTRL+w. (Will likely work in emacs mode.)
Hit META+w. (Will likely work in emacs mode.)
Hit Esc. (Will likely work in emacs mode.)
Hit q. (Will likely work in vi mode, and may work in emacs mode as well.)
Ultimately, you can try hitting:
CTRL+w     ENTER
or:
Esc     q
Chances are, that will put you back in the normal mode where your keyboard is responsive again.
Using the mouse with vim:
I've discovered that putting this line in my ~/.vimrc file:
:set mouse=a
seems to work well with tmux, better than this line:
:set mouse=r
I can't really explain the difference; if you're a vim user, try them out and see which setting works best for you.
If you need to test out these tmux options, you may find yourself editing your ~/.tmux.conf file, exiting tmux, and then restarting tmux. This can become a tedious process, so if you want some work-arounds, here are some options:
Option1: After editing (and saving) your ~/.tmux.conf file, run this command (while in tmux):
CTRL+B :source-file ~/.tmux.conf ENTER
This will immediately apply the new settings in your ~/.tmux.conf file into your current tmux session, without the need to restart tmux.
Option 2: If you're in a tmux session, you can turn on/off options temporarily just for that session by running commands like these at the Unix shell prompt:
tmux set-option -g mouse on
tmux set-window-option -g mode-keys vi
Option 3: You can also temporarily turn on/off options in a tmux session with:
CTRL+B :set-option -g mouse on ENTER
CTRL+B :set-window-option -g mode-keys vi ENTER
Good luck, and have fun using tmux !
Try this. It works on my computer.
set -g mouse on
Ctrl + B and then set mouse. -g is not needed anymore.

Resources