➣ Reading Time: 8 minutes

install zsh, oh-my-zsh

#!/bin/bash
echo "[1/5] update system"
sudo apt-get update -y
sudo apt-get upgrade -y

echo "[2/5] install zsh"
sh -c "(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
sudo apt-get install zsh -y

echo "[3/5] Show all current shells"
cat /etc/shells
echoSHELL

echo "[4/5] install oh-my-zsh"
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

echo "[5/5] change default shell to zsh shell"
chsh -s /bin/zsh
#grep pi /etc/passwd #check change shell in /etc/passwd

install powerlevel10k

#!/bin/bash
# ----- powerlevel10k theme ------ #
echo "install powerlevel10k"
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>! ~/.zshrc

echo "[restart] restart zsh"
source ~/.zshrc

[optional] 修改設定檔 (需修改 ~/.zshrc, ~/.p10k.zsh 文件)

echo "[optional] set ~/.zshrc (zsh settings)"
vim ~/.zshrc

echo "[optional] set ~/.p10k.zsh (powerlevel10k settings)"
cp ~/.p10k.zsh ~/.p10k.zsh.bak # backup
#p10k configure # GUI version
vim ~/.p10k.zsh

echo "[restart] restart zsh"
source ~/.zshrc

(optional) 下載字體 (Nerd font, powerline font)

其他網站提供的下載的方式很多不能用了,另外如果將整包字體打包下載檔案也非常的巨大,因此參考其中一篇文章提供的方法,直接下載我們要的字體包。

字體載點:https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/SourceCodePro.zip

我是安裝裡面的以下字體:

  • Sauce Code Pro ExtraLight Nerd Font Complete.ttf
  • Sauce Code Pro ExtraLight Nerd Font Complete Mono.ttf

(optional) install zsh plugins

zsh 好用的插件,我推薦以下兩個,自動完成與自動標示指令。

因為插件的關係,下面的”$”符號會被吃掉,
如果使用指令無法順利安裝,請參考官網的安裝指南:

#!/bin/bash
# ----- install zsh plugins ------ #

echo "[optional] install Syntax Highlighting Plugin"
# doc: https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/INSTALL.md
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git {ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

echo "[optional] install ZSH-AutoSuggestion Plugin"
# doc: https://github.com/zsh-users/zsh-autosuggestions/blob/master/INSTALL.md
git clone https://github.com/zsh-users/zsh-autosuggestions{ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

設定 plugins (需修改 ~/.zshrc 文件)

echo "[optional] set ~/.zshrc to use plugins"
vim ~/.zshrc
plugins=(
git
zsh-syntax-highlighting
zsh-autosuggestions
)

echo "[restart] restart zsh"
source ~/.zshrc

Reference