有 Oh-My-Zsh 的終端機真好

Posted in :

之前的Max在使用的 macOS 和 ubuntu 都是使用 bash, 自從用過 oh-my-zsh 之後發現再也回不去 bash 了。

有在使用git 的人,進入 repositories 時,在 prompt 地方還會顯示目前在那一個 brach, 滿實用的。

使用 lll 都可以自動顯示為彩色的 ls -al 很貼心。

還有很多使用上的小細節操作起來也很貼心,像是copy/paste 時的轉場動畫。

還有使用 tab 鍵去自動完成指令時,居然可以猜測到我想完成的檔名。我的使用情境是已經有很多 backup_ 開頭的 .bz2 檔,中間夾雜了一個 .sql 檔案,一般情況下按 tab 應該只有完成 backup_ 開頭就停了,沒想到按下 tab 是自動完成那個夾雜的 .sql 檔案,真的好聰明。

新版的 macOS 10.15 catalina 的 terminal 預設也換成 zsh 了。


Ubuntu 安裝 zsh:

前置準備,需要先安裝下列的套件:

sudo apt-get install wget curl git

Installing Zsh:

sudo apt install zsh

修改預設的 shell 為 zsh:

chsh -s $(which zsh)

檢查目前使用中的 shell:

echo $SHELL

Install Oh-my-Zsh:

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

畫面會詢問:

Looking for an existing zsh config…
Using the Oh My Zsh template file and adding it to ~/.zshrc.

Time to change your default shell to zsh:
Do you want to change your default shell to zsh? [Y/n]

輸入 Y 即可進入 oh-my-zsh 的世界.


macOS 安裝 zsh:

修改預設 shell:

chsh -s /bin/zsh

安裝 oh-my-zsh指令:

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

進階用法:

超簡單!十分鐘打造漂亮又好用的 zsh command line 環境
https://medium.com/statementdog-engineering/prettify-your-zsh-command-line-prompt-3ca2acc967f

APPLE CHANGED THE DEFAULT SHELL FROM BASH TO ZSH, SO DID I
https://pawelgrzybek.com/apple-changed-the-default-shell-from-bash-to-zsh-so-did-i/

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *