This is my .tmux.conf file, placed in the home directory.
unbind C-b
set -g prefix S-a
bind S-a send-prefix
bind r source-file ~/.tmux.conf
I am properly loading it with tmux source-file ~/.tmux.conf. However, doing shift+a to initiate the prefix doesn't work.
However if I replace S-a with C-a, it'll work (ctrl+a).
What am I doing wrong?
You can't and it's not a good idea, the shift key is by no way meant for that. Take a look in the man tmux, section KEY BINDINGS for the list of available keys. More info are available here https://unix.stackexchange.com/a/140010
Solution 1
Run: (WARN: Save your work in all sessions first)
tmux kill-server
Solution 2
In your .zshrc/.bashrc file, add the following line:
[ -z "${TMUX}" ] || tmux YOUR_COMMAND
e.g. YOUR_COMMAND = set -g prefix S-a.
Related
I want my bind-key command to make use of a variable.
Here is my .tmux.conf file:
# .tmux.conf
bind-key r rename-session $MY_VARIABLE
How can I set MY_VARIABLE on a session-by-session basis?
Things I have tried that did not work:
Run export MY_VARIABLE=my_value in bash before pressing C-b r.
Run tmux setenv MY_VARIABLE my_value in bash before pressing C-b r.
(C-b is my prefix in tmux)
The following (based on this answer) DOES WORK:
Add a line to to .tmux.conf, like this:
# .tmux.conf
MY_VARIABLE=my_value
bind-key r rename-session $MY_VARIABLE
Running C-b r the successfully renames the session. But this is less than ideal, because MY_VARIABLE=my_value is hard-coded into the .tmux.conf file; I want a way to change MY_VARIABLE on an ad-hoc basis.
Typically, the way round this is to go through the shell again, eg:
bind-key r run-shell 'tmux rename-session "$MY_VARIABLE"'
The single quotes stops the variable from being expanding whilst parsing the config file. If you then later say
tmux setenv MY_VARIABLE my_value
it will set the session environment.
When you then type prefix-r the shell forked by run-shell will inherit these session variables, and the shell will be able to replace the variable by the current value for the session.
I want unbind the prefix keys of tmux, use caps lock-a instead of Ctrl-B
So, C means Ctrl, and ??? refer to caps lock?
unbind C-b
set -g prefix ???-a
tmux source-file ~/.tmux.conf
This is kind of a hack but achieves the end goal.
Change the behaviour of Capslock to Ctrl and keep the tmux config as C-a.
In OSX this can done using System Preferences > Keyboard > Modifier Keys.
In Linux this can be done using the command 'setxkbmap'
I'd like to be able to issue a command like this:
tmux new-window -n irc ssh -t eco /usr/bin/weechat
and have the title of the new window be "irc". Instead, as soon as weechat launches, the title changes to weechat.
I had been under the impression based on the tmux man page that if you set a window title explicitly, automatic-rename would be disabled for you:
automatic-rename
[...] This flag is automatically disabled for an individual window when a
name is specified at creation with new-window or new-session, or later
with rename-window, or with a terminal escape sequence.
But that seems to not be the case. What am I missing here? I do want automatic-rename in most cases - I just want to also be able to specify -n windowname and have it take precedence.
I'm using bind-key + , to rename my windows, but as soon as I type a command the name reverts back to the current working directory.
Is it possible to make the window name permanent?
The automatic rename function is turned on. Add the following to your .tmux.conf file (and/or run from the command line to have it take effect immediately):
set-window-option -g automatic-rename off
Per this superuser answer, I made the following change to ~/.tmux.conf:
# NO, window name keeps changing
# set -g default-terminal "screen-256color"
# YES, window name sticks
set -g default-terminal "xterm-256color"
I've been a happy tmux user for a while now but there's one behaviour that's bugging me. When I switch panes using ^b-arrow, and then immediately press arrow-up (to get a command from history, for example), the window pane switches again. I understand this can be useful if you want to move through multiple panes quickly, but for me it's a pain in the backside since I keep ending up in panes I never meant to be in.
So, is there a way to set tmux so that the ^b-arrow command only switches pane once and ignores any following arrow key presses?
That happens because the default bindings for the arrow keys are setup with bind-key -r, specifying that they may be repeated. There are two ways that you can disable this.
First, you can use set-option repeat-time 0 to disable repeating entirely. This will affect all bindings. I find that to be very annoying when resizing panes.
Secondly, you can change the bindings for the arrow keys to use bind-key without the -r option:
bind-key Up select-pane -U
bind-key Down select-pane -D
bind-key Left select-pane -L
bind-key Right select-pane -R
If you spend a lot of times navigating panes, why not set up global mappings so you don't have to use prefixes at all, e.g. bind -n C-h select-pane -L to map ctrl-h to switching left, same as Vim.
See http://robots.thoughtbot.com/seamlessly-navigate-vim-and-tmux-splits for an even better solution that also navigates across Vim windows.
Another option is to make a binding to jump to the previous pane, if you are flicking back and forth between the same two panes.
bind-key C-a last-pane