Pane Title in Tmux .conf File - tmux

I'm setting up a window template script in the tmux.conf file and want to have a statement that add a pane title.
In a related post 2019 the solution is partially provided by adding a pane title from the command line - link. A solution is quoted below:-
tmux select-pane -t {pane} -T {title}
Examples:
tmux select-pane -T title1 # Change title of current pane
tmux select-pane -t 1 -T title2 # Change title of pane 1 in current window
tmux select-pane -t 2.1 -T title3 # Change title of pane 1 in window 2`
How do I translate this into a line in the .tmux.conf file?
I've tried the following;
send-keys 'tmux select-pane -t 1 -T titles' C-m ;
select-pane -t 1 -T titles C-m ;
select-pane -t 1-T titles

Finally - although changes to the config file seem to be effected by the continuum & reurrect plugins I found that in order for this to work:-
select-pane -T title1 # Change title of current pane
select-pane -t 1 -T title2 # Change title of pane 1 in current window
select-pane -t 2.1 -T title3 # Change title of pane 1 in window 2
You had to first add the following to the conf file:-
set -g pane-border-format "#{pane_index} #{pane_current_command}"

Related

How do I set tmux window name from within a Bash script?

In one of my tmux windows, I run a Weechat IRC client inside a Docker container, which I instantiate using a Bash script, which makes the tmux window name "bash". https://imgur.com/a/Dc20YEB
I would like the tmux window name to be "weechat", as if I had run a locally installed weechat - as is the case with man or nvim.
I understand there is a difference between "window names" and "pane titles", and that I can set the window name using (as detailed in the man page):
tmux set-option allow-rename on
tmux select-pane -T fooname
printf '\033kWINDOW_NAME\033\\'
But this changes my window name to 1:tpreston#hostname:~*. I'm running tmux 2.9a on Fedora 30.
These are my options
activity-action other
assume-paste-time 1
base-index 0
bell-action any
default-command ""
default-shell "/bin/bash"
default-size "80x24"
destroy-unattached off
detach-on-destroy on
display-panes-active-colour red
display-panes-colour blue
display-panes-time 1000
display-time 4000
history-limit 50000
key-table "root"
lock-after-time 0
lock-command "lock -np"
message-command-style fg=yellow,bg=black
message-style fg=black,bg=yellow
mouse on
prefix C-Space
prefix2 None
renumber-windows off
repeat-time 500
set-titles off
set-titles-string "#S:#I:#W - \"#T\" #{session_alerts}"
silence-action other
status on
status-bg green
status-fg black
status-format[0] "#[align=left range=left #{status-left-style}]#{T;=/#{status-left-length}:status-left}#[norange default]#[list=on align=#{status-justify}]#[list=left-marker]<#[list=right-marker]>#[list=on]#{W:#[range=window|#{window_index} #{window-status-style}#{?#{&&:#{window_last_flag},#{!=:#{window-status-last-style},default}}, #{window-status-last-style},}#{?#{&&:#{window_bell_flag},#{!=:#{window-status-bell-style},default}}, #{window-status-bell-style},#{?#{&&:#{||:#{window_activity_flag},#{window_silence_flag}},#{!=:#{window-status-activity-style},default}}, #{window-status-activity-style},}}]#{T:window-status-format}#[norange default]#{?window_end_flag,,#{window-status-separator}},#[range=window|#{window_index} list=focus #{?#{!=:#{window-status-current-style},default},#{window-status-current-style},#{window-status-style}}#{?#{&&:#{window_last_flag},#{!=:#{window-status-last-style},default}}, #{window-status-last-style},}#{?#{&&:#{window_bell_flag},#{!=:#{window-status-bell-style},default}}, #{window-status-bell-style},#{?#{&&:#{||:#{window_activity_flag},#{window_silence_flag}},#{!=:#{window-status-activity-style},default}}, #{window-status-activity-style},}}]#{T:window-status-current-format}#[norange list=on default]#{?window_end_flag,,#{window-status-separator}}}#[nolist align=right range=right #{status-right-style}]#{T;=/#{status-right-length}:status-right}#[norange default]"
status-format[1] "#[align=centre]#{P:#{?pane_active,#[reverse],}#{pane_index}[#{pane_width}x#{pane_height}]#[default] }"
status-interval 5
status-justify left
status-keys emacs
status-left "[#S] "
status-left-length 10
status-left-style default
status-position bottom
status-right "#(/home/tpreston/.tmux/plugins/tmux-battery/scripts/battery_status_bg.sh) b:#(/home/tpreston/.tmux/plugins/tmux-battery/scripts/battery_icon.sh)#(/home/tpreston/.tmux/plugins/tmux-battery/scripts/battery_percentage.sh) | %a %F %H:%M "
status-right-length 40
status-right-style default
status-style fg=black,bg=green
update-environment[0] "DISPLAY"
update-environment[1] "KRB5CCNAME"
update-environment[2] "SSH_ASKPASS"
update-environment[3] "SSH_AUTH_SOCK"
update-environment[4] "SSH_AGENT_PID"
update-environment[5] "SSH_CONNECTION"
update-environment[6] "WINDOWID"
update-environment[7] "XAUTHORITY"
visual-activity off
visual-bell off
visual-silence off
word-separators " -_#"
# rename window name of current window
tmux rename-window newname
# rename another window
tmux rename-window -t <target> new-name
The parameter <target> could be
window name
window index
window name or index with session prefix: <session>:<window>
tmux select-pane -T fooname
This sets the pane title not the window name. Use "tmux rename-window" to change the window name.
tmux set-option allow-rename on
printf '\033kWINDOW_NAME\033\'
This does change the window name.
But this changes my window name to 1:tpreston#hostname:~*
This is because something else is renaming the window, probably your shell is doing it as part of the prompt.
If you want to have allow-rename on and use the \033k escape sequence yourself, you will need to track this down and disable it.
If your script is running on the same host as tmux, it might be better just to leave allow-rename off and run "tmux renamew weechat" from the script.

