Pintaste Pintaste

Setting Up Oh My Zsh on Ubuntu

1 min read 81 words 阅读中文版

System Information

  • Ubuntu 22.10 kinetic

Install zsh

echo $SHELL             # Check the current shell
cat /etc/shells         # List installed shells on the system
sudo apt update && apt full-upgrade -y
sudo apt install zsh -y # Install zsh

Set zsh as the Default Shell

sudo chsh -s /bin/zsh
sudo reboot # Reboot the system
echo $SHELL # Verify the switch was successful

Install Oh My Zsh

sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

Configure Oh My Zsh Theme

# Open the configuration file
vim ~/.zshrc 
# Change the theme
ZSH_THEME="random"
# Apply the changes
source ~/.zshrc 

Official Themes - ohmyzsh/ohmyzsh Wiki

ZSH_THEME="" disables any theme.

ZSH_THEME="random" picks a random theme each time.

echo $RANDOM_THEME prints the name of the current theme.

To choose a random theme from a list of favorites:

ZSH_THEME="random"

ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "cloud" )

Install Powerline Fonts

sudo apt install fonts-powerline -y

Configure Oh My Zsh Plugins

Syntax Highlighting Plugin - zsh-syntax-highlighting

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

Auto-suggestions Plugin - zsh-autosuggestions

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

.zshrc File Configuration

 # Open the configuration file
vim ~/.zshrc
 # Find  plugins=(xxx)
plugins=(git extract zsh-syntax-highlighting zsh-autosuggestions)
 # Save and exit vim
source ~/.zshrc # Apply the changes

Note: zsh-autosuggestions must always be placed last to work correctly.

CC BY-NC-SA 4.0 · pintaste

Comments

Giscus comments activate once PUBLIC_GISCUS_* env vars are set.