Transcript from the "tmux" Lesson
>> Let's dive into tmux. For those that don't remember where we're at, including myself, let's just jump back to the terminal. Remember we got Dan talking about alacritty guy, Kitty guy. And then what are we gonna talk about, talked all about tmaxing that we're gonna be testing. Terminal multiplexing we're gonna really solve that problem where there's all those terminals everywhere and you just have this problem of navigation kinda getting there.
[00:00:20] I really want to kinda provide something that is a much better path and then I wanna kinda take it up another level beyond that and actually make it so that you can start crafting and customizing it into a solution that you want for yourself. Not just simply something that I think is good, but a way for you to see how to take it much much further.
[00:00:40] So I first thought I'd just at least start off with just a simple example. So here's my screen. I'm just in a terminal that is it. Nothing else is on my screen. Well, there's technically little zoom widgets. You can see the zoom widgets I can. It's very bothersome, but I can press a quick button I'll get a nice fuzzy find, hey, here's all the folders in my home, in my personal and in my work directory.
[00:01:01] I can then go to my say my favorite personal project refactoring, and I can press enter, I now have a session created. I'm in the refactoring directory, everything's looking good, I can then launch them. And here I can have another window here, run some sort of servers. If I really, really, really want to over here, they're just all there.
[00:01:19] They're all ready to rock. That's awesome. I can go back here. Great, I think close things down, open it back up. Just jump right back in. We're bright back exactly where we were nothing has changed. Yes, even on that other one, it still has all the nonsense over there.
[00:01:32] This is beautiful, right? It allows me to always be really like tightly bound to my system. I don't have to worry about things getting lost. I can really jump to where I want to, if I want to jump to another project. There we go with them with me.
[00:01:43] I can go to my work project, my work project, my work project, right? I can just keep jumping around. I can go back and forth between them ultimate file style. I have everything on a very short fast leash for me to be able to go exactly where I want to go with very few keystrokes.
[00:01:58] And more than just that, I can also, say, open up something, with no JS, something I always forget, the splice interface. There we go. Okay, yep, that's how you do the splice interface. Awesome, I'm back in my project, right? I have very fast access to enter information, and it's very optimized for my usage.
[00:02:14] So that is really what I wanna talk about today is just crafting and creating a better terminal experience to really kind of move out of the way some of the silly things we do as developers. Specifically just slow navigation looking up information that can be looked up differently.
[00:02:32] That kinda stuff, all right? So we're gonna talk TMUX. That's really the primary thing here, there's some alternatives to TMUX. If you use a Lac ready, I believe it has a multiplexer built into it, I don't use it I like TMUX. Like I said it works everywhere. It's how I want it to be, I assume alacrity works everywhere but I just stick with TMUX.
[00:02:52] So here we go. I wanted to share this picture I thought this was one of the I thought this was one of the best pictures yet to describe TMUX. It seems to be the most accurate. Now obviously if you don't know what TMUX is you are not too familiar with the terminal, this may feel overwhelming.
[00:03:06] But really let me just kinda slowly walk you through this to the point where, it will feel really easy to understand. All right, so at the very base of everything, there is a TMUX server, this is the thing that runs. Every server has one or more sessions. Every session has one or more windows.
[00:03:25] Every window has one or more panes. It's fairly straightforward. Just in this picture, you can kinda see that but really, what's a server? What's a session? What's a window? What's a pane? Let's kinda go through all of that at once. So I'm gonna jump over here to GIMP.
[00:03:41] We've had all of our fantastic drawings. And let kinda write some things about that. Actually, I'll write that here in a moment. Let me first go down first. So, install tmux first. Okay, if you want to join in on all this, I'll give everybody a moment to install tmux.
[00:04:00] I think this is really important just to at least minimally use it. Cuz when you first use tmux, you'll probably be a lot like me. You'll start it and go. I don't know what this does, I don't get it. I'm pressing funny buttons. This is weird, I don't wanna use this ever again.
[00:04:14] And that;s kinda what I did, as I learned a couple quick things and that was it and then I never touched any of them. I felt confused and disjointed and then all sudden I took some time learned about it and it became really obvious what was going on.
[00:04:28] Now I love it. Let's start using tmux. Now to start using tmux, you just need to type the word tmux. It should be pretty easy so I will join you with it. Let me just go like this. All right, here we go. I'm gonna just start using tmux, just with you.
[00:04:45] So I do this tmux boom. What just happened right there. Obviously not a lot of things just happened right there. Yours is gonna look slightly different than mine. If you just for the first time ever installed it, you probably have green down here as opposed to my more pleasant blue.
[00:05:01] Just the way it is. So let me just kinda explain to you what just happened there. So first off, when you typed in tmux, you sent obviously, remember we talked about the terminal. The terminal is the thing that are taking in all your keystrokes and making everything happen.
[00:05:15] Your shell interpreted, called the right program, made sure everything happened in that program, then launched. That's tmux, right? So we sent all these keys over through your terminal, blah, blah, blah, blah, blah, and tmux went, all right, I'm gonna run, is there a server running? Remember at the bottom of our diagram, the server was the largest portion.
[00:05:31] It's gonna say, hey, there's no server running. So let's create a server, right? And then after that, it's gonna go, all right, since we are now doing a new session or now since it's a new command will create a new session, which we need to add a window to this one session which we need to add a pain to the, this one session.
[00:05:48] And so that's exactly what you're seeing here right now is a server with one session, with one window, with one pane, it'll become more obvious as we start moving and doing things but just kind of keep that in mind. We've just created a singular thing. And to really drive this home.
[00:06:05] Yeah, what do we do next? Well, let me show you what we do next. Well first, let's exit. So easy way to exit Ctrl D, Ctrl D actually sends an end of file, note our end of file into the input stream. And a file is the end of what needs to be running and so then tmux goes what, this pain can be closed.
[00:06:25] There's no more pains in this window. This window can be closed. There's no more windows in this session. This session can be closed. You need to leave tmux now. Thank you very much for being around here goodbye, whole thing closes and I bet if we check there won't even be anything running.
[00:06:40] All right, just a little side note whenever you see this syntax in my mark down or if you're watching from right here because I don't think the website is still up C-D means ctrl D, all right? Just so you know. So C- anything, is ctrl plus that character.
[00:06:58] So the example we're using right now is CD which is just end of file, throw right in the STN and but, so let's start using tmux, all right? Now I did wanna be a little bit of a warning here. My tmux experience will be slightly different than yours because I have that RC changes a few things.
[00:07:18] So all the commands will be the same, but some information might be slightly differently displayed for you than for me. And then second, why am I showing you all these commands? It's a little weird. Why am I gonna go through all the things we're gonna go? Well a big thing is is that you need to know these commands not because it makes you a better hacker, you're more awesome.
[00:07:37] But in reality, it allows you to understand that tmux, though interactable with a bunch of keyboard shortcuts is also scriptable. Meaning that you can actually write out these commands and create things you want. Not just what is currently available. I think that's a really important kind of aspect of tmux.