Tmux: keep accidentally resizing pane instead of switching to the next one

Tmux is excellent, but there is one quirk that is proving to be a pane. If I hit ctrl+b then go too fast to the arrow key in order to switch panes I end up just resizing the current pane. It would be very nice to get rid of that behaviour. Is this a problem solvable in tmux or is in some kind of lag in my OS?
tmux is fully configurable so, yes, it's possible to solve this issue.
I suggest that you take a look at the tmux man pages or at other resources like Pragmatic Bookshelf's "tmux 2" book.
As an example, you can fully remap the keys to use to split, move around and resize windows adding something like this to your ~/.tmux.conf file:
# Splitting panes
bind | split-window -h # Uses "|" to split pane horizontally
bind - split-window -v # Uses "-" to split pane vertically
# Remapping movement keys
bind h select-pane -L # Move focus to pane on the left
bind j select-pane -D # Move focus to pane above the current one
bind k select-pane -U # Move focus to pane below the current one
bind l select-pane -R # Move focus to pane on the right
bind -r C-h select-window -t :- # Move to previous window
bind -r C-l select-window -t :+ # Move to next window
# Resizing panes (notes that is using the uppercase here and resize by 5 chars)
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5

tmux zoom in or out without toggle

tmux's zoom (< prefix> + z
or resize-pane -Z) is a toggle.
How do I zoom out (restore) only if the current pane is already zoomed in?
How do I zoom in (maximize) only if the current pane is un-zoomed?
tmux-zoom-in.sh
#!/bin/bash
# Zoom in the current pane ONLY if it is not currently zoomed.
# Requires tmux version >= 1.8
tmux list-panes -F '#F' | grep -q Z || tmux resize-pane -Z
exit 0
tmux-zoom-out.sh
#!/bin/bash
# Zoom out the current pane ONLY if it is not currently zoomed.
# Requires tmux version >= 1.8
tmux list-panes -F '#F' | grep -q Z && tmux resize-pane -Z
exit 0

tmux: how to toggle "on" and "off" options with the same key

