ZSH

Introduction to using zsh.

Learning Objectives

  • Get to know about zsh
  • Use it if you must. It is default on macOS, but not the PI

You may use zsh on the PI, but we find it better to just use a default shell such as bash. The reaon we have included it is that it became default on macOS and many are accessing the Pis from the Mac.

Topics covered

Introduction

Z shell (zsh) is an alternative to bash. It is used as an interactive shell or command interpreter. Zsh has been chosen by apple as a replacement for bash. A large number of plugins for zsh is avalable at the Web site Oh My Zsh.

Features of zsh include:

  • commandline completion
  • global history that can be shared in shells
  • build in file globing
  • multiline commands
  • spell correction
  • compatibillity modes to impersonate other shells
  • themes for prompts
  • in addition to which a wher ecommand
  • shortcut to names directories with ~

In principal it does not matter much whcih shell you use as long as you use to set up your envireonment properly. While bash zupporst .bash_profile and .bashrc, zsh supports ~/.zprofile and ~/.zshrc

A good overview of the loading process is documented at

Setting up zsh on an older OSX is relatively simple.

$ brew install zsh

To add Oh My Zsh you can do:

$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

To chnge the default shell to zsh you can than execute

$ chsh -s $(which zsh)

To activate the shell you can as usal do

$ source ~/.zshrc

However if you start a new terminal, you do not have to do this as it is added automatically.

To use a number of useful plugins, you can activate them with

$ plugins=(osx git colored-man colorize pip python brew zsh-syntax-highlighting zsh-autosuggestions)

If you like to change the theme you can find a large number at

Using zsh on your operating systems

For other operationg systems see

zsh on Windows 10

To install zsh on Windows 10, please look at