Do not be afraid of the terminal, it’s amazing!
– said no beginner ever.
First and foremost, this isn’t going to make you a better developer, but it’s an awesome quick and easy facelift you can do to instantly make your time in the console time pleasing to the eye and a and make you feel like as if you are developer level 2000. At the very least, you’ll get some more utility and conveniences out of this (for those of you, like me, who have a bad habit of forgetting to check what branch you are on before working).
As I spend more time developing, I find myself staring into my console more and more. I would like to say that I’m pretty comfortable with it now and really enjoy moving files and directories and quickly making new directory and file structures compared to the repeated right click >> new blah-blah.
A lot of you veterans have already heard of different shells, so this is for the beginners out there.
For Mac and Linux distrubutions, the most common default shell provided is
Bash. For those of you with Windows, it’s likely you are using
Bash is a great shell that offers things like command and file name completion, advanced scripting features, a command history, configurable colors, command aliases, etc.
Another newer, yet very similar shell,
Z shell or
Zsh is what we’re going to talk about today. To read in detail about the difference between bash and zsh: Zsh vs Bash. Because I don’t really plan on writing scripts for other developers to use just yet, it’s safe me to switch of to zsh, however, it’s quite easy to switch between the two in the active terminal with:
\> exec bash or $ exec zsh
In all honestly, I just wanted zsh for some of the convenience items like more relevant autocompletion, (try typing
git <tab> with zsh) themes, plugins, and syntax-highlighting aka colorization because, like all design-minded developers out there, stuff has to look pretty and work well if I’m using it daily. I am sure the real power of zsh will become even more clearer to me as I advance.
For more details, there’s a great article here: What’s the Difference Between Bash, Zsh, and Other Linux Shells?
The basic terminal is pretty bland, but when you replace the default Terminal app with something like iTerm2, you already off to a great start in manipulating the shell environment such as how many lines to keep in memory, or colorization of the text.
But with zsh, you can get so much more fun stuff, and it’s really easy to manage. Here’s how I did it:
These steps are on Mac; just refer to the main zsh repo for instructions on other platforms like Linux and Windows. Normally zsh is included on Mac distributions, you just have to check the version. The links to the repos are at the end of this article.
Check if zsh is already pre-installed on your machine
You’ll want v5.1.1 or more recent
In your terminal:
You should set zsh as your default shell.
echo $SHELL from a new terminal to confirm.
usr/bin/zsh or similar
If not, here are the directions to install zsh: Installing ZSH
On Mac OSX, you can open the User and Groups panel and go to the advanced options for your user and set the login shell to something like
oh-my-zsh is just a framework for managing your zsh configuration, but it’s a really awesome framework that makes managing it really easy, it’s worth it. Get it.
The repo provides 2 ways to get it using curl and wget, check with the repo for the latest:Oh-my-zsh. There’s really great documentation on how it all works and where everything goes.
- via curl or wget
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
This is the equivalent to the .bash_profile for bash shell, only a lot more helpful and comes with instructions on how to override the default settings. I just copied over my aliases from my
.bash_profile, but you could essentially export it through the
.zshrc or some like to just create a
.profile that both bash and zsh can reference. Your call. But this file is awesome for aliases, which allows you to type shortcuts to frequently used directories or even remote repos, etc.
You can open this file with vim, vs code, atom, or just the plan text note pad.
∆ code ~/.zshrc
That’s it you are done, just find a theme you like, if it’s a pre-packaged one, you just change the name in the
If you want to download a custom one or one that’s not pre-loaded, you just have to download it and place it in the
custom/themes directory and then change the name and
oh-my-zsh will find it for you.
Same with plugins, it comes with everything, you just have to activate it by adding their name to the
plugins=() line. At the very lease you’ll want the
Another favorite non-.zshrc prepackaged plugin is syntax-highlighter which tells you whether the command you are entering is correct. GitHub – zsh-users/zsh-syntax-highlighting: Fish shell like syntax highlighting for Zsh.
Just follow the directions on downloading and install and don’t forget to add it to the .zshrc file like this:
Don’t forget to
∆ source ~/.zshrc every time you make a change to this file.
Of course, I also want to add it to my favorite text editor, VS Code!
In the settings file, type in
shell and scroll to the bottom where you’ll see the paths set for the shell to be used by the integrated terminal:
If it still says bash, then change it to zsh. Restart your VS Code and open the integrated terminal and it should say .zsh in the upper right of the terminal window.
At this point I observed an odd behavior where bash and zsh were visibly flipping back and forth several time, if the terminal is starting up slow for, double check your .zshrc profile and your
$PATH. I had several duplicate path shims, so I had to just clear those out and now the terminal starts up instantly.