Developer Productivity

Directories with tmux



Developer Productivity

Check out a free preview of the full Developer Productivity course

The "Directories with tmux" Lesson is part of the full, Developer Productivity course featured in this preview video. Here's what you'd learn in this lesson:

ThePrimeagen discusses the problem space of navigating directories, fuzzy finders, specifying directories in tmux, and switching clients. How to specify a command, open the manual, and how to read the manual is also covered in this segment.


Transcript from the "Directories with tmux" Lesson

>> And then lastly, of course let me ask this question. Have we solved this problem? Really, have we solved it? The answer should be no, we haven't solved it. Cuz really when I have to press prefix W and like scroll through all these. Are we still playing where's Waldo?

Yes, we are. But now we're playing in a linear fashion which is almost worse than any other way. So I think that in some sense we've actually made the problem a little bit worse. maybe a little bit more visible, a little easier to see what you're looking for, but nonetheless, I think it's a little worse, right?

It's not what I want. I don't want the heartburn cortisol, inducing moment that I'm sitting right here on my screen. I just want a nice Tmux. Nice simple terminal experience. So we're gonna take it to the next level. Yes, once again, I am an artist. I can draw lines that are incredibly straight.

I'd even see one person comment on how beautifully straight this line is. I'm a little hurt. I'm not gonna lie to you. I expected at least a few praises of line straightness there. That's freehand okay? Free hand. All right, let's create a this [LAUGH]
>> It's very nice.

>> Thank you. Thank you everybody. I trained many years Juilliard. So I'm gonna talk about what I want to do or how I would solve this problem, particularly. This is how I think about the problem is that I have three places in which code may exist. I have it in my home directory, right?

I have my dot files repo right because that's where store is. That's where I store into my home folder. So therefore I have a folder on my home directory called Dot files. I also have my Ansible folder there. Then on top of that, I have personal, right? Personal is kind of where I have all my personal projects because, I dont know, I call them personal why not?

It feels right okay, and that's also right off my home directory. Then on top of that, I also have my work directory. Now I did mix work with pleasure or personal actually, they're both on the same machine, but nonetheless, they're right there. So these are really the three places in which I want to navigate to quickly.

Anything else could be a little bit smaller blades, E prime can use a lot. Let's see I just self promoted. Where is that? Is a 9. I'm still out. I don't even know where that can you read that. I don't even know where zoom is. Zoom is somewhere.

So instead of comment, something about me even being a better GIMP user, I'm very excited. I'd like to know this GIMP tip. All right, so this is kind of an idea right here. Every one of these folders that exist right here, every one of these folders that exists at each one of these levels are likely a git project or a folder I want to navigate to as quickly as possible.

Obviously, I don't wanna navigate to somewhere really deep in here, right? I don't need to go to the node module folder somewhere deep down. Nodes module nodes module that weird thing that happens with node modules. Like those are the folders that I'm super concerned about. Right? Those are the places I want to get to immediately.

And on top of it I love fuzzy finding for those that don't know what fcf or fuzzy finding Fcf is a specific fuzzy finder it just stands for fuzzy finding right? A Fuzzy Finder. If you don't know what that is, or the best way to kind of say it is that have you ever used Ctrl p in VS code if that's more familiar to you Ctrl P brings up all of your like files right and you can start typing and it finds the file with a few keystrokes, right?

That's a fuzzy finder. It means you can type a partial match to a string and return to you all the strings in some sort of sorted order. That makes sense. FCF has a lot of options, blah, blah, blah. But it's just a fuzzy finder, it's good to know this is very, very good to know.

All right, so I want to be able to take these two things and I want to be able to create a Tmux experience out of them right? I want to take all these folders right here, and I wanna be able to navigate to them instantly and I want to filter them by FCF.

So that is what I want to create and we're gonna create that right now, because I want better, faster, smoother navigation. All right, that seems about right, right? So we do know a command, right? We did walk through this command earlier. We can create a session and we can name it, we can detach it.

Awesome, right? It's beautiful. It's exactly what we want. But did you know, I know, my goodness, you can create a new session and you can even say, hey, this is the directory I want you to go to, right? So we can actually even tell it what directory to go to with -c.

We can create a new window with a directory it should go to. And we can also call switch client switch client will switch to a new client and it uses this -t parameter. Now the -t parameter, it will put it on switch client what it would effectively it does, it allows you to put in a session name.

Now I only ever use session name but you can even go further and do window name and pain number. So you can really give it like a really targeted string to jump to. And so if you name your Windows as well, you could even like fuzzy find into that you could list your sessions and then fuzzy find the cross it and jump in if you have really well named session in Windows schemes, it's pretty darn cool.

But I tend to just do session name foobar, right. So right now just kind of show it to you there's bar that's one of the sessions name is bar. So we're in food, right now so I can go Tmux. Switch client, no, I didn't spell that right at all.

And then do T and go foo right? And by doing that, we are currently in foo, I thought I was in bar. So now instead tricking you guys making sure you're paying attention and we press bar and we jump over to bar. So look at that, I programmatically switched sessions.

So we were like, okay. We have a lot of the tools here to create this style of navigation, right? We know that there's commands that exist, that we can do this with, we know what folders we want to do it, and we know that we want to fuzzy finder to be able to help us.

So there's like kind of a lot of things going on here. And lastly, there's another command that I have right here that I, we don't need this time. But we're gonna need pretty near or you may want soon is you can also include a command right here. So not only can you create a new window with a name, you can also say hey, run node js whatever, right?

So you can actually tell it to do something. And lastly, always read the friendly manual. I believe that's what that abbreviation stands for RTFM always read the friendly manual. It's very important to do that. And so man tmux actually has a lot of information inside of it. If you're not familiar with man, which stands for manual do man it will tell you actually how to read a manual.

And what it means, what each one of these numbers mean along with it, it'll even tell you like, bold means type it exactly as shown. Okay. So let's go back to tmux man, look at that. This means type it exactly like this tmux. It actually gives you a lot of information and once you read through the man's manual, it makes a lot more sense reading manual pages.

They're actually they're very, nice and T mux is is particularly nice because it has like everything in it. You're confused at how switch client works. Well here you go. Here's every single option, all of it. Here's the alias that it's also known by, here's everything that can possibly do.

It's very, very nice to learn these commands using this little manual page. Always recommend reading the friendly manual

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now