This article is outdated. Simply use:
# for `selWin`
bind 1 if-shell 'tmux select-window -t :1' '' 'new-window -t :1'
# for `movePane`
bind M-1 if-shell 'tmux join-pane -d -t 1.1' '' { if-shell 'tmux break-pane -d -t 1' '' 'move-window -t 1' }
# for `rearrange`
set -g renumber-windows on
Spending a lot of time in the command line, I am quite a happy tmux user. As much as I love tmux, I find it a bit stiff in handling panes and windows, especially if you compare it to tiled window managers like xmonad. During the years, I wrote some simple scripts to help me in such menial tasks.
Here is a brief description of what those scripts do:
xTmux movePane n
will send the current pane to window number n. If such
window does not exist, the script will create it before moving the
pane.
In my .tmux.conf I added:
bind M-1 run-shell "~/somePath/./xTmux.hs movePane 1
bind M-2 run-shell "~/somePath/./xTmux.hs movePane 2
[...]
bind M-9 run-shell "~/somePath/./xTmux.hs movePane 9
bind M-0 run-shell "~/somePath/./xTmux.hs movePane 0
so by pressing Alt-4
I will send the pane I am working on to window
number 4.
selWin n
will select (go to) window number n. If such window does not
exist, it will be created. Relevant .tmux.conf section looks like this:
bind 1 run-shell "~/somePath/./xTmux.hs selWin 1
bind 2 run-shell "~/somePath/./xTmux.hs selWin 2
[...]
bind 9 run-shell "~/somePath/./xTmux.hs selWin 9
bind 0 run-shell "~/somePath/./xTmux.hs selWin 0
This makes window more similar to workspaces we are used to see in graphical window managers.
./xTmux.hs rearrange
will rearrange windows in ascendant order. So if your
layout looks like this
[0] 1:irssi 4:vim* 5:bash-
calling ./xTmux.hs rearrange
will lead to
[0] 1:irssi* 2:vim- 3:bash
Download the scripts. I wrote them in Haskell, so you will need to install GHC (or any other Haskell compiler) before running them:
sudo apt-get install ghc
chmod a+x xTmux.hs