Make colorful terminal with Terminator, ZSH and Powerlevel9K on Ubuntu Bionic

เมื่อวานผมได้เจอบทความนึงใน medium ซึ่งได้เขียนเกี่ยวกับการปรับปรุงให้ terminal ของเราบน MacOS น่าใช้มากขึ้น
แต่เครื่อง PC ที่บริษัทดันเป็น Ubuntu Desktop Bionic (Gnome) นี่สิ เพื่อให้การทำงานของเรา smooth ก็เลยทำให้ environment ของการใช้งานเหมือนกันในทุกๆที่
หัวข้อ
- โปรแกรมที่ติดตั้งใช้งาน
- ขั้นตอนการติดตั้ง และตั้งค่า terminal
โปรแกรมที่ติดตั้ง
- Terminator
- ZSH
- Oh My Zsh
- Nerd fonts
- Powerlevel9k zsh theme
- Extra: Rubygem + Colorls
- Custom
~/.zshrc
config file
ขั้นตอนติดตั้ง และตั้งค่า
- สำหรับการติดตั้ง
Terminator
(ใช้แทน iTerm2)
sudo apt update
sudo apt install -y terminator
2. ต่อด้วย ZSH
sudo apt install -y zsh
เปลี่ยน default shell ให้เป็น zsh
chsh -s $(which zsh)
3. ติดตั้ง Oh My Zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
4. โหลด Nerd Fonts
cd ~/.fonts && curl -fLo "Droid Sans Mono for Powerline Nerd Font Complete.otf" https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/DroidSansMono/complete/Droid%20Sans%20Mono%20Nerd%20Font%20Complete.otf
Run command to rebuild the font cache
fc-cache -fv
เปลี่ยน font ของ terminator
โดยการคลิกขวาบนหน้า terminal -> เลือก Preferences
จากนั้นให้เอาติ๊กถูกออกจาก Use the system fixed width font
และเลือกฟอนต์เป็น DroidSanMono Nerd Font Book

5. Clone Powerlevel9k
theme
git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
6. Extra: Install colorls
command
sudo apt install -y ruby ruby-dev ruby-colorize libncurses5-dev libtinfo-dev
sudo gem install colorls
7. Edit vim ~/.zshrc
file
#...snippet# User configuration
POWERLEVEL9K_MODE='nerdfont-complete'
ZSH_THEME="powerlevel9k/powerlevel9k"
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
custom_githublogo dir vcs newline virtualenv
)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status ram load time)
POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
# custom github logo
POWERLEVEL9K_CUSTOM_GITHUBLOGO="echo -n '\uf113'"
POWERLEVEL9K_CUSTOM_GITHUBLOGO_FOREGROUND="black"
POWERLEVEL9K_CUSTOM_GITHUBLOGO_BACKGROUND="white"#...snippet
# ALIAS - colorls
alias lsca='colorls -lA --sd'
alias lsc='colorls'
Finally, run it by this command:
source ~/.zshrc