Skip to content

Instantly share code, notes, and snippets.

@CodeBrotha
Last active December 1, 2023 04:28
Show Gist options
  • Save CodeBrotha/67241595f304f5e528d085bcf998a384 to your computer and use it in GitHub Desktop.
Save CodeBrotha/67241595f304f5e528d085bcf998a384 to your computer and use it in GitHub Desktop.
WSL Ubuntu: oh-my-zsh Setup:

WSL Ubuntu: oh-my-zsh Setup:

Installing Zsh:

sudo apt install zsh

After installing it, type zsh

zsh will ask you to choose some configuration. We will do this later on while installing oh-my-zsh, so choose option 0 to create the config file and prevent this message from showing again.

Installing oh-my-zsh:

Use curl to install oh-my-zsh:

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

This will clone the repo and replace the existing ~/.zshrc with a template from oh-my-zsh.

Configuring zsh/oh-my-zsh:

First, we need to make sure zsh is executed by default for Bash on Ubuntu. This is not mandatory, but if not done you need to type zsh every time. For this, edit the .bashrc file with nano: nano ~/.bashrc and paste this right after the first comments:

if test -t 1; then
  exec zsh
fi

Save it and restart your Ubuntu shell. You should be on zsh by default now.

To view or edit your Zsh configuration you will edit the .zshrc file from now on:

nano ~/.zshrc

Installing Node via NVM:

First, install the plugin by cloning in the zsh-nvm repo.

git clone https://github.com/lukechilds/zsh-nvm ~/.oh-my-zsh/custom/plugins/zsh-nvm

Then add it as a plugin in the ~/.zshrc file.

plugins=(git zsh-nvm)

Then reload the .zshrc file, and you’ll see nvm being installed:

source ~/.zshrc

Usage :

nvm install node

Test that Node is installed by running:

node -v
npm -v

Installing Yarn:

npm install --global yarn

Test that Yarn is installed by running:

yarn -v

Installing Purer theme:

Obviously you can install whichever theme you prefer. You can see plenty of choices here: https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes

I personally prefer Purer: https://github.com/DFurnes/purer

Install Purer using NPM:

npm install --global purer-prompt

Add the following to your .zshrc if not automagically symlinked:

fpath+=($fpath '/home/tineyi/.nvm/versions/node/v21.1.3.0/lib/node_modules/purer-prompt/functions') 

To initialize the prompt system (if not so already) and choose Purer, add this to your .zshrc file:

autoload -U promptinit; promptinit
prompt purer

Installing zsh-autosuggestions:

Clone the repository into $ZSH_CUSTOM/plugins (by default ~/.oh-my-zsh/custom/plugins)

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Add the plugin to the list of plugins for Oh My Zsh to load (inside ~/.zshrc):

You may want to add other plugins. For example, ssh-agent plugin will start the ssh-agent automatically if it’s not running the first time that you fire up the WSL. (You'll be prompted for your SSH key passphrase every time WSL is started fresh. So basically anytime you reboot your computer.)

plugins=(git vscode zsh-nvm zsh-autosuggestions ssh-agent)

Start a new terminal session, or reload the .zshrc file again, and you should be all set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment