DEV Community

Connor Bode
Connor Bode

Posted on • Updated on

Multiple commands running in a single shell (windows in tmux)

I'll just jump straight to it. Sometimes, your app needs a lot of commands running.

You're probably running babel on your Javascript, using react-native start, running gulpfiles and gruntfiles and webpacks and whatever other new JS build systems there are, and you've got your test suite running and there's some CSS pre-processing and..

The list goes on. You're probably running a lot of commands that just need to.. run, and sometimes you'll need to check their output.

Does that mean you need a million terminal windows open? No. You just need one, and a terminal multiplexer.

Enter tmux.

tmux is the tool you need. It allows you to do all sorts of things in a single shell. We'll cover the absolute basics here, but there's a lot more to know:

  • To start, Ctrl-b takes you into the command mode. The next bullet points all require you to be in command mode.
  • c creates a new window
  • n takes you to the next window
  • p takes you to the previous window
  • & deletes the current window

In each window, you can have a command running (you can actually run more, but you need to know more about tmux). You can only view one window at a time and you use the commands above to cycle through them.

That's all for now!


Want more tips on tmux, VIM, and general productivity in Linux? Follow me here on dev.to or hit me up on Twitter @connorbode. I can also be found on the web at matix.io.

Top comments (4)

Collapse
 
ferricoxide profile image
Thomas H Jones II

Out of curiosity, what made you choose tmux vice screen?

Collapse
 
connorbode profile image
Connor Bode

I didn't make a choice, when I looked to solve my problem tmux was the solution I found. Didn't discover screen until later, at which point I was comfortable with tmux.

Collapse
 
ferricoxide profile image
Thomas H Jones II

Cool. I've been using screen since 1989. I'm always interested in new-to-me tools and know a lot of people use tmux, but haven't seen anyone post that "this is why you must switch" capability-note. Occasionally, I like to ask, in case the tmuxer in question has used both enough to be able to tell me "this is the differentiator that was key to me." =)

Thread Thread
 
connorbode profile image
Connor Bode

Yeah I don't think there is a difference really, I think they satisfy the same goal equally well.