by Chiamaka Ikeanyi
Sometimes, using the default terminal sucks. You want to go out of the ordinary, to add life to the boring terminal and improve your productivity.
Z shell (Zsh) is a Unix shell built on top of bash (the default shell for macOS) with a large number of improvements.
Sudo: setrlimit(8): Invalid argument after switching Mac OS shell from BASH to ZSH. ZSH:.zprofile,.zshrc,.zlogin - What goes where? Hot Network Questions If a player's character is absorbed by a gibbering mouther, do they make death saving throws as normal, or are they instantly killed? If you're not using Homebrew, this is what I just did on MAC OS X Lion (10.7.5): Get the latest version of the ZSH sourcecode. Untar the download into its own directory then install:./configure && make && make test && sudo make install This installs the the zsh binary at /usr/local/bin/zsh. You can now use the shell by loading up a new terminal and executing the binary directly, but you'll. Apple has announced that in macOS 10.15 Catalina the default shell will be zsh. In this series, I will document my experiences moving bash settings, configurations, and scripts over to zsh. Part 1: Moving to zsh Part 2: Configuration Files Part 3: Shell Options Part 4: Aliases and Functions Part 5: Completions Part 6: Customizing the zsh Prompt (this article).
In this walk-through, we will configure iTerm2 with ZSH and its dependencies. This is a no-brainer, and after this, you’ll ponder the reason for not discovering ZSH earlier. Well, since you’re here already, let’s kick-start this.
Keynotes
![Zsh Zsh](/uploads/1/2/6/5/126528790/832691968.png)
- Homebrew installation
- iTerm2 installation
- ZSH and Oh My ZSH installations
- Setting up the dependencies to create a beautiful terminal
Step 1: Install Homebrew
Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple’s macOS.
Before installing Homebrew, we need to install the CLI tools for Xcode. Open your terminal and run the command:
If you get an error, run
xcode-select -r
to reset xcode-select
.Then, install Homebrew.
I don't have powerline fonts as I'm using Nerd Fonts instead, and I don't have iTerm2, just oh-my-zsh (Mac). I've also seen this mentioned a little on the official 10k github page, but it's a bit vague on how to fix it. Any help with this would be much appreciated, thanks! Personally, I'm using Oh My Zsh for adding color and other tricks to my Terminal. I think that is the easiest way. Oh-my-zsh is an open source, community-driven framework for managing your Zsh configuration. It comes bundled with a ton of helpful functions, helpers, plugins, themes,.
Step 2: Install iTerm2
iTerm2 is a replacement for terminal and the successor to iTerm. Most software engineers prefer iTerm2 over the default terminal that ships with macOS as a result of its cool features. You can integrate zsh into iTerm2 to increase productivity.
To install iTerm2, run the command:
Step 3: Install ZSH
Zsh is a shell designed for interactive use, although it is also a powerful scripting language.
By default, macOs ships with zsh located in
/bin/zsh
.Let’s install zsh using brew and make iTerm2 use it.
Step 4: Install Oh My Zsh
“Oh My Zsh is an open source, community-driven framework for managing your zsh configuration. It will not make you a 10x developer…but you might feel like one”
— Robby Russell
It runs on Zsh to provide cool features configurable within the ~/.zhrc config file. Install Oh My Zsh by running the command
Check the installed version
You can upgrade it to get the latest features it offers.
Restart iTerm2 to dive into the new experience of using Zsh. Welcome to the “Oh My Zsh” world ?.
That’s not all. Now, we will install the dependencies to get the best out of Zsh.
Step 5: Change the Default Theme
Oh My Zsh comes bundled with a lot of themes. The default theme is robbyrussell, but you can change it to any theme of your choice. In this scenario, I changed it to agnoster, an already pre-installed theme.
You then need to select this theme in your
~/.zshrc
. To open the config file (.zshrc), run the command:Or open the file in a text editor with
Set the zsh theme and update your changes
Using a Custom Theme
To install another theme not pre-installed, clone the repository into
custom/themes
directory. In this scenario, we’ll install powerlevel9k,Then, select this theme in your
~/.zshrc
Update your changes by running the command
source ~/.zshrc
Navigate to
iTerm2 > Preferences > Profiles > Colors
Mac os torrent files. if you wish to change the background color of the terminal.The selected theme in this scenario requires powerline fonts. So, let’s install that.
Step 6: Install Fonts
I will be using Inconsolata. Get your preferred font out of these powerline fonts. Then, download and install it.
Or download the entire font.
To change the font, navigate to
iTerm2 > Preferences > Profiles > Text > Change Font
.Now, you can see Inconsolata listed as one of the fonts. Select your preferred font. For fonts that support ligatures like FiraCode, check the “Use ligatures” option to view your arrows and other operators in a stylish manner like ( → ).
Step 7: Install Color Scheme
Let’s change the color scheme to bring out the beauty of our terminal. Navigate to iTerm2-Color-Schemes and download the ZIP folder. Then, extract the downloaded folder cos what we need resides in the schemes folder.
Navigate to
iTerm2 > Preferences > Profile > Colors > Color Presets > Import
- Navigate to the schemes folder and select your preferred color schemes to import them.
- Click on a specific color scheme to activate it. In this scenario, I activated Batman which is my preferred color scheme.
Tada! ? We’re done with the basic settings.
Step 8: Install Plugins
Oh My ZSH comes preloaded with a git plugin. To add more, for instance, docker, auto-suggestion, syntax highlighting and more:
- Clone the Git repository
- Head over to
.oh-my-zsh > custom > plugins
directory to view the cloned directory. To access this, run the commandopen ~/.oh-my-zsh
- Add the plugin to the plugin section of the config file
~/.zshrc
shown below - Update your changes by running the command
source ~/.zshrc
Step 9: Add Aliases
Aliases are shortcuts used to reduce the time spent on typing commands. Add aliases to commands you run in the section shown below.
Mac Terminal Zsh
Thanks for reading.
If you know about other means of improving productivity using ZSH, you can drop them on the comment section, I will be glad to hear from you.
macOS 10.15 Catalina brought many big changes to the Mac, like lack of support for legacy 32-bit apps, but one that you could easily have missed is the default Terminal shell switching from bash (the Bourne-again shell) to zsh (Z shell). It’s an easy change to miss if you don’t use the Terminal, but also because if you upgraded from an older version of macOS, bash remains the default (though you’re prompted to switch).
If you’re a Terminal user, you need to be aware of the change, and if you’re merely Terminal-curious, now is a great time to dive in and learn more about the shell, since so many Mac-friendly user guides are being published. In our last reader survey, Terminal coverage wasn’t high on the list of desired topics (“TidBITS 2019 Reader Survey Results,” 6 September 2019), so I won’t dedicate a ton of space to zsh here but will instead point you to resources to help learn more about it.
![Iterm2 Iterm2](/uploads/1/2/6/5/126528790/309507504.jpg)
What is a “shell?”
In the simplest terms, the shell is the command-line environment you use to interact with the operating system. Apple intends users to interact with macOS primarily through its graphical interface, but because macOS is built on top of Unix, it also offers a robust command-line environment.
Don’t confuse a shell like zsh with the Terminal app itself. Terminal loads zsh or another shell of your choice and acts as your graphical interface to the shell, which in turn is the text-based interface to macOS’s Unix foundation.
From the command line, you can execute Unix commands like
cd
and ls
. A shell used in this way is referred to as an “interactive shell.” You can also string shell commands together with flow control and the like to write shell scripts that automate actions. Those can in turn also be integrated into other automation tools like AppleScript and Keyboard Maestro. In such scripts, you call the shell, usually sh
, with a starting line like #!/bin/sh
. When you use a shell like this, it’s called a non-interactive shell.What is bash, and why did Apple switch to zsh?
Over the years, programmers have developed numerous shells with different features. Since Mac OS X 10.3 Panther, the Mac’s default shell has been the Bourne-again shell, or bash. It’s also often the default on many Linux distributions, making it something of a de facto standard. Its name is a play on the nigh-ubiquitous Bourne shell (and its many clones, like ash), often referred to by its command,
sh
. The Bourne shell dates back to 1976, and while it isn’t generally used interactively, it’s still the basis for most Unix shell scripts because of its ubiquitousness. In 1989, bash emerged from the GNU Project as a newer, more modern version of sh.There’s nothing wrong with bash, but after version 3.2, released in 2007, the GNU Project relicensed it under the GNU Public License 3.0, which places restrictions on companies like Apple, such as refraining from patent lawsuits and letting people tinker with their computers. Long story short, the 3.2.57 version of bash that ships with macOS is long out of date because Apple refuses to accept GNU’s terms. However, GNU has released small updates over the years to address things like the Shellshock vulnerability—see “Apple Updates Bash for the Shellshock Vulnerability” (29 September 2014).
In contrast, zsh is licensed under a variant of the less-restrictive MIT license. It also offers some advanced features that bash doesn’t.
What does zsh do that bash doesn’t?
The How-To Geek has a brief overview of zsh’s advantages, like automatic
cd
, where you can simply type a directory name to navigate to it, and built-in spell-check. zsh also supports plug-ins, which enables things like the popular Oh My Zsh, which adds even more features and makes advanced configuration easier. I also recommend perusing the zsh FAQ, which answers various and sundry questions.One of my favorite features of zsh is menu autocomplete. In most shells, you can start to type a command or directory name, like
/usr/bi
, and then press Tab to autocomplete. In most shells, if there’s more than one autocomplete option, the shell will list the options, but you have to keep typing out the correct path by hand until there’s only one option left, after which you can press Tab to fill it in. With zsh, you can instead configure it to show your options as a menu that you can navigate and select with arrow keys, or with a bit more configuration, vi keybindings or any keys you want. In the screenshot below, I entered /usr/local/
and hit Tab to see a menu of subfolders.How do I know which shell I’m using?
Open Terminal and enter one of these commands:
echo $0
— which shows the name of the shell.echo $SHELL
— which shows the path to the shell.
The latter command can be especially helpful if you use something like Homebrew to install different shell versions, which exist alongside those Apple ships, just in a different directory (more on that later).
Where can I learn more about zsh?
One of the best free resources for zsh in macOS is Armin Briegel’s Moving to zsh eight-part blog series. Briegel has also released a $9.99 ebook called—you guessed it—Moving to zsh—in Apple’s Book Store. If you’re serious about learning zsh in Catalina, I think it’s a good investment, as it covers in detail everything from explaining what a shell is, transitioning to zsh, and configuring zsh. It will take you from beginner to advanced user quickly, but it isn’t an exhaustive reference. For that, check out the official zsh manual.
The zsh team also offers an official user-friendly guide to zsh, which isn’t as user-friendly or Mac-focused as Briegel’s but has more raw information.
How do I customize zsh?
Out of the box, zsh is a bit spartan. I recommend Briegel’s Moving to zsh, part 2: Configuration Files for a thorough explanation of zsh’s configuration files, though you’ll have to read the rest of the series for configuration tips.
Hold off on installing a plug-in system like the aforementioned Oh My Zsh until you have a good grasp on how zsh works and what you need from Oh My Zsh. No need to make things overly complicated from the start.
Can you share your zsh configuration?
I just copy Luke Smith’s zshrc file into
~/.zshrc
. He has set up some nice colors and menu autocomplete with vi keybindings. Here’s a video explaining his configuration in detail.If you don’t like the vi keybindings and want to use the arrow keys to navigate the menu, simply remove or comment out the five lines under
# Use vim keys in tab complete menu:
.Will my old shell scripts break?
If you started your shell scripts with the standard
#!/bin/sh
, you shouldn’t have problems. Catalina still ships with bash, which emulates sh. However, I wouldn’t be surprised if Apple were to remove bash entirely in the future. Apple suggests having zsh emulate sh by adding the --emulate sh
option to zsh, so you can start a script with #!/bin/zsh --emulate sh
. (Note that this won’t work with the version of zsh that ships with Mojave.) I also refer you to Briegel’s Moving to zsh, part 8, which covers scripting with zsh.My default shell is still bash. How do I switch to zsh?
Although zsh was not the default in older versions of macOS, nor is it the default in Catalina for older accounts which were created with bash as their default shell, Apple has long included zsh with macOS. You can give it a whirl right now by typing
zsh
at the command line. Type exit
to leave zsh. If you want to set it as your default shell, Apple offers a couple of ways to do so, as well as a way to change what Terminal uses without changing the default for your account.YEd Graph Editor. YEd is a powerful desktop application that can be used to quickly and effectively generate high-quality diagrams. But yEd is that it is written in Java yet has a 100% native look and feel (so on Mac, you can zoom in and out with 2 finger scrolling). Lucidchart Sponsored. Lucidchart is an online diagram and flowchart software that supports. Thousands of graphic, graph and data attributes, including artwork, maps, autoscaling and many effects can be set by applying a skin made with Vvidget Builder (an optional Mac OS X desktop. YEd Graph Editor. Downloads Download yEd 3.20.1. The current version is 3.20.1. To check your version, open the Help menu and choose About. Download Notes; yEd for Windows. YEd for Windows: yEd installer for 64-bit Windows 7 or later. Includes a suitable Java 13 JRE. YEd for Mac OS X/macOS: yEd installer for Mac OS X 10.11 or higher. Best video editor for mac. Free Graph Editor Software for Mac Os – Graphviz. This is open source graph editor software which comes with helps to represent information as diagrams of graphs. It allows changing various aspects of graph representation. It allows drawing nodes and connection lines.
I don’t like zsh. Can I go back to bash? Preferably a newer version?
Yes, and it’s easy to do so. Just follow the link to Apple’s how-to page above and replace
/bin/zsh
in the instructions with /bin/bash
.However, you may not want to remain on Apple’s ancient version of bash. That’s where Homebrew comes in handy. Once you install it, running
brew install bash
will update the latest version from Homebrew, which will be installed in /usr/local/bin/bash
. Note that you’ll have Apple’s version in /bin/bash
and Homebrew’s version in /usr/local/bin/bash
. If you need a feature from the newer version of bash that Homebrew installs, be sure to start your scripts with #!/usr/local/bin/bash
.If you don’t or can’t use Homebrew, Briegel has instructions on how to build and install bash manually.
Are there alternatives to bash and zsh?
There are an absurd number of shells out there, but bash and zsh are the most common and the most worth your time to learn. However, Brett Terpstra has been documenting his experiments with the fish shell:
The Default Interactive Shell Is Now Zsh
Fish features advanced autosuggestion and expansions, does cool syntax highlighting, offers a “sane” scripting toolset, has an array of existing plugins and themes, and even sports a browser-based configuration tool that’s pretty awesome.
What Is Zsh Mac
I haven’t tried it, but it may be your cup of tea, er, barrel of fish.