Using Tmux & Cygwin together is the best console combination on Windows, if you ask me. I’ve been using this setup for over a year now, and my productivity is measurably better, my workspace more organized, and it looks cool to boot! I’ve also converted most of the developers at my workplace to this setup.

Don’t know what Cygwin is? It’s a Linux-like environment for Windows, allowing you to run most Linux packages natively on Windows. It also includes MinTTY, a terminal emulator (when I speak about using Cygwin as a program, I’m really talking about MinTTY). I have a great blog post on how to get started with Cygwin, so make sure you check it out!

Tmux is “terminal multiplexer”. Put simply, it allows you to have multiple tabs, multiple panes in those tabs, and sessions than don’t go away when you close MinTTY (you can even save them and then restore after a reboot, using plugins!).

In this post, I’ll explain how to setup Tmux with Cygwin, how to create some more sane keyboard shortcuts, and list some of the commands you might be most interested in.

If you’re a screen user, and not sure if/why you should change, check out my post on Tmux vs Screen!

Getting Setup

Step 1, you need to install Tmux. I’m assuming you’ve already installed Cygwin (if not, check out my blog post to get setup). Re-run the Cygwin installer, and select the “tmux” package for installation (it’s under the “Utils” category).

Step 2, open the MinTTY options dialog (right click on the titlebar), and go to the “Mouse” category. Ensure “Default click target” is set to application.

Step 3, create a new file called .tmux.conf in your home directory. I recommend going with the one I use to start with, and then customize it over time.

Step 4, launch tmux (using the tmux command).

You are now ready to start using and customizing tmux!

Prefix Operator

Before going further, it’s important to understand how the prefix operator works. Tmux has a customizable prefix sequence (using my file, it’s ctrl + space ), and you must type this before typing the next key.

For example, when creating a new tab, it’s prefix + c . This means you first hold down the ctrl key, then the space key, then you release both (just like copying and pasting). Now press the c key. By pressing the prefix sequence first, you’re entering command mode.

Windows & Panes

Tmux supports tabs (they are called windows though), as well as splitting a tab into any number of panes (both horizontally and vertically). Normally, commands in Tmux are prefixed with a prefix command sequence, but my tmux.conf file adds a few unprefixed commands for modifying windows & panes, as I use these operations so often.

Your tab/window bar is at the bottom of the screen. Tabs are numbered, starting at zero. You should have a single tab open to start with.

To create a new tab, type prefix + c (prefix being ctrl + space ). Once in your new tab, you can set a name for the tab using prefix + , (just enter the new name a press enter ). Naming tabs is the key to staying organized! To close a tab with only one pane, type prefix + x . To move a tab left or right in the tab bar, using ctrl + alt + left/right .

Now, onto panes! To split the currently active pane horizontally, type ctrl + left/right (direction indicates to which side of the current pane the new pane will be created). To split vertically, use ctrl + up/down . You can repeat these commands to create all sorts of pane layouts:

Note: I’ve resized my panes using mouse mode controls in this example (just drag the tab border to resize).

To navigate your panes, use shift + up/down/left/right . The active pane will be highlighted with green borders on all sides:

If you’ve split your window up like I have, but you want to focus on a specific pane temporarily, use prefix + z to maximize the currently selected pane (and repeat to reverse).

prefix + x will close the currently selected pane.

Copying & Pasting

Copying & pasting is my biggest gripe with Tmux. It used to be a lot easier, but recent changes to mouse mode have made it unnecessarily difficult. There is a pull request open to fix this at the time of writing, so hopefully it gets accepted.

As it stands, if you want to copy less than a page’s worth of data, it’s trivial. Scroll as needed, highlight the text (it should highlight in yellow, to indicate Tmux is handling the copy operation), and release the mouse. Nothing should be highlighted now. Press prefix + t to copy. The explanation here is that highlighting text and releasing the mouse will copy your selection into a buffer, and then prefix + t will copy the buffer into the clipboard.

If you want to copy more than a page, you have two options. Option 1: resize the font in MinTTY (using ctrl +/- keys) until everything fits on screen at the same time, then follow the directions above. Option 2: Type prefix + [ to allow the cursor to be moved. Navigate using the arrow keys to wherever you’d like to start your selection. Press space to start selecting, and then use the arrow keys to complete your selection (it should highlight in yellow, just like when using mouse mode). Once you’ve got your selection, press the enter key to copy it into a buffer. You can now type prefix + t to copy the buffer to your clipboard.

Customization