GithubHelp home page GithubHelp logo

amarpan / how-to-install-and-configure-zshell Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 317 KB

How to install Z Shell, change themes, and enable the autosuggestions plug-in on the command line interface (CLI)

how-to-install-and-configure-zshell's Introduction

How to Install and Configure Z Shell in Linux

Written by Amar Panjwani
Technical Writer

Portfolio Badge
LinkedIn Badge
Stars Forks
Version

If you find this tutorial helpful, please consider giving it a ⭐

Z Shell (zsh) is a popular alternative to the default command line bash shell with improved features like recursive path expansion, automatic spelling correction, and plug-in and theme support.

This guide will walk you through the process of installing and configuring zsh, including how to change themes and enable the time-saving autosuggestions plug-in.

Before You Begin

Complete the following steps prior to getting started:

  1. Install Git:
sudo apt install curl wget git

Installation

  1. Install Zsh:
sudo apt install zsh
  1. Install Oh My Zsh:
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

You should now see the following prompt asking if you'd like to change your defaut shell to zsh. Type y to confirm.

Oh My Shell Configuration Prompt

Take a look at your new command line and you should notice the difference right away.

Zsh In Effect

Note:

If for any reason you need to switch back to the bash shell, use the following command:

chsh -s $(which bash)

Proceed to log out and back into your session for the change to take effect.

Run echo $SHELL to confirm the output is /bin/bash

Change Zsh Theme

By default, the zsh theme is set to robbyrussell, the name of the founder of Oh My Zsh. However, this is rather plain and there are over 100+ included themes with a wider assortment of colors and styles to choose from.

For example, here are 3 uniquely different themes to choose from:

  1. jonathan

Jonathan Theme Preview

  1. xiong-chiamiov

Xiong Chiamiov Theme Preview

  1. agnoster

Agnoster Theme Preview

Follow these steps to change themes to jonathan:

  1. Open your zsh configuration file:
vi ~/.zshrc
  1. Press i to enter Insert Mode.

  2. Change the ending of the line reading:

ZSH_THEME="robbyrussell"

to

ZSH_THEME="jonathan"
  1. Press ESC to leave Insert Mode and enter Command Mode.

  2. Type :wq + ENTER to save and quit.

  3. Reload the command line:

source ~/.zshrc
  1. Check out your newly themed command line and repeat steps 1-6 with a few more themes to find the best fit.

  2. To see the full list of locally available zsh themes, follow these steps:

    a. Change directories to the zsh themes folder:

    cd ~/.oh-my-zsh/themes
    

    b. List the names of all the available themes:

    ls
    

Enable Autosuggestions

The autosuggestions plug-in is quite possibly the single most time-saving tool when coding. Instead of having to type the same command over and over again in full, this plug-in automatically suggests the rest of your command as you are typing, without even having to press TAB.

For example, instead of having to type git push origin main every single time you wish to push a new commit, you can instead type git push and the command line will automatically show a preview of the rest of the suggested command based on your shell's history.

Auto-Complete Plug-in Preview

Follow these steps to install and enable the autosuggestions plug-in:

  1. Change directories to the oh-my-zsh plug-ins location:
cd ~/.oh-my-zsh/plugins/
  1. Clone the autosuggestions plugin packages:
git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
  1. Edit the zsh configuration file:

    a. Type vi ~/.zshrc

    b. Press i to enter Insert Mode.

    c. Update the line beginning with plugins=(git) to plugins=(git zsh-autosuggestions)

    d. Press ESC to leave Insert Mode and enter Command Mode.

    d. Type :wq + ENTER to save and quit.

  2. Reload the command line for the changes to take effect:

source ~/.zshrc
  1. Try it out! Start typing a command you know to be in your shell's history and watch as zsh offers autosuggestions. After seeing a suggestion that you'd like to approve, press the Right Arrow key to accept it.

More Information

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

***If you found this tutorial helpful, please consider giving it a ⭐

Copyright ©️ 2021-2022

More Tutorials from Amar Panjwani

How to Create a GitHub Profile

How to Write a README

How to Use the Command Line Vim Text Editor

how-to-install-and-configure-zshell's People

Contributors

amarpan avatar

Stargazers

Edius Ferreira avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.