Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iTerm2 + Oh My Zsh 安裝&設定 #6

Open
JeffKko opened this issue Apr 23, 2019 · 0 comments
Open

iTerm2 + Oh My Zsh 安裝&設定 #6

JeffKko opened this issue Apr 23, 2019 · 0 comments
Labels
Mac OS X This issue or pull request already exists

Comments

@JeffKko
Copy link
Owner

JeffKko commented Apr 23, 2019

iTerm2 + Oh My Zsh 安裝&設定

安裝 brew (有裝過 brew 可以跳過此步驟)

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

安裝 iTerm2

$ brew cask install iterm2

安裝好後設定 color scheme 為 Solarized Dark

安裝 Oh My Zsh

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

看看是否成功

$ zsh --version

把預設的終端機改為zsh

$ sudo sh -c "echo $(which zsh) >> /etc/shells"
$ chsh -s $(which zsh)

重新開啟終端機, 輸入

$ echo $SHELL

成功的話會顯示 /usr/local/bin/zsh

更改設定檔

$ vi ~/.zshrc

找到 ZSH_THEME=”…” , 修改主題為 tonotdo

安裝 Oh My Zsh 外掛

Auto Suggestions

酷酷的會提示打過的字, 按方向鍵右可以直接補完

$ git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions

一樣更改設定檔,以空格分開

plugins=(git zsh-autosuggestions)

背景色會和提示字體太接近而看不到, 這裡可以更改字體顏色

$ vi $ZSH_CUSTOM/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh

找到 ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8', 修改 fg=240

Syntax Highlighting

打出正確的字元後會高亮, 例如 node ,which 以防不小心打錯字

$ brew install zsh-syntax-highlighting

一樣打開設定檔, 在最下面加上這行

# For zsh syntax-highlighting
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

修改 prompt

因為預設的是 user@hostname, 很長很鬧

$ whoami

知道我是誰後

再打開 ZSH 設定檔, 加入下面這段, username 就是剛剛顯示的使用者名稱

# optionally set DEFAULT_USER in ~/.zshrc to your regular username to hide the “user@hostname” info when you’re logged in as yourself on your local machine.
DEFAULT_USER=username

使用鍵盤上的 Home/End 鍵

打開設定檔加入下面這段

bindkey "\033[1~" beginning-of-line
bindkey "\033[4~" end-of-line
@JeffKko JeffKko added the Mac OS X This issue or pull request already exists label Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mac OS X This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

1 participant