This is a bit of my tmux.conf
cat tmux.conf
...
bind a set-window-option synchronize-panes on
bind b set-window-option synchronize-panes off
As you can see, sync and unsync options for panes are bound to two different keys. Is it possible to toggle sync/unsync with the same key?
If you don't explicitly specify "on" or "off", the option will get toggled. The following would suffice:
bind-key a set-window-option synchronize-panes\; display-message "synchronize-panes is now #{?pane_synchronized,on,off}"
don't attach on or off. it's toggle
bind-key a set-window-option synchronize-panes
This should be possible with a combination of run-shell and tmux show-option, something like (tested in tmux 2.3):
bind a run-shell "if [[ `tmux show-options -w | grep 'synchronize-panes.*on'` ]]; then toggle=off; else export toggle=on; fi; tmux display-message \"sync panes tmux: \$toggle\"; tmux set-option -w synchronize-panes \$toggle &> /dev/null"
(this is a variation of a mouse-mode toggle found on the TMux user mailing list)
Here's an example of toggling the mouse on and off with ^M:
bind-key c-M set-option -g mouse \; display-message 'Mouse #{?mouse,on,off}'
A more generic solution based on the answer by Frank Schmitt:
!/usr/bin/bash
USAGE="USAGE: $0 OPTION_NAME ON_STATE OFF_STATE"
OPTION_NAME=$1
ON_STATE=$2
OFF_STATE=$3
if [[ "$#" != 3 ]]; then
echo $USAGE
exit 1
fi
if [[ `tmux show-option -w | grep "$OPTION_NAME $ON_STATE"` ]]; then
OPTION_VALUE=$OFF_STATE
else
OPTION_VALUE=$ON_STATE
fi
tmux display-message "monitor activity: $OPTION_NAME $OPTION_VALUE"
tmux set-option -w $OPTION_NAME $OPTION_VALUE > /dev/null
The script takes the name of the option, the on value and the off value. Not very well tested but works for simple cases like:
PATH_TO_SCRIPT_ABOVE monitor-activity on off
In your .tmux.conf:
bind-key <SOME_KEY> run-shell "tmux_toggle_option monitor-activity on off"

