描述:
用于安装和配置Mac终端工具
iTerm
,同时对界面进行个性化配置、提效插件推荐,助你打造专属终端神器。目的:
原生终端的完美替代方案,解决原生终端操作不太方便,界面可定制化程度低的种种问题。
最终效果:
目录
一、下载安装
二、主题配置
2.1 基础主题配置
2.2 配置Oh My Zsh
安装
脚本安装
原生安装
配置
三、配置Meslo字体
四、其他配置
4.1 声明高亮
安装
配置
4.2 自动填充建议
4.3 快速隐藏和显示iTerm窗口
4.4 隐藏用户名和主机信息
4.5 自定义配置上方显示CPU、内存、网络等信息
4.6 查询历史记录和遍历目录文件
4.7 命令行支持vim快捷键操作
五、F&A
5.1 如何卸载oh-my-zsh
5.2 iTerm主题字体配置后,打开Mac自带的终端时出现乱码问题。
六、附录
6.1 iTerm快捷键
下载地址:
中文版
官方版
下载后双击可直接安装。
通过brew
安装
brew cask install iterm2
command + ,
或点击左上角进入偏好设置页配置文件具体路径 ⬇️
导入后,选择应用配置,效果如下 ⬇️
On my zsh是对主题的进一步扩展。
# curl命令
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# wget命令
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# clone仓库到本地
git clone https://github.com/ohmyzsh/ohmyzsh.git
# 把仓库复制到 .oh-my-zsh目录
cp -r ohmyzsh ~/.oh-my-zsh
# 复制.zshrc
cp ohmyzsh/templates/zshrc.zsh-template ~/.zshrc
将默认终端命令配置为zsh
sudo chsh -s /bin/zsh
修改zsh
主题,主题列表:https://github.com/ohmyzsh/ohmyzsh/wiki/themes,选择自己喜欢的,编辑~/.zshrc
文件ZSH_ZSH_THEME
配置项后,保存退出。
# vim ~/.zshrc
ZSH_THEME="agnoster"
# :wq
配置效果如下
可见,存在一些问题,有乱码。。
别急,继续往下看
使用zsh主题后,会导致乱码,需要meslo字体支持
下载字体文件:GitHub:Meslo LG M Regular for Powerline.ttf,备用下载地址,下载后双击安装。
应用字体,打开iTerm,键入command + ,
或点击左上角进入偏好设置页,选择该字体。
退出重新打开iTerm后,效果如下:
zsh-syntax-highlighting
插件为 shell zsh
提供语法高亮显示。当命令在 zsh 提示符下输入到交互式终端时,它可以突出显示命令。
# 使用git
cd ~/.oh-my-zsh/custom/plugins/
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
编辑~/.zshrc
文件,找到plugins
配置项,将该插件插入
❗️ zsh-syntax-highlighting必须为最后一项
然后在末尾添加:
source ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
键入source ~/.zshrc
应用后,重启终端查看下效果:
clonezsh-autosuggestions
项目,到zsh插件目录
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
然后编辑~/.zshrc
文件,plugins
项加入:zsh-autosuggestions
后,source
应用。
应用后看不到效果是因为,提示颜色与当前背景色一致。需设置提示颜色。这里以5c6e73
为例。
效果如下
# vim ~/.zshrc
DEFAULT_USER="你的用户名"
# 应用
source ~/.zshrc
# vim ~/.zshrc
plugins=(
...
fzf
)
Ctrl+R
搜索历史命令
输入**+TAB
查询目录文件
# vim ~/.zshrc
plugins=(
...
vi-mode
)
进入~/.on-my-zsh/tools
目录,依次执行:
sudo chmod +x uninstall.sh
./uninstall.sh
rm -rf ~/.zshrc
解决方法:
打开终端的偏好设置修改字体如下:
命令 |
说明 |
command + t |
新建标签 |
command + w |
关闭标签 |
command + 数字 command + 左右方向键 |
切换标签 |
command + f |
查找 |
command + d |
水平分屏 |
command + shift + d |
垂直分屏 |
command + option + 方向键 |
切换屏幕 |
command + shift + h |
查看剪切板历史 |
ctrl + u |
清除当前行 |
ctrl + l |
清屏 |
ctrl + a |
到行首 |
ctrl + e |
到行尾 |
ctrl + f/b |
前进/后退 |