If you're into web- and software development it's likely that at some point you've opened a terminal.
Since one terminal is often not enough tabs may be a useful addition. But at some point not even tabs are enough; switching between tabs which all belong to the same project is just annoying - but as of today a lot of projects require multiple processes to be run; one for running your application, one to watch log files, one for running commands on the fly and eight docker containers where you know what at least five of them are used for.
But having a tab for every single process can become overwhelming pretty quickly.
And restarting your computer means re-opening all your tabs. That's no fun.
tmux, a terminal multiplexer
To compensate for this tab insanity you can use tmux. tmux is a multiplexer which allows for multiple terminals controlled from a single screen.
It's available for Linux and OS X (via
brew install tmux). It might be possible to run tmux on Windows - but I have honestly no experience with that.
What it does
tmux offers a hierarchical set of features regarding terminal control; sessions, tabs and panes where a session can has multiple tabs and a tab can have multiple panes.
A very important feature tmux provides is the support of plugins. My absolute favorite plugin (and an absolute must-have in my opinion) is tmux-resurrect which makes it possible to persist our tmux configuration through system restarts.
Last but not least it's highly customizable in it's appearance which allows for some personal touch.
How I use it
To get an idea at how this can be used let's take at a look at how I use it:
I use two different sessions, one for personal projects and one for work. My personal session (named
dev) has different tabs for all my private projects. The tab shown in the screenshot is my blog and has four different panes: one for starting the Docker container for Commento (during development I don't need the
-d flag to run the container in the background), one for Gatsby, one for Ghost-related commands and one for "everything else".
Every time I start my computer and open the terminal the first thing I do is to reload my tmux configuration, jump to the tab with the project I want to work on and I'm ready to go.
If I want to work on an other project all I need to do is to open it in my IDE and switch to the proper tab in tmux. All tabs are properly configured for their respective project - there's no need to manually
cd into multiple directories using multiple tabs or terminals.
tmux is mainly controlled by shortcuts. These shortcuts use a specific prefix (
ctrl+b by default) followed by the shortcut you want to execute. My personal most used shortcuts are:
ctrl+b + wto switch between sessions and tabs
ctrl+b + arrow keysto switch between panes
ctrl+b + cto create a new tab
ctrl+b + ,to rename a tab
ctrl+b + rto restore my sessions (via the resurrect plugin)
ctrl+b + xkill the current pane
ctrl+b + |split pane vertically (custom, default is
ctrl+b + -split pane horizontally (custom, default is
A lot of people like to change the prefix key to
ctrl+a instead of
ctrl+b - but that's up to you. A useful cheat sheet with shortcuts can be found on GitHub by MohamedAlaa.
As you may have noticed my tmux looks slightly different than the default greenish matrix-like look. By having a
.tmux.conf file in your home directory you can customize many things like the look, plugins or some general settings.
.tmux.conf can be found on GitHub. Let's talk about some neat configurations within this file:
set-option -g set-titles on set-option -g set-titles-string "#S / #W"
This will cause your window title to follow equal
<session name> / <tab name>.
By default the shortcuts for splitting up panes are
". I've never been able to tell the difference and hence simply rebound these to:
bind | split-window -h bind - split-window -v unbind '"' unbind %
Which is way easier to remember;
| splits the pane vertically,
Liked this post?
Glad to hear that! Get the next one delivered right to your inbox.
Free. No spam. Unsubscribe whenever you want.
I make stuff. Mostly functional, occasionally shiny, stuff.