tmux is a terminal window manager, powerful but not always user friendly.
$ sudo apt install tmux
control+d on an empty line, and you’ll be back to the shell where you launched tmux.
The default key binding is
control+b, which is the same keybinding for moving the cursor back a character, so let’s remap it.
I don’t know of anything that uses this,
and space is the easiest key to press anyways.
tmux config goes in
Uh oh, another bespoke configuration language incoming…
$ cat >> ~/.tmux.conf set -g prefix ^Space
Honestly that’s all you really need.
From there you can use:
c-spc cto make a new terminal in a new tab
c-spc pto go to the previous tab
c-spc nto go to the next tab
c-spc "to make a new terminal below
c-spc %to make a new terminal to the right
c-spc oto focus the other window
One more keybinding is worth having:
prefix space to go the previous tab.
I also bind
prefix control+space since sometimes I haven’t let go of the control key.
bind Space last-window bind ^Space last-window
You can add these to your tmux.conf and relaunch tmux
or activate it manually with
tmux source-file ~/.tmux.conf,
or you can enter commands using tmux’s command mode.
To get the command mode prompt, the keybinding is
Enter your command and hit enter, and it’ll be applied. That’s all the tmux config file is doing, executing each line as a tmux command.
One useful keybinding is reloading the ~/.tmux.conf into your current tmux session, so you can edit ~/.tmux.conf and reload it without having to restart tmux.
I put this under
prefix r. Since I split this up onto multiple lines, I have to escape the newline with
\, and since it takes multiple commands (I first source the config, then display a message), I put a
\; between the commands.
bind r \ source-file ~/.tmux.conf \; \ display "Reloaded ~/.tmux.conf"
Add these to your ~/.tmux.conf for vim-style hjkl pane movement.
bind h select-pane -L bind j select-pane -D bind k select-pane -U bind l select-pane -R