Beginner

How To Install And Use ZSH On Debian 10 [Z shell]

How To Install And Use ZSH On Debian 10 [Z shell]

Tutorial How To Install And Use ZSH On Debian 10 Linux Server. Z shell is a programmable shell of Unix that is an extended version of the Bourne Shel to provide us several features like support for more than 275 plugins and bout 150 themes. Before all, buy Linux VPS to be able to use all its benefits on your server.

To let this tutorial work better, please consider the below Prerequisites:

A non-root user with sudo privileges.
To set up, follow our Initial Setup with Debian 10.

How To Install And Use ZSH On Debian 10 [Z shell]

Join us with this tutorial to review how to install ZSH in Debian 10 to see your terminal was never good enough before that. In the following, you will learn the installation and also you see some most common plugins to help you start Zsh.

Tutorial Install And Use ZSH On Debian 10 Linux Server

Zsh Features On Debian 10

Better tab completion

Easy directory navigation

Supports lots of Themes and Plugins

Syntax highlighting

Auto completion

Interactive configuration

Color customization

You can install Zsh with your package manager. On Fedora, RHEL, and CentOS:

sudo dnf install zsh

Also, you can check for any shells currently in use:

Type the following command to install on Debian:

sudo apt install zsh

OR

Open a terminal window. Copy & paste the following into the terminal window and hit Return. You may be prompted to enter your password.

sudo apt update sudo apt upgrade sudo apt install zsh  
Recommended Article: How To Install And Configure OpenVAS On Ubuntu 20.04

How To Set Up Zsh And Use ZSH On Debian 10

Since the Zsh is not a terminal emulator but a shell that runs inside a terminal emulator, you need to launch a terminal window to launch Zsh. A terminal window such as Gnome Terminal, Konsole, Terminal, iTerm2, rxvt, or another terminal of your preference. Once you ensured of launching one of them, ypu can use the command below to launch Zsh.

zsh

In case, this is the first tie you launch Zsh, you will be prompted to choose some configuration options.

Note: The configurations can all be changed later, so you can press 1 to continue.

This is the Z Shell configuration function for new users, zsh-newuser-install.  (q)  Quit and do nothing.  (0)  Exit, creating the file ~/.zshrc  (1)  Continue to the main menu.

 

How To Use Zsh

Once the installation is completed, you can clearly see that  Zsh feels a lot like using Bash. Since there are serious differences between, Bash and Tcsh, so if you learn how to switch between Bash and Zsh it would be easy to use at home if you have to use Bash at work or on your server.

 

How To Search With Zsh

It is expected to use the find or locate command to find a file using a normal shell or even use ls -R for a recursive listing of a set of directories. However, Zsh allows you to find a file in the current or any other subdirectory. For example, consider that you have two files called elder.txt. One is located in your current directory, and the other is in a subdirectory called elder. In a Bash shell, you can list the file in the current directory with:

ls elder.txt

And you can list the other one  explicitly:

ls elder elder.txt

Anyway, to list both, you must use the -R switch, maybe combined with grep:

ls -R | grep elder.txt elder.txt elder.txt

But in Zsh, you can use the ** shorthand:

% ls **/elder.txt elder.txt elder.txt
Please be aware that you can use this syntax with any command, not just with ls.
 
 

How To Use Wildcards in Zsh

To maximize your search results in library databases you can use the wildcard, an advanced search technique. Wildcards are used in search terms to represent one or more other characters. Also, in Zsh the wildcards behave differently Zsh than what Bash users are used to. To list all folders in your current directory, use a modified wildcard:
% ls dir0   dir1   dir2   file0   file1 % ls *(/) dir0   dir1   dir2

In this example, the (/) qualifies the results of the wildcard so Zsh will display only directories. To list just the files, use (.). To list symlinks, use (@). To list executable files, use (*).

