Tmux: A terminal multiplexer

Tmux: A terminal multiplexer

Introduction

In the rapidly evolving world of information technology, a key focuses is efficiency. Tmux, a terminal multiplexer is an awesome tool in this context.

Tmux enables the operation of multiple terminal sessions or panes within a single window. This feature is incredibly useful for remote work and server management and facilitating effortless multitasking. I can see it be a really useful tool for developers, system administrators, and IT experts alike who all need a responsive and powerful command-line environment. Its standout feature is the ability to detach and reattach sessions without disrupting ongoing processes.

How to use it

I will showcase some examples of what you can do with tmux but I will also link to a youtube video here from NetworkChuck who has an incredible video showing of some of the powers of tmux. I really enjoy a lot of his content and his style of videos. Link to his youtube channel in the reference section will be provided. I will also provide a link to the tmux cheat-sheet where you can find all the available commands here and in the reference section.

But now, which commands do I use the most and how do I apply it as a Cloud Engineer working with Infrastructure as Code? Here is a pretty standard workflow for me.

My use case for tmux, helping me write good commit messages

  • I start my terminal of choice and create a new tmux session: tmux new -s demo

I will obfuscate my computer name in all images. Not sure that it really is sensitive information but I would rather not take a chance - but now you know :)
  • I will hit CTRL + B and then SHIFT + 5 to go into splitscreen mode
  • I will then in the new pane switch into my directory, list my files and open visual studio using code .
  • In here I will make some changees to my Terraform configuration files because I wish to create a new resourcegroup in my Azure Environment that will host some new resources for me. I will interact with git on the left pane and az CLI & terraform on the right pane, it is just how I like to do it:
  • I switch panes by pressing CTRL + B + Q this displays the number of the pane, press the number of the pane that you want to switch to, so for example CTRL + B + Q + 1 switches to the right-side pane
  • I will make my changes, deploy my resource group and now it is time for me to commit my changes to my Azure Devops repository
  • This is where I have found a huge advatange with tmux in my workflow helping me write my commit messages by being able to have both what has changed in my different files whilst writing my commit message
  • In this example it is quite easy to explain in my commit messages what has happened on a single line but sometimes you may want to write more in-depth information about your changes which you can do in commits under the main commit-header
  • In this instance whilst having Nano or Vim open and editing the commit message I can still see the results from git diff in my other pane which is a game-changer for me

Key Features and benefits in professional use

A key feature is its session management capability, enabling users to create, populate, and manage sessions that continue to run even when disconnected. In the examples above I am connected to Lindbergtech in a session called Demo but I can easily detach, leaving everything running the way it is with CTRL + B + D and start a new session. Once I want to return to the demo session with Lindbergtech I can type tmux a -t demo and everything is they way I left it. I can see all my sessions running using tmux ls in the command-line.

Furthermore, tmux offers window and pane management, allowing for a single screen to display multiple, distinct information panels, like I also showed in my examples above. You can tailor virtually every aspect of tmux, from key bindings and scripts to the interface's visual aspects, ensuring it aligns perfectly with their individual workflow needs and preferences. Don't like CTRL + B? You can change it!

Imagine running various terminals covering scenarios like log monitoring, script execution, and simultaneous management of remote servers. The session persistence feature of tmux is particularly beneficial for remote work, allowing users to maintain their working environment across different sessions, thereby minimizing setup time when resuming tasks.

Conclusion

Tmux is a great asset for any IT professional aiming to maximize their command-line workflow efficiency.

For those in the IT sector who have not yet explored tmux, it is strongly advised to investigate its full range of capabilities and consider incorporating it into their daily routine. Adopting tmux can lead to some gains in productivity and it is just really fun to use! See my reference section for helpful links.

References

Home
tmux source code. Contribute to tmux/tmux development by creating an account on GitHub.
NetworkChuck
Welcome to NetworkChuck! I LOVE Information Technology!! My goal is to help as MANY PEOPLE AS POSSIBLE jump into a career in the IT field through obtaining IT Certifications. I talk about Cisco Certifications, CompTIA, AWS, Microsoft...pretty much EVERYTHING in IT. As a CBT Nuggets Trainer, it’s also my passion to TEACH information technology and to make it FUN. If your goals are to obtain your CCNA, CompTIA A+, CompTIA Network+...I’m here to help you with that goal in any way I can! *****Interested in Sponsoring NetworkChuck? Email chuck@networkchuck.com
Tmux Cheat Sheet & Quick Reference | Session, window, pane and more
Master tmux with the comprehensive cheat sheet: session management, examples, installation guide and more for the ultimate terminal multiplexer.

About me

About me
If you have landed on my page you will have already understood my passion for tech, but obviously there is more to life than that. Here I will try and outline a few of my other hobbies. Strength training I am a person who loves to move around and challenge