Coffee Coder

Shubham Jain's Weblog

Why Should You Use Tmux?

| Comments

Terminals are an essential place frequented by developers in their daily use. In contrast to GUIs, command line gives you more folds of power and transparency when you dealing with a complicated tool like git, or when you need to pull off some networking stats using netstat. In this blog post, I’ll explain why tmux is a great productivity enhancer when working with command line.

What is tmux?

tmux or terminal multiplexer is a simpler version of GNU screen, both of which are tools to split, combine and create terminal windows. Yes, that is indeed similar to what terminator does but guess what, you can’t run terminator on SSH, can you? but that is not the selling point here. tmux is command line based tool which is very easy to use and in fact for any beginner, a little primer should be enough to start using it to its full extent.

Why should one use tmux?

I use tmux even when I am working locally. In comparison to terminator, tmux offers a significant advantage by freeing your hands from needing to get to the mouse. When working over command line, anything other than keyboard is an interruption and costs in your work flow. Just like tabbed browsing, multiples panes and windows allow you to do many things at once and with tmux you are encouraged to exploit them more effectively. Other significant features include :

  • You can use it over SSH.
  • You can share a session on SSH with use of sockets.
  • You can de-attach and run multiple sessions.
  • Using tmux-sessions you can dump and restore sessions after boot.

In a better combination of both tabbed terminals and tmux, one can use separate tabs for both local and remote machines and tmux can be used inside each tab, helping to avoid confusion between the two.

A typical use-case scenario

A typical usefulness of tmux can be illustrated when you are debugging and internal server error over SSH. My normal mode of operation in such cases was to keep switching directories using cd - alternating between adjusting configurations and viewing error logs. Using tmux this process was a lot simpler since all you needed was to switch tabs. Even better, you could use watch command in a separate pan to constantly output the tail error_log to console, thus, saving your time and watching constantly switching directories.

Comments