Subtitles section Play video Print subtitles (bell ringing) - Now it's time to work on our shell access. So what I've always done prior to this video is use just the built-in terminal that comes with Mac OSX, and I kind of don't need very much more than that because I am not that sophisticated. I just type basic Git commands or node commands in there, but I have learned recently that there is a particular application called iTerm. Let me pull up the URL for that. And this is a Mac OSX terminal replacement. There are equivalent terminal replacements for Windows. I'll try to include some links in the video description when I get good suggestions. And you can see that it has a lot of extra features. It's free. I believe it's, I don't know if it's open source. That would be an interesting question. There's a bug tracker, and it is, it looks like it's licensed under GPL version two. Okay, great. So I encourage you to kind of click through and look at the different features. But really it's just has a lot of customization for searching, for hotkeys, for that kind of stuff. So it has more features. We'll see that as I use it. So I have that here. Now, something that I've always wanted, I look over other programmers and I see their console, and it's all like color coded. And if they use Git, maybe you don't know what Git is, but you're learning about it. It says things like you're in a Git repository and what branch you're in in that repository, just gives you information as you're going. So there's many ways to configure your terminal in terms of styles and transparency and color and features and what you can type. Something that I learned about recently is a shell. So by the way, this shell that it's running right now is bash. Bash is the default shell of Mac OSX. And remember when I was talking about this important concept called PATH. When you start a shell it's going to load the PATH from the configuration files for that shell, and I'm realizing something. I'm going to show you a completely different way to live your life. I apologize for this being so Mac OSX specific, but one of the things that you want, the Mac doesn't want you to like get into your actual configuration files by default. If I go here it just wants me to look at my recent files or things people are AirDropping at me. I don't want to do that. (laughing) I want to get to my user home directory which has all this configuration stuff. So one thing I could do if I'm in the terminal prompt and I know I need to configure it still I type, I can type pwd and I can see, ah, this is the directory that I'm currently in in the terminal, in the console. I'm in Users/temporarytrain. This is actually where I want to be. That's where all the user configuration stuff for me, the temporarytrain, that particular login of this computer is. So I can now say open dot, and it's going to open that directory in the Finder. And look at this. But there's not, there's just, this is not a way to live. (laughing) Look at all this. There's a list of all this stuff here. But there's all these files that are hidden. And those files that are hidden are things that are actually controlling your PATH for when you get stuck and need to fix your Python configuration because this is broken or that is broken. You need to get into those files. So something that you can do is if I just Google like show hidden files Mac I'm going to see this nice little command here, defaults write com.apple.finder Apple, I can do this. And I can go in here. I can put that in. And then if I go back to the Finder, I'm not going to see the hidden files, and I apologize this is so low. There might be a way for me to make this bigger. I'm not going to worry about that right now. I can just zoom into it. What I need to do is relaunch the Finder. So I can do command option escape and then here click on relaunch. It's going to relaunch the Finder. And then I can come back here and I can hit open again. And suddenly look at all this stuff, .vscode, all the configuration stuff for vscode and the extensions, that's actually where it is. .npm, these are all where my user, or my global but user, anyway, all the node configuration stuff is, .config. And this, by the way, .bash_history. The current shell that I'm using is called bash. So everything that I've ever typed in, within reason, is in here, bash_sessions. And what I'm looking for is bash profile or .profile. I think it doesn't exist yet, maybe by default. But there's usually a profile file that has a lot of PATH settings and different things for when you start up. So now it's time that I've shown you this, time for me to install a different, I'm going to use a different shell. Instead of bash I'm going to use one called zsh. So if I look, and by the way, googling it the first thing I come up with is Oh My Zsh, as well as livestream of The Coding Train from four hours ago. Have I really been doing it this long? Oh my god, and a bunch of other videos that are probably better than mine. So I encourage you to find out more information about zsh. A really easy way to install it is through this tool called Oh My ZSH, and I can actually just scroll down here and get it, this website changed since yesterday. I can grab this command. This is a special command to run a curl. A curl is a way of grabbing a file. And the file that I'm going to grab is a shell script, install.sh, and sh is going to execute it. So this is basically like grabbing someone's shell script from GitHub and executing it. So you want to be careful when you do this kind of stuff. But I'm going to trust Oh My ZSH, why am I saying c? And I'm going to run it. Oh no, sh command not found? Oh, you know what it is? Sorry everybody, this is very tricky. You got to be careful here. I added an extra. I copy pasted it with the dollar sign. That's not good. So it's not going to be able to run it. So I thought like oh maybe I'm missing something, but I've got to really get it only, I just want to copy and paste this part. Easy to make these kind of mistakes. And by the way I'm hitting command k a lot, which clears the console. So now we try this. Wget was not found? That's weird that I don't have wget. Oh, right, I meant to do it with curl. Curl is a thing that I have. So now I'm going to do that. There we go. It's running. Okay, so it needs to do some stuff to my computer that I need to give it authorization for. So I need to type in my password, which I have none for this temporary account, but you should have a password, you should never do this. I'm going to delete this user after this video is over. Empty passwords are not allowed. I'll be right back. (clapping) Okay, I'm back. I changed and I made a password. So let me try running that again. I already have it installed. Hmm. But it didn't actually work. This is a thing that you won't run into, but I might as well keep it in because these are the kinds of things that happen. Let's try removing it. So, look at this, this is actually easy because I've already enabled my, I've already enabled my hidden files. So I can actually just go right here. If I hadn't done that I wouldn't be able to find this. And I can hit delete. So I'm just going to delete that. That's uninstalling it. And now I should be able to do this again. And it's running it. It wants my password. Now it got my password and boom, all the sudden Oh My ZSH, things are color coded. Look at this, I've got this beautiful little green arrow and this nice little blue tilde. Woops, I don't know where I went just now. And now, ah, sorry. iTerm come back. I now have iTerm and I am running zsh. Now notice this has changed it for the computer. I didn't link it to iTerm. If I go and run my terminal I'm also now running using zsh. And you can switch back to bash and there's all sorts of ways to do that, but I'm not going to bother. I'm happy with zsh. And it comes with, Oh My ZSH comes with a kind of default theme and set of configurations. I would love to maybe at some point go into more, and I'm sure a lot of you can write in the comments little tips and tricks of things you love to use, but I'm just going to, enjoy the wonder of the internet and get all of this stuff made for free. Oh My ZSH is Z shell, it stands for Z shell, so I should say Z shell. Okay, so one thing that I really want to do which has nothing to do with Z shell is that I want to go into the preferences and I'm going to go under profiles and under text, and there's all these sort of things you can configure, but I'm just going to change the font to something much bigger so on The Coding Train people can see it. Let's make it 36. That's probably too big but it never hurts. And there we go. So already things look different. Let's look at some things that are new. So I can still type pwd and I can see this is where I am. I can also type cd. Now most terminal shells will have things like autofill if you hit tab. This configuration has kind of a wonderful thing where if I hit tab it actually shows me all of the options. Like and I can actually tab through them. So I want a cd Desktop. So now I'm on the desktop, look it's showing me where I am. Now I can hit ls and I can see sketch.js. I can still say code sketch.js, and it filled it in but if I'd gone code I can see like oh look at this, it's trying to figure out things that I might want to say. Anyway, I'm not that experienced with this, but I can run code sketch.js and it opened that up there, so there I am again. All right so what I want to do is move on to look at how this shell configuration works with say, running node stuff as well as something, I'll add it right here, is Git and GitHub. That's really sort of a key thing that I use in my workflow. Before I do that I probably should have mentioned this in the beginning, you want to be careful about doing this. If you had a lot of stuff already configured on your machine, we just put a whole new shell, it's going to do all sorts of wonky stuff to your PATH. So maybe, so you should always be careful doing these kind of things. Good news is, let's show you how to fix stuff if it's broken. So if I go back to this directory, the key file, this is just my user directory, the key file here that I care about now is .zshrc. This has all of my essentially configuration settings for Z shell. And so if I want to edit that file, I can just say code and I can get to it. By the way, this tilde always means go to my home directory. So tilde slash which would really be like Users, temporarytrain, but I can get there always by just doing tilde, and then now I want to say .z and I want this one. I'm going to do this and now I'm going to see this file in Visual Studio Code. And you can see this is the theme that it's using. You can change it and look at this, if you come from bash you might have to change your PATH. So this is something, this idea of saying export PATH is a way of adding things to your PATH. Like so maybe you had this like Python install that you need to make sure you installed it with anaconda or something, you might say like HOME anaconda, I mean this isn't right, like python bin or something, colon. This is the way of always adding something to your PATH. Oh I want this thing to be in my PATH and I want to join it with a dollar sign PATH being everything else that's already in PATH. PATH is basically a variable. So if I were to do this I have now added, in theory, a bunch of things that I might have had before. I can hit save and now I can come back here. I can always look at what the path is by saying echo $PATH. And you can see this is what it is. Did it actually get this other stuff? I'm not sure. Sometimes you need to say source tilde dot, this like reloads that file. And then I can look at path again. And you can see oh it like added other stuff. Yes it did. So all the user stuff is now in there as well. So if you edit that file you can either restart terminal or say source to make it happen again. Now I'm probably missing like hundreds of details trying to give you an overview of the things that I end up doing all the time. But this is a place you shouldn't be afraid to mess with. You can always back it up, save it, find other settings from the internet, that type of thing. So in the next video I want to look specifically at working with Git commands in the shell and how that works. (upbeat, fun music)
B1 shell path configuration bash terminal git Workflow: Shell 3 0 林宜悉 posted on 2020/03/28 More Share Save Report Video vocabulary