DEV Community

Cover image for Why I *love* TMUX

Why I *love* TMUX

Antonin J. (they/them) on January 28, 2020

Tmux is one of those utilities like VIM. Somewhat archaic, somewhat difficult to learn, but immensely powerful. So powerful in fact, that it's hard...
Collapse
 
patryktech profile image
Patryk

Tmux is the best. I usually have one open terminal tab per project I am currently working on, and tmux in there with a 4 pane split... One where I run docker-compose up (without daemonizing, since I often want to kill / rebuild / restart containers e.g. when changing dependencies), one for git, one for bash inside my python / Django container (for migrations, startapp, pytest etc.), and one for my node.js container (for jest, yarn add ..., etc.)

My favourite thing is to also use a drop-down terminal (yakuake, as I use KDE, but you can also use guake for Gnome). Then I can just toggle my terminal with F12, and easily switch from the terminal to VSCode or Chrome, and vice-versa.

Collapse
 
antjanus profile image
Antonin J. (they/them)

I've seen that setup! One of my colleagues (maybe 2 actually?) sets up a grid of terminals that run everything that you might want to glance at and then edits in one big terminal.

I'm not a huge fan of drop-down terminals but I guess that's because the terminal is my entire workspace -- including editing.

Collapse
 
patryktech profile image
Patryk

I'm not a huge fan of drop-down terminals but I guess that's because the terminal is my entire workspace -- including editing.

Yeah, it would probably annoy me if I used vim for entire projects. I only use it for quickly editing a handful of files, or on remote servers.

Collapse
 
waylonwalker profile image
Waylon Walker

Tmux is so scriptable and customizable. Thats my favorite part of any terminal application really. My favorite shortcuts are my hotkeys for splitting, windowing, and navigating new windows. I closely mirrored the existing commands with alt instead of c-b.

alt+s - split
alt+v - vsplit
alt+c - create new window
alt+n - next window
alt+p - previous window

alt+[hjkl] - go to [left,lower,upper, or right] split

This makes it super quick to have vim open and gatsbt develop like you mentioned to jump between running servers, a shell, and vim.

Sadly copy and paste support on wsl is atrocious. Makes it hard to paste in something a team mate sent in chat.

Collapse
 
antjanus profile image
Antonin J. (they/them)

oooh, I like that alt thing! That didn't even occur to me, I got so used to the Ctrl+a mapping that many tutorials suggested when I started early on that I can't imagine doing things any different way.

Yeah copy/paste no matter where is a pain in the ass. I'm thinking of using the tmux-yank plugin that's supposed to handle copy/paste on all platforms including via SSH and WSL.

Collapse
 
waylonwalker profile image
Waylon Walker

Two keystrokes is ok for single commands, but multiple in a row is a pain. For instance checking on a server running in an adjacent window and getting back is a simple alt+n+n.

My first post on Dev walks through replicating my alt key setup from tmux to vscode dev.to/waylonwalker/keyboard-drive.... I honestly use vscode mostly for copy and paste. Every time I go to use tmux I end up pairing with a team mate an thier like what is this you cant even paste properly here. I have my hotkeys setup so similarly that I can switch between them comfortably.

Collapse
 
idrisrampurawala profile image
Idris Rampurawala • Edited

Tmux is an ideal solution for me on remote servers, where generally we are are dealing with multiple commands and paths to different software/tools. Also, viewing multiple logs in parallel for resolving issues.

Collapse
 
jay97 profile image
Jamal Al

Unfortunately, it does not support serial communication like screen does.

Collapse
 
antjanus profile image
Antonin J. (they/them)

ooh, I'm not super aware of that. What does that mean for usability? Or, when do you need serial communication?

Collapse
 
jay97 profile image
Jamal Al

Some devices support the ability to configure them through a serial port (its like sshing into ur router) or URAT port. Although it’s not a big issue because thankfully there are other ways to work around this, it would’ve been nice to have by default.

Collapse
 
chiptus profile image
Chaim Lev-Ari

Thanks for writing this. Very interesting, I'll have a look. Any link for a beginner tutorial?

Collapse
 
antjanus profile image
Antonin J. (they/them)

I started using Tmux almost six years ago and can't find the original article, unfortunately. And none of the current guides are to my taste.

I'd say, find a guide that helps you install it locally, and then peruse youtube for a more visual guide. Cheatsheets are also useful

I started on a series called "How I Work" where I cover how I use tmux for work. You can kind of see the tmux flow there and I also linked to a cheatsheet as well as my dotfiles there.

Collapse
 
flrichar profile image
Fred Richards

Tmux is like jazz. The music never stops playing.

Collapse
 
batorshikh profile image
Bat-Orshikh

Hello,
How can I configure copy past key bindings to my OSX system clipboard?

Collapse
 
antjanus profile image
Antonin J. (they/them)

solid question, looks like searching for it yields a few different answers. I'll be honest... I haven't set up copy to system clipboard because I rarely use it (I tend to copy/paste between panes/tabs).