Getting you started with tmux
For Mac, you can install tmux using a package manager like home brew. Simply run the command:
brew install tmux
You should also install tmuxinator so that you can use automated scripts to spin up TMUX
brew install tmuxinator
Once you have tmux installed, you will want to reconfigure some of the default keybindings. By default, all key bindings in tmux are prefixed with C-b
(Control b). This prefix is a bit arkward and not on the home row so we are going to the prefix keybinding to C-s
. Follow these instructions:
- Run
./setup.sh
- Save and close the file. Run the command
tmux source-file ~/.tmux.config
Addtionally, we are going to remap our caps lock key. The caps lock key is a valuable piece of real estate on the keyboard. The only question is whether or not to remap it to escape
or control
. In this case we are going to remap to escape
. On Mac, this can be done by going to System Preferences > Keyboard > Modifier Keys
.
You can start your tmux session manually by typing tmux
(use tmux kill-session -t {session_id}
to remove your session).
OR you can use our TMUX preset environment. You will need to set your PROJECT_HOME
environment variable for the tmux session to initiate in the correct location Run
PROJECT_HOST={repo_path} tmux start {tmux template}
We currently support the following tempaltes:
dev
In order to use TMUX, you and your pair must be on the same machine. This means that you can either setup a machine to work from in AWS, DigitalOcean, etc. or you can enable your machine to accept remote connections. Here is how to enable your machine to accept remote connections.
Edit the following file to make PubKeyAuthentication yes
/private/etc/ssh/sshd_config
Restart SSH on your Mac:
sudo launchctl stop com.openssh.sshd
sudo launchctl start com.openssh.sshd
You will also have to enable Remote Login
in System Preferences > Sharing
.
tmux
- start a tmux session
C-s
- prefix key
C-s %
- split window vertically
C-s "
- split window horizontally
C-s o
- switch between splits
C-s 1
- switch to window 1
C-s w
- visual switch between windows 🔥
C-s L
- switch between sessions
C-s <Space Bar>
- switch between layouts 🔥
C-s <Esc> <Arrow Key>
- resize split in a direction
tmux resize-pane -R 10
- resize the pane to the right by 10
tmux resize-pane -L 10
- resize the pane to the left by 10
tmux resize-pane -U 10
- resize the pane to the up by 10
tmux resize-pane -D 10
- resize the pane to the down by 10
These keyboard shortcuts were added to our tmux.config
file from a variety of community sources. See the videos below for more information!
C-\\
- Switch to previous window
C-f
- Focus the test runner
If you VIM coloring is not showing up in TMUX, then past the following command into your ~/.bash_profile
. It may fix it.
export TERM=xterm-256color
Excellent video by Chris Toomey at Thoughtbot about Tmux VIM Integration.