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
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:
echo SHELL /usr/bin/bash
Type the following command to install on Debian:
sudo apt install zsh
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
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.
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:
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
How To Use Wildcards in Zsh
% 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
plugins=(rails git ruby)
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
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.
# 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.
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:
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.