Check out a free preview of the full Developer Productivity course

The "Shell" 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 and demonstrates the difference between the shell and terminal, gives examples of different shells, and suggests a shell to use. Having a comfortable shell can greatly improve the user experience while in a terminal.

Preview
Close

Transcript from the "Shell" Lesson

[00:00:00]
>> So, I did wanna also briefly touch on the shell. Now, I don't want to go very deep into this. Much like window managers, I don't wanna go deep into this. Cuz I actually find that your shell is not as important as where you can spend your time.

[00:00:14]
A lot of people just use what's available and that's that. If you're on macOSX, zsh, I believe comes already installed. You just use zsh, right? You may use My Zsh to have a pretty prompt, right? So, if you look at my prompt, it has like what folder I'm in.

[00:00:27]
I'm on, I'm in git, it shows me my branch, right? It gives me all those kinda nice pretty things in my prompt. You can set all those things yourself. Or you can use plugins, I just use plugins. It's just easier for me. I don't have to think about it.

[00:00:38]
And I don't really wanna learn the prompt language. That's just my lifestyle I live. Nonetheless, it all starts with the shell, right? For those that don't really know what the shell is. We'll get into that in a moment. I strongly suggest zsh. Just pick something, use it honestly.

[00:00:53]
In my personal opinion, don't spend a lot of time on it. Just get something you like, right? We've already gone through the installation process of zsh. So, I don't need to show you how I install zsh anymore. But what is a shell? Well, there's a guy named, I call him The Wizard.

[00:01:06]
His name is Las Smiles. He's like 70 years old and he streams on Twitch. But he frequently gets banned for showing movies. And so, he's currently banned right now, if I'm not mistaken. So, I have as a YouTube linked. But, he experienced computers. Like it just the rowdiest of days, right?

[00:01:24]
He has stories about how he had to like tried to save the server farm when he was younger. But they only had punch cards and he tripped and fell. And like his whole program, he actually has those stories, right? Just super awesome, but he had a really great explanation for what the shell is.

[00:01:39]
Cuz in my head, I always had this kind of specific thought process of what the shell is. And I was kind of wrong. Cuz a lot of people don't really know the difference between a shell and a terminal. So, at one point in life, there was terminals, literal physical terminals that had keyboards.

[00:01:55]
And then, there was actual servers that you time shared on all, right? So, if you wanted to run your program for class, for school, for whatever. You actually have something remotely that ran at all. And you just kind of were on your little terminal that sent things. The terminal just simply gets key input and displays output.

[00:02:11]
And it sends all the stuff over to something to be interpreted, do the system calls, run your program. So, that's really what is happening. And so, this little communication line existed at one point. But, in the olden days, when you say you sent over ls and you meant to do dash la but you sent over underscore la.

[00:02:31]
What would end up happening is go, wow, that thing doesn't exist. Your connections dead now, I don't know who you are, you screwed up, you can't be here. So, then you'd have to re-log in. Redo all that. And so, how The Wizard describes, is that, the shell is not a shell, around your computer, it's a shell around you.

[00:02:50]
It protects you from doing something dumb, right? It is a language that you can use and a way to interact with your operating system. Make system calls, start processes, do all that. And if you screw up, its gonna treat you really nicely. It's gonna say, hey, you messed up.

[00:03:05]
Here's some information about how you messed up. Don't worry, you're still logged in, everything is still fantastic. You're not getting destroyed. And so, I always really liked this kind of analogy between the difference, between a terminal. Really just a stupid input. It just runs a program, does input, does output.

[00:03:21]
And the shell is the thing that interacts with the operating system. And so, you can technically start a terminal and started off and say no JS, all right? So, you can actually launch a terminal in no JS, it launches the program. And then you can only interact with no JS.

[00:03:35]
And the moment you quit no JS, it will also kinda quit that entire session also. Your terminal will also quit because there's nothing left to run. It's done. And so, that's kinda the main difference between a shell and a terminal. And it's good to know these things. I didn't really know these things for a long time.

[00:03:49]
Is it super important I mean in our day to day life. It's not like super important to know these fine grained differences. But you should at least minimally know that. And so, to kinda really drive this home. Let me show you something kinda neat. So, what I'm gonna do is I'm gonna relaunch that docker instance.

[00:04:04]
Let's clear everything, I'll zoom in on just a little bit more to make it a little bit easier to read. And we're gonna go apt install zsh, one more time. It's gonna do all that. Yep, let's install just zsh. And so now that zsh is running, I'm gonna do this.

