概述
mac os mojave終端環(huán)境, iTerm2 + Oh my zsh + zsh
下載安裝iTerm2
- 官網(wǎng)
- 或者使用brew安裝
brew cask install iterm2
brew cask list
brew install zsh-autosuggestions
-
command+,
打開preference
, 配置喜歡的主題
iTerm2 熱鍵
- iTerm2 部分熱鍵, 見下表:
命令 | 功能 |
---|---|
command + t | 創(chuàng)建新標(biāo)簽頁 |
command + w | 退出標(biāo)簽頁 |
command +數(shù)字 or 方向鍵 | 切換標(biāo)簽頁 |
command + d | 垂直分屏 |
command + shift + d | 水平分屏 |
command + enter | 全屏切換 |
ctrl + l | 清理屏幕 |
ctrl + u | 清理當(dāng)前行 |
ctrl + a | 到行首 |
ctrl + e | 到行尾 |
ctrl + r | 搜索歷史命令 |
切換到zsh
- shell切換
chsh -s /bin/zsh
# 完成后痪寻,退出iTerm2,再次進入
chsh -s /bin/bash
# which shell supported
cat /etc/shells
# 配置zsh主題, vim ~/.zshrc:
ZSH_THEME="agnoster"
- 切換主題后牺弄,有亂碼,下載字體Meslo修復(fù)Meslo LG L Regular for Powerline.ttf
打開iterm2典鸡,command+,
進入preference->text->Font, change font, 選擇Meslo...字體即可
-
vscode
terminal字體配置阅茶,vscode 首選項搜索fontFamily
,terminal->integrated->fontFamily
,增加Meslo LG M for Powerline
安裝 oh my zsh
安裝
- github
- mac os默認安裝了zsh蛛枚,直接安裝oh-my-zsh
curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh
# 創(chuàng)建~/.zshrc(如果不存在時)
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
zsh 語法高亮
此部分須先安裝Homebrew(Mac),這里不說怎么安裝Homebrew。
執(zhí)行以下命令:
brew install zsh-syntax-highlighting
# 在.zshrc中追加以下內(nèi)容:
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
自動建議
- 可以用brew安裝
brew install zsh-autosuggestions
# vim .zshrc
source /usr/local/Cellar/zsh-autosuggestions/0.5.0/share/zsh-autosuggestions/zsh-autosuggestions.zsh
- 或者
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
#vim .zshrc,找到plugins配置脸哀,增加:
zsh-autosuggestions
其他配置
- 隱藏prompt的用戶名提示
#vim .zshrc, 增加
DEFAULT_USER="your name"
# 需要時查看:
whoami
- ssh key
ssh-keygen -t rsa -b 4096
# copy to clipboard
pbcopy < ~/.ssh/id_rsa.pub