概述
mac os mojave终端环境, iTerm2 + Oh my zsh + zsh
下载安装iTerm2
- 官网
- 或者使用brew安装
brew cask install iterm2
brew cask list
brew install zsh-autosuggestions
-
command+,
打开preference
, 配置喜欢的主题
iTerm2 热键
- iTerm2 部分热键, 见下表:
命令 | 功能 |
---|---|
command + t | 创建新标签页 |
command + w | 退出标签页 |
command +数字 or 方向键 | 切换标签页 |
command + d | 垂直分屏 |
command + shift + d | 水平分屏 |
command + enter | 全屏切换 |
ctrl + l | 清理屏幕 |
ctrl + u | 清理当前行 |
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修复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
# 创建~/.zshrc(如果不存在时)
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
zsh 语法高亮
此部分须先安装Homebrew(Mac),这里不说怎么安装Homebrew。
执行以下命令:
brew install zsh-syntax-highlighting
# 在.zshrc中追加以下内容:
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
网友评论