From the course: Learning Zsh

Installation and initial configuration - Unix Tutorial

From the course: Learning Zsh

Start my 1-month free trial

Installation and initial configuration

- Z-Shell is available through the packet managers for a wide variety of Linux distros. For Unix clients and for OpenBSD and FreeBSD and as of Mac OS 10.15, it comes as the default shell as well. So if you're using that version of the platform you don't need to install Zsh. For older versions of Mac OS, you can install Zsh with a package manager like Homebrew. On Windows, it can be installed in Windows Subsystem for Linux using the package manager of your chosen distro. And you can also install it directly in Windows 10 using the WinZsh package. Let's take a look at installing Z-Shell, here on my Ubuntu system. Depending on which platform you're using, you'll need to use the tools available to you to install Z-Shell. Here in the terminal, I'll write apt update, to get the most recent package list. And then apt install zsh, to install Z-Shell. Installing Z-Shell is fairly straight forward if you have a system that includes it in the repositories. If you're feeling adventurous, you can also build Z-shell from source, which is available from the projects page on SourceForge. But we won't get into that here. We'll focusing on the Z-Shell installation that's available through the package manager. Once Z-Shell is installed, we can start it up by typing zsh. On a clean install you're likely to see the new user installation wizard, which helps you set some common options for the shell but if your system already has Z-Shell configuration files, you won't see it. My system didn't have those files, so I see the wizard. The configuration options we'll see, get into topics I'll cover later in the course. So don't worry if they look complicated and you don't completely understand them at this point, you will. If you don't want to do any customization now, you can chose one of the other options or follow along and then just not save anything at the end. If you don't set the options that I do, that's fine, just be aware that what you see throughout the course might vary a little bit. We can relaunch this configuration wizard later, too. Here in the configuration wizard, the first options we have are to quit, exit or continue. If I quit, the wizard will do nothing and just run next time. If I exit by pressing 0, the wizard will create a configuration file with no directives in it, meaning there won't be any customization and this wizard won't run the next time you launch Z-Shell. And pressing 1 will continue to the main menu. I also have an option to populate my configuration file with a configuration recommended by the system administrator. We'll ignore that for now. And I'll press 1 so we can take a look at the options. I won't do any real custom configuration here. I'll stick to recommended defaults as I show you around a little bit. Here, we have options for configuring the command history, for the completion system, how keys behave at the command line, and other shell options. Again, we don't have to set these here and they can all be configured later. This just sets the initial configuration. First, I'll press 1 to take a look at the history setting. We can set the number of commands that the shell will remember. I'll talk about history, in more detail, later on. The default number of items stored is 30, which is a little slim. And the recommendation here is a thousand. To customize this further, you can press 1 but I'll leave that alone and move forward. By default the history within the shell isn't saved anywhere. When we close a shell session, the history goes away. The recommendation here, represented by number two, sets the histfile configuration option, which saves the history in a file in the home directory so it's available for other shell sessions that are active and will persist between closing and opening the shell. That's useful too. And this last option, sets how many lines of history are saved to the history file. That could be different than shell buffer if you want it to be. To except these defaults, I'll press 0. Back here, at the main menu, the next option is for completion. Again, we'll talk about how this works later. I'll press 2, and then chose the first option, here to enable completion. There's an option to further customize it but I'll leave it alone. Pressing 1, takes me back here to the main menu. The third option here, configures how keys behave when working with a line editor. Again, we'll talk about that in a while. I'll press 3. The recommendation is to use Emacs line editing, which mimics the behavior of the Emacs text editor. I'll enter a submenu, for that default by pressing 1. The recommendation for Emacs is selected by pressing e here, so I'll do that. And then I'll press 0 to get back to the main menu. The last section to configure here are commonly used options. I'll press 4, to see them. We'll discuss options in more detail later on. I won't choose to set any of these right now though. So I'll press 0 to go back to the main menu. And now, we're ready to see if the changes we made. To save them, I'll press 0. If you want to cancel these changes, you can either abort or quit. These options have now been written to the .zshrc file in my home directory. As with a lot of things I've mentioned so far, we'll take a look at that, in more depth, later on. But now we have a basic configuration and we're ready to continue learning about Z-Shell.

Contents