Tmux in 100 Seconds

444.92k views684 WordsCopy TextShare
Fireship
Learn the basics of Tmux, an open-source terminal multiplexer that can juggle multiple terminal sess...
Video Transcript:
t-mo an open- Source terminal multiplexer that can juggle multiple terminal sessions from a single window it was created by Nicholas Marriott in 2007 after becoming frustrated with the limitations of G screen and is offered under the more permissive BSD license as you can see here I'm building some crappy software and I have a terminal window open for a web server one for postgress one for my engine X logs one for htop one for Nano and one for repel to say hello world it's complete chaos but things get a lot better if I run this t-x
command first which will summon this magic little status bar now I can take all these Terminals and combine them into a single window where they're organized in the status bar like an array I can easily navigate between them without ever touching the mouse to split them into panes both horizontally and vertically and can give each one of them a custom name and if I accidentally closed it all is not lost because the session is still running in the background also if you're constantly switching between multiple failed side projects it's timec consuming to manually resurrect a
bunch of terminal Windows to set up your environment a t-mo can be controlled with scripting to Define sessions programmatically with just a few lines of bash code we can instantly fire up multiple terminals for our project with descriptive names and fancy colors but you don't even have to do it all from scratch because t-mo has a bunch of pre-built plugins like resurrect will restore your environment after reboot or use power line to customize it in ways that would make even the most flamboyant peacock jealous to get started install it on any Unix like machine including
Mac OS Linux and WSL then open up a terminal window and start a new session go ahead and run any random process then create a new terminal window by hitting control Bravo let go then hit Charlie a new terminal is pushed onto the stack and we can navigate between them with contrl B followed by their index number we can also navigate with the arrow keys or split these terminals into panes with quotee for vertical or percent for horizontal pretty cool but oh no I just closed it but it didn't actually die it only detached from
reality if we open up the terminal we can run t-mo LS to list out all the active sessions when we find the one we're looking for we can reattach to it and get back to work what's really awesome though is that if we create a bash script we can do all this programmatically let's Define a variable for session name and then first check to see if that session already exists with the t-mo has session command if it exists then we can simply reattach to it otherwise we'll use the new session command to create a new
one with the initial window handling our text editor from there we can tell t-mo to CD into the project directory and run Bim just kidding we'll run Nano because it's far superior but now let's open up another window called server it'll CD into that same project and run some JavaScript slop we might also need a window to run a Docker container another one for the database and another one for logging that takes care of our windows but let's also customize the color and appearance and then finally we'll use select window to focus on the editor
first now open the terminal and run the script to work smarter and not harder this has been t-mo in 100 seconds this video is a part of my full Linux course which is available for fireship pro members if you want to learn everything you need to know about Linux and self-hosting your own virtual private server to try it out for free and use this discount code to upgrade thanks for watching and I will see you you in the next one
Copyright © 2024. Made with ♥ in London by YTScribe.com