0

I was trying to set up my key binding in tmux so that I can resize my panes without having to type the whole command. Currently I have it set up as:

bind-key -n S-Left resize-pane -L 1
bind-key -n S-Right resize-pane -R 1
bind-key -n S-Up resize-pane -U 1
bind-key -n S-Down resize-pane -D 1

however, that does not work for some reason. When I press shift left with not prefix it does not work (since thats what -n and S do). Does someone know what might be going wrong? My whole .tmux.conf file is as follows:

# Force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf

#set-window-option -g mode-keys vi
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection

#unbind %
bind | split-window -h
bind - split-window -v

# remap prefix to Control + a
unbind C-b
set -g prefix C-a
bind a send-prefix

# copy mode using vi
set-window-option mode-keys vi

bind-key -n S-Left resize-pane -L 1
bind-key -n S-Right resize-pane -R 1
bind-key -n S-Up resize-pane -U 1
bind-key -n S-Down resize-pane -D 1

I actually tried a new thing and I tried executing one of those commands sperately on the tmux command line. To get there I pressed prefix and then :. Then I typed the command:

bind-key -n S-Up resize-pane -U 1

which did work. Now Shift up with no prefix resizes the pane. But for some reason the tmux config file is not being sourced...right? Not sure what might it be.


It seems it works now after I added:

source ~/.tmux.conf

at the end of the file. However, it feels like a super hacky solution. Anyone know why I need to do such a silly command in the tmux config file?

0

Surely you have realized by now, that "silly command" is the command to "read" your default tmux configuration file.

It is not necessary for the function of your resize-shortcuts.

0

Adding the command to the end of the file is not enough to actually source the file, since sourcing the file would be needed to reach that command, essentially resulting in a double source.

More likely you did something in between, e.g. restarted your terminal session and restarted tmux (or just restarted tmux), which WOULD trigger the the source command against the tmux config file.

Having source ~/.tmux.conf at the end of ~/.tmux.conf is redundant and unnecessary.

-1

I suspect that you had some tmux windows open, in which case it would have used the old configuration. you have two options:

1. before starting a tmux session, source the config

~source ~/.tmux.conf~

  1. shut down all tmux windows and start a new session
New contributor
salah is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

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.