[00:04:17]
I'm gonna go zsh. So, when I press that, I want you to see the difference because the prompt changes. You'll see that I've logged, I have now started the zsh process. And I can go ps, ps is a way for you to do a lot of process stuff.

[00:04:30]
I'm gonna go, -o pid and ppid and look for everything that's running zsh. And it's gonna say, hey, there's one PID. It's ideas 98, its parent is 1, right? That's the shell that was launched when we launched docker. So, I'm gonna copy and paste, this just so, I don't have to do that again.

[00:04:50]
Actually, let's not do it that way. Let's go up here. Let's go back and yank that. There we go. All right, so now let's relaunch zsh and then let's relaunch that. Look at what happens here. The PID that we were on is now the parent to this PID, which is a new zsh, right?

[00:05:09]
So we can re-zsh it again and then we can redo that. And you'll notice once again, the PID that was the child before. The one that we just launched, is now the parent. And now there's a new one. So, the shell experience you can just launch over and over again within itself.

[00:05:23]
And you're still just launching a program. And when I type in things, it's like, hey, this doesn't exist. I could exit this, but I haven't exited zsh all the way. Because now I've moved up from 125 to 121. Accept that, now I'm likely in 98, right? I'm in 98.

[00:05:38]
And my parents want are the standard or the one that was launched with docker. Now, if we were to do the exact same thing, let's paste that in. You'll see, hey, there's no zsh running at all right? So, now we're kinda in the top level one that we've, that ran with docker.

[00:05:52]
I can exit that, now I'm out of docker. So, hopefully that kinda illuminates a little bit more. The difference between the shell and the terminal. I had one terminal that whole time. But I opened what, four separate shells all within each other. So, they are different and you can interact with them differently, right?

[00:06:08]
Shells can be great. There's a lot of point counterpoint. People will tell you, you're absolutely wrong. You're an idiot. You're whatever and then if you use the right one, you're based, you're awesome, you're blessed, you got all the right terms, right? So, people are gonna talk wild on the Internet about all the different bashes right?

[00:06:24]
Or all the different shells, so you got bash, zsh, tsh, bish, fish. Me personally, I'm like bish please, I'm gonna use zsh, okay. I'm not gonna be using bish, that's ridiculous. But, it's just because that's the one I wanna use. By the way, I made that meme on Twitter.

[00:06:36]
No one liked it. I thought it was really good. Okay, I thought it was really good, no like that one. So, I just use zsh and I, yes, I use OhMyZsh. Cuz honestly, I'm person that I love configuring things, I love making them better. But I also have limited time and so, I kinda choose where I want to spend my time.

[00:06:54]
Where I think I'm gonna have the most impact, on just my day to day life. So, this is one of those items that I just farm out to somebody else. So, I just use OhMyZsh, gives me a pretty prompt, gives me an easy way to add plugins. I don't really need to think about it.

[00:07:07]
Awesome, good to go. That's kind of, my lifestyle is that, not everything needs to be configured to the nth degree. Even though you can, so you really could. So, personal opinion, just choose anything. Learn about it a little bit. But honestly, go get good at core utils. Go get good at other parts of your operating system.

[00:07:23]
And take advantage of tools that are already built and are amazing, right? That's personal opinion about the shell. I don't think a lot of people have the same opinion. I'm sure someone eventually will make a YouTube video, saying why, what I said is very dangerous. Everything is very dangerous when it's someone else's opinion, so careful.

[00:07:39]
Careful with what you use on the shells. Anyways, apply what you learn. If you have an Ansible script. Once you just get zsh or fish or whatever you've decided, put that as part of your installation process. Get a docker container that is just a basic docker container. And see if you can create an Ansible process to install the shell that you want.

[00:07:57]
And make sure it works. Right, it's fun, by the way fun side note. When I did do this talk, I think I already said this, I can't remember if I did. But that zsh auto suggestions. I literally could not figure out why I wasn't getting auto suggestions. It took me like 10 minutes to figure it out.

[00:08:10]
And so, because I had the new docker container. It's cuz even though I've installed it before. It's so easy to forget all these little things. I'm like, why is my zsh slightly off? I don't get it. It's frustrating, all right. Anyways, that's all, that's I wanted to talk about window managers and shells.

[00:08:25]
I kept it really light because I didn't wanna spend too much time there. Like I said, I don't think there's huge. I don't think there's a lot you get to gain out of those ones comparatively to other topics.

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