DEV Community

Zachary Izdepski
Zachary Izdepski

Posted on

A beginners guide to the terminal and z-shell

Image description

The relationships between the levels of a computer can be thought of in terms of layers, the computer itself being the hardware, the Kernel being a largely inaccessible program without a user interface that handles the very basic functions necessary for the operating system to, well, operate, and a terminal that allows the user to actually communicate with the computer. Subsequent "layers" are where we start to interact with our computers in more nuanced and specific ways, and this is really where the term "shell" gains more meaning.

So what exactly is a shell? At the most basic level, a shell is a user interface that allows the user to interact with the computer in a more human friendly way. You can think of a shell as just another layer of interpretation, an interface that ‘wraps’ the commands you give to your operating system so you don’t need to be quite as verbose with your machine. There are two primary types of shells: Graphic User Interface (GUI) and Command Line Interface (CLI). GUI is the way in which most everyday people interact with their computers. It is an interface that is built to be specific to tasks and supports a more visually interactive user experience. An example would be a file directory. By contrast, a CLI is how developers interact with their machines. The CLI is a more wholistic way to communicate with your operating system in that it essentially consolidates interaction with your operating system into one place; the terminal.

Let's take a step back. What is a terminal? And is a CLI a terminal or is a terminal a CLI? This gets at a somewhat confusing characteristic of modern software development; the repetition of industry terminology and reliance upon understanding the context in which the terms are used as the industry evolves. With this in mind, I will say that the "terminal" is typically referred to as a CLI, or even THE CLI, and is a place where we can interact with the hardware of our computer in an environment largely stripped of software. In the early days of computers, a terminal was an actual keyboard and monitor connected to a large computer in a server room. It was THE way in which early software developers had to communicate with a computer. Nowadays we utilize an electronic terminal, one that is much more integrated into our machines and far more powerful. In the terminal you can run code, execute files, start servers and download and install tools all in one place.

Image description

So what then is the z shell? In 2019, Apple replaced the born again shell (bash) with the z shell (zsh). Many of the features of bash, tcsh, and ksh were incorporated into zsh since it is really just an updated version of previous unix-like system shells. Zsh can be used for in line completion features, natively supports unicode, can get paths to binaries, and offers customized CLIs, built-ins and plugins. All of this is supported by a community of developers whose main goal is to make life easier for other developers. For instance, zsh offers a reverse-search that allows you to search your command history across sessions. Now you can go back in time and see exactly what commands you ran in your app to make it break the last time you used the terminal in a previous session! There are also built-ins, which are basically subsets of shorthand commands that you can choose from depending on what kind of software development you are in. There are many more features in zsh that can be used to customize your terminal experience and make you a more efficient developer, but probably the best one is the open-sourced nature of the shell. Crowd source is the best source!

Top comments (0)