Skip to content

How to install Zsh + OhMyZsh in WSL

Published: at 09:08 PM

to check which shell we are running

echo $SHELL

in default case is bash

/bin/bash

install zsh

sudo apt install zsh

check if is installed

which zsh

should return

/usr/bin/zsh

in order to tell our machine to use zsh instead of bash we run and after we restart the machine to make the change effective

 chsh -s $(which zsh)

then we type 1 to enter the main menu

This is the Z Shell configuration function for new users,
zsh-newuser-install.
You are seeing this message because you have no zsh startup files
(the files .zshenv, .zprofile, .zshrc, .zlogin in the directory
~).  This function can help you with a few settings that should
make your use of the shell easier.

You can:

(q)  Quit and do nothing.  The function will be run again next time.

(0)  Exit, creating the file ~/.zshrc containing just a comment.
     That will prevent this function being run again.

(1)  Continue to the main menu.

(2)  Populate your ~/.zshrc with the configuration recommended
     by the system administrator and exit (you will need to edit
     the file by hand, if so desired).

--- Type one of the keys in parentheses ---

and hit one again to configure

History configuration
=====================

# (1) Number of lines of history kept within the shell.
HISTSIZE=1000                                                                                                                                                               (not yet saved)
# (2) File where history is saved.
HISTFILE=~/.histfile                                                                                                                                                        (not yet saved)
# (3) Number of lines of history to save to $HISTFILE.
SAVEHIST=1000                                                                                                                                                               (not yet saved)

# (0)  Remember edits and return to main menu (does not save file yet)
# (q)  Abandon edits and return to main menu

--- Type one of the keys in parentheses ---

set histsize to 110000

History configuration
=====================

# (1) Number of lines of history kept within the shell.
HISTSIZE=1000                                                                                                                                                               (not yet saved)
# (2) File where history is saved.
HISTFILE=~/.histfile                                                                                                                                                        (not yet saved)
# (3) Number of lines of history to save to $HISTFILE.
SAVEHIST=1000                                                                                                                                                               (not yet saved)

# (0)  Remember edits and return to main menu (does not save file yet)
# (q)  Abandon edits and return to main menu

--- Type one of the keys in parentheses --- 1
Variable       HISTSIZE
              The maximum number of events stored in the internal history list.  If you use the HIST_EXPIRE_DUPS_FIRST option, setting this value larger than the  SAVEHIST  size  will
              give you the difference as a cushion for saving duplicated history events.

Edit a value.  If it is left blank, nothing will be saved:
HISTSIZE> 110000

press 3 to regulate savehist to 100000

History configuration
=====================

# (1) Number of lines of history kept within the shell.
HISTSIZE=110000                                                              (set but not saved)
# (2) File where history is saved.
HISTFILE=~/.histfile                                                             (not yet saved)
# (3) Number of lines of history to save to $HISTFILE.
SAVEHIST=1000                                                                    (not yet saved)

# (0)  Remember edits and return to main menu (does not save file yet)
# (q)  Abandon edits and return to main menu

--- Type one of the keys in parentheses --- 3
Variable       SAVEHIST
              The maximum number of history events to save in the history file.

Edit a value.  If it is left blank, nothing will be saved:
SAVEHIST> 100000

then press 0 to return to main menu, here we press 2 and then 1 to choose the default option

Please pick one of the following options:

(1)  Configure settings for history, i.e. command lines remembered
     and saved by the shell.  (Unsaved changes.)

(2)  Use the new completion system.  (Unsaved changes.)

(3)  Configure how keys behave when editing command lines.  (Recommended.)

(4)  Pick some of the more common shell options.  These are simple "on"
     or "off" switches controlling the shell's features.

(0)  Exit, saving the new settings.  They will take effect immediately.

(a)  Abort all settings and start from scratch.  Note this will overwrite
     any settings from zsh-newuser-install already in the startup file.
     It will not alter any of your other settings, however.

(q)  Quit and do nothing else.  The function will be run again next time.
--- Type one of the keys in parentheses ---
The new completion system (compsys) allows you to complete
commands, arguments and special shell syntax such as variables.  It provides
completions for a wide range of commonly used commands in most cases simply
by typing the TAB key.  Documentation is in the zshcompsys manual page.
If it is not turned on, only a few simple completions such as filenames
are available but the time to start the shell is slightly shorter.

You can:
  (1)  Turn on completion with the default options.

  (2)  Run the configuration tool (compinstall).  You can also run
       this from the command line with the following commands:
        autoload -Uz compinstall
        compinstall
       if you don't want to configure completion now.

  (0)  Don't turn on completion.

--- Type one of the keys in parentheses ---

then we press 0 in the main menu to exit and save

The function will not be run in future, but you can run
it yourself as follows:
  autoload -Uz zsh-newuser-install
  zsh-newuser-install -f

The code added to ~/.zshrc is marked by the lines
# Lines configured by zsh-newuser-install
# End of lines configured by zsh-newuser-install
You should not edit anything between these lines if you intend to
run zsh-newuser-install again.  You may, however, edit any other part
of the file.
DESKTOP-EGAF37T%

download ohmyzsh appimage

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

let’s update .zshrc file

vim ~/.zshrc
plugins=(
git
zsh-autosuggestions
)

navigate to plugins directory

cd ~/.oh-my-zsh/plugins

Clone ZSH Autosuggest from GitHub

git clone https://github.com/zsh-users/zsh-autosuggestions.git