Error in symbols font on tmux statusbar [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
Look at my Tmux status bar:
I down't see symbols. How I can fix this?
My config files is these:
.Xresurces
#define S_base03 #002b36
#define S_base02 #073642
#define S_base01 #586e75
#define S_base00 #657b83
#define S_base0 #839496
#define S_base1 #93a1a1
#define S_base2 #eee8d5
#define S_base3 #fdf6e3
#define S_yellow #b58900
#define S_orange #cb4b16
#define S_red #dc322f
#define S_magenta #d33682
#define S_violet #6c71c4
#define S_blue #268bd2
#define S_cyan #2aa198
#define S_green #859900
URxvt*background: S_base03
URxvt*foreground: S_base0
URxvt*fading: 40
URxvt*fadeColor: S_base03
URxvt*cursorColor: S_base1
URxvt*pointerColorBackground:S_base01
URxvt*pointerColorForeground:S_base1
!! black dark/light
URxvt*color0: S_base02
URxvt*color8: S_base03
!! red dark/light
URxvt*color1: S_red
URxvt*color9: S_orange
!! green dark/light
URxvt*color2: S_green
URxvt*color10: S_base01
!! yellow dark/light
URxvt*color3: S_yellow
URxvt*color11: S_base00
!! blue dark/light
URxvt*color4: S_blue
URxvt*color12: S_base0
!! magenta dark/light
URxvt*color5: S_magenta
URxvt*color13: S_violet
!! cyan dark/light
URxvt*color6: S_cyan
URxvt*color14: S_base1
!! white dark/light
URxvt*color7: S_base2
URxvt*color15: S_base3
URxvt*font: xft:Inconsolata for Powerline:size=12,xft:PowerlineSymbols:pixelsize=12:antialias=true
URxvt*scrollBar: False
URxvt*scrollTtyOutput: False
URxvt*scrollTtyKeypress: True
URxvt*secondaryScroll: True
URxvt*saveLines: 8000
URxvt*letterSpace: 0
URxvt*cursorBlink: True
URxvt*cursorUnderline: True
URxvt*modifier: alt
URxvt.perl-ext-common : default,matcher,keyboard-select,url-select,clipboard
URxvt.tabbed.tabbar-fg: 5
URxvt.tabbed.tabbar-bg: 0
URxvt.tabbed.tab-fg: 14
URxvt.tabbed.tab-bg: 0
URxvt.keysym.M-Escape: perl:keyboard-select:activate
URxvt.keysym.M-s: perl:keyboard-select:search
URxvt.keysym.M-u: perl:url-select:select_next
URxvt.url-select.autocopy: True
URvxt.url-select.button: 2
URxvt.url-select.launcher: firefox
URxvt.url-select.underline: True
URxvt.keysym.M-c: perl:clipboard:copy
URxvt.keysym.M-v: perl:clipboard:paste
URxvt.keysym.M-C-v: perl:clipboard:paste_escaped
And .tmux.conf:
# use UTF8
set -g utf8
set-window-option -g utf8 on
set -g status on
set -g status-utf8 on
# make tmux display things in 256 colors
set -g default-terminal "screen-256color"
# set scrollback history to 10000 (10k)
set -g history-limit 10000
# set Ctrl-a as the default prefix key combination
# and unbind C-b to free it up
set -g prefix C-a
unbind C-b
# use send-prefix to pass C-a through to application
bind C-a send-prefix
# shorten command delay
set -sg escape-time 1
# set window and pane index to 1 (0 by default)
set-option -g base-index 1
setw -g pane-base-index 1
# reload ~/.tmux.conf using PREFIX r
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# use PREFIX | to split window horizontally and PREFIX - to split vertically
bind | split-window -h
bind - split-window -v
# Make the current window the first window
bind T swap-window -t 1
# map Vi movement keys as pane movement keys
bind -n S-down new-window
bind -n C-right select-pane -R
bind -n C-left select-pane -L
bind -n C-up select-pane -U
bind -n C-down select-pane -D
bind -n S-right next
bind -n S-left prev
bind l select-pane -R
# and use C-h and C-l to cycle thru panes
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+
# resize panes using PREFIX H, J, K, L
bind H resize-pane -L 10
bind J resize-pane -D 10
bind K resize-pane -U 10
bind L resize-pane -R 10
# C-i for even-vertical arrangement and C-o to zoom current pane
bind-key C-i select-layout even-vertical
bind-key C-v select-layout even-horizontal
#bind-key C-o resize-pane -y 1000
# Sync panes
bind C-s set-window-option synchronize-panes
# explicitly disable mouse control
setw -g mode-mouse off
set -g mouse-select-pane off
set -g mouse-resize-pane off
set -g mouse-select-window off
# ---------------------
# Copy & Paste
# ---------------------
# provide access to the clipboard for pbpaste, pbcopy
#set-option -g default-command "reattach-to-user-namespace -l zsh"
set-window-option -g automatic-rename on
# use vim keybindings in copy mode
setw -g mode-keys vi
bind y run 'tmux save-buffer - | reattach-to-user-namespace pbcopy '
bind C-y run 'tmux save-buffer - | reattach-to-user-namespace pbcopy '
# -----------------------
# Multistart panes
# ----------------------
bind-key P run-shell 'tmux-multistart as'
bind-key A run-shell 'tmux-multistart alpha'
bind-key B run-shell 'tmux-multistart beta'
bind-key W run-shell 'tmux-multistart web'
bind-key D run-shell 'tmux-multistart dev'
bind-key T run-shell 'tmux-multistart txhub'
bind-key C command-prompt -p "machine(s)/group: " "run-shell 'tmux-multistart %1'"
# ----------------------
# set some pretty colors
# ----------------------
# set pane colors - hilight the active pane
set-option -g pane-border-fg colour235 #base02
set-option -g pane-active-border-fg colour240 #base01
# colorize messages in the command line
set-option -g message-bg black #base02
set-option -g message-fg brightred #orange
# ----------------------
# Status Bar
# -----------------------
# visual notification of activity in other windows
setw -g monitor-activity on
set -g visual-activity on
# set color for status bar
set-option -g status-bg colour236 #base02
set-option -g status-fg yellow #yellow
set-option -g status-attr dim
# set window list colors - red for active and cyan for inactive
set-window-option -g window-status-fg brightblue #base0
set-window-option -g window-status-bg colour236
set-window-option -g window-status-attr dim
set-window-option -g window-status-current-fg brightred #orange
set-window-option -g window-status-current-bg colour236
set-window-option -g window-status-current-attr bright
# show host name and IP address on left side of status bar
set -g status-left-length 85
set -g status-right-length 60
set -g status-right '#[fg=colour16,bg=colour254,bold] #S #[fg=colour254,bg=colour234,nobold]'
set -g status-left '#(eval tmux-airline `tmux display -p "#{client_width}"`)'
set -g window-status-format "#[fg=colour244,bg=colour234]#I #[fg=colour240] #[default]#W "
set -g window-status-current-format "#[fg=colour234,bg=colour31]#[fg=colour117,bg=colour31] #I  #[fg=colour231,bold]#W #[fg=colour31,bg=colour234,nobold]"
I found it:
I had another error message with sublime about set locate for non-ascii characters in arch.
So arch's wiki help to set locale setting with this command:
$ locale > /etc/locale.conf
After i3 restart everythings is OK

Resources