% ls ~/bin/*(*) fop  exify  tt
 

Zsh Plugins

To add functionality of many sorts to your shell just by enabling them, you need to use Zsh plugins. They are each documented in the README file in their respective plugins/ folder. To enable the plugins, you need to add their names to plugins array in your .zshrc file.
For example, this enables the railsgit, and ruby plugins, in that order:
plugins=(rails git ruby)
If you need to check your current plugins, update or install new ones, you can run the following command:
zplug <option>  

check — Return true if all packages are installed, false otherwise

clean — Remove repositories which are no longer managed

clear — Remove the cache file

env — [User-defined] The environment variables of zplug

info — Show the information such as the source URL and tag values for the given package

install — Install packages in parallel

list — List installed packages (more specifically, view the associative array $zplugs)

load — Source installed plugins and add installed commands to $PATH

status — Check if the remote repositories are up to date

update — Update installed packages in parallel

 
 

How To Set Zsh As The Default Shell

If you found the Zsh suitable for your cloud server, make it a default shell for your user to let it be loaded a Zsh session when you log in. You will no longer have to type “zsh” to get to zsh in your VPS.

chsh -s $(which zsh)
 
 

How To Configure Zsh

The location of the Zsh configuration file is in your home directory (eg. ~/.zshrc). The following configuration file will help you to start.

Create ~/.zshrc with the following content:

# Set path if required #export PATH=$GOPATH/bin:/usr/local/go/bin:$PATH  # Aliases alias ls='ls --color=auto' alias ll='ls -lah --color=auto' alias grep='grep --color=auto' alias ec="$EDITOR $HOME/.zshrc" # edit .zshrc alias sc="source $HOME/.zshrc"          # reload zsh configuration  # Set up the prompt - if you load Theme with zplugin as in this example, this will be overiden by the Theme. If you comment out the Theme in zplugins, this will be loaded. autoload -Uz promptinit promptinit prompt adam1            # see Zsh Prompt Theme below  # Use vi keybindings even if our EDITOR is set to vi bindkey -e  setopt histignorealldups sharehistory  # Keep 1000 lines of history within the shell and save it to ~/.zsh_history: HISTSIZE=5000 SAVEHIST=5000 HISTFILE=~/.zsh_history  # Use modern completion system autoload -Uz compinit compinit  # zplug - manage plugins source /usr/share/zplug/init.zsh zplug "plugins/git", from:oh-my-zsh zplug "plugins/sudo", from:oh-my-zsh zplug "plugins/command-not-found", from:oh-my-zsh zplug "zsh-users/zsh-syntax-highlighting" zplug "zsh-users/zsh-autosuggestions" zplug "zsh-users/zsh-history-substring-search" zplug "zsh-users/zsh-completions" zplug "junegunn/fzf" zplug "themes/robbyrussell", from:oh-my-zsh, as:theme   # Theme  # zplug - install/load new plugins when zsh is started or reloaded if ! zplug check --verbose; then     printf "Install? [y/N]: "     if read -q; then         echo; zplug install     fi fi zplug load --verbose

 

How To Change The Theme

You can find that by opening the .zshrc file. By default, Oh-my-zsh uses ‘robbyrussell’ theme.

.zshrc
# If you come from bash you might have to change your $PATH. # export PATH=$HOME/bin:/usr/local/bin:$PATH  # Path to your oh-my-zsh installation. export ZSH=$HOME/.oh-my-zsh  # Set name of the theme to load --- if set to "random", it will # load a random theme each time oh-my-zsh is loaded, in which case, # to know which specific one was loaded, run: echo $RANDOM_THEME # See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes ZSH_THEME="robbyrussell"  

Also, you can find many other themes available and in ~/.oh-my-zsh/themes/ directory.

ls ~/.oh-my-zsh/themes

In case, you need to change the default theme, you should edit the .zshrc file and change the default theme and save the changes by running:

source .zshrc

 

 

Conclusion

In this article, you learned How To Install And Use ZSH On Debian 10. From now on you can use Zsh and enjoy its features. Also, you can read more on Linux Server Monitoring Commands.

View More Posts
Tom Veitch
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

7 thoughts on “How To Install And Use ZSH On Debian 10 [Z shell]

    1. The friendly interactive shell (fish) is very user-friendly and interactive shell and also more customized. It is easy to pick up and use. However it is depends on you and your needs.

    1. The fact is that Linux users don’t need to install the Bash shell because it is installed by default with Linux distribution. Also, some of the Zsh features make it better such as spelling correction, cd automation, better theme, and plugin support, etc.

Leave a Reply

Your email address will not be published. Required fields are marked *

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day