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

Teerawat Namsricharoensuk

--

Example UI of Terminator with combination

เมื่อวานผมได้เจอบทความนึงใน medium ซึ่งได้เขียนเกี่ยวกับการปรับปรุงให้ terminal ของเราบน MacOS น่าใช้มากขึ้น

แต่เครื่อง PC ที่บริษัทดันเป็น Ubuntu Desktop Bionic (Gnome) นี่สิ เพื่อให้การทำงานของเรา smooth ก็เลยทำให้ environment ของการใช้งานเหมือนกันในทุกๆที่

หัวข้อ

  1. โปรแกรมที่ติดตั้งใช้งาน
  2. ขั้นตอนการติดตั้ง และตั้งค่า terminal

โปรแกรมที่ติดตั้ง

  1. Terminator
  2. ZSH
  3. Oh My Zsh
  4. Nerd fonts
  5. Powerlevel9k zsh theme
  6. Extra: Rubygem + Colorls
  7. Custom ~/.zshrc config file

ขั้นตอนติดตั้ง และตั้งค่า

  1. สำหรับการติดตั้ง 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

Terminator Preferences

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

Inspiration

  1. https://gist.github.com/matthewjberger/7dd7e079f282f8138a9dc3b045ebefa0
  2. http://diego-pacheco.blogspot.com/2017/07/linux-power-terminal-with-oh-my-zsh-and.html
  3. https://medium.com/the-code-review/make-your-terminal-more-colourful-and-productive-with-iterm2-and-zsh-11b91607b98c

--

--

No responses yet

Write a response