Change tmux key-bind conditionally, depending on which pane are you in.

For long time since I switched from gnu screen to tmux, I have been a little wondering is there any way to change tmux behavior depending on which pane I am working.
What I wanted to do is to enlarge a pane when I moved to the pane so that I can work on the bigger pane.
This is a bit convenient to know which pane I am moving in and keep terminal window smaller for a laptop.

I finally figured out how to do it today, I want to share it with you. (Maybe 10 more people on the earth want this info, I guess.)
Key bind is like this in .tmux.conf.

bind C-a if "tmux display-message -p | awk '{exit($5=0)}'" "resize-pane -D 16" \; last-pane \; resize-pane -U 8
Points are "if-shell" tmux command and -p option for tmux "display-message".
As you can see, this does not work well on three or more panes, but I usually don't do that so it's OK for me. If you want it, you should add condition to second resize-pane.
Any suggestion would be appreciated, as always.

Comments

Popular posts from this blog

Calling OpenCV functions via Cython from Python 3.X.

Showing CPU/Memory usage on tmux status bar(tmuxのステータスバーにCPUとMemoryの使用状況を表示する)

Subclassing and Signal connect on a same widget crashes PySide application on exit.