iTerm2的安装
1. 直接官网下载
下载地址: https://www.iterm2.com/downloads.html
下载的是压缩文件
,解压后直接双击执行程序文件,或者直接将它拖到 Applications 目录下即可。
2. 使用Homebrew安装
brew cask install iterm2
Homebrew
的安装(已安装Homebrew的请忽略此操作)
# install brew
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
# uninstall brew
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh)"
# cat version
brew -v
# update
brew update
# 自检
/usr/local/bin/brew doctor
iTerm2的配置
1. 配置Oh My Zsh
Oh My Zsh
是对主题的进一步扩展,下载地址https://github.com/robbyrussell/oh-my-zsh
- 一键安装:
wget
方式
$sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
wget
的安装(已安装Wget的请忽略此操作)
# install
brew install wget
# 查看版本
wget —version
- 手动安装 :
git
地址https://github.com/ohmyzsh/ohmyzsh
# clone到本地
git clone https://github.com/ohmyzsh/ohmyzsh.git
# 复制文件夹
cp -r ohmyzsh ~/.oh-my-zsh
# 复制配置文件
cp ohmyzsh/templates/zshrc.zsh-template ~/.zshrc
# 切换shell
chsh -s /bin/zsh
打开终端发现权限问题,解决如下:
chmod 755 /usr/local/share/zsh
chmod 755 /usr/local/share/zsh/site-functions
# 修改配置文件
vim ~/.zshrc
输入i
进入编辑模式
,将ZSH_THEME=
""编辑为 ZSH_THEME="agnoster"
按下esc
键,退出编辑,:wq
保存退出。
2. 配置iTerm2的主题
Dracula
主题:https://blog.csdn.net/daiyuhe/article/details/88667875
iTerm2
最常用的主题是 Solarized Dark theme
,下载地址:
http://ethanschoonover.com/solarized
https://github.com/altercation/solarized github地址
# clone到本地
git clone https://github.com/altercation/solarized.git
打开 iTerm2
,按Command +,
键,打开 Preferences
配置界面,然后 Profiles
-> Colors
-> Color Presets
,在下拉列表中选择 Import
,选择clone到本地的solarized
->iterm2-colors-solarized
->Solarized Dark.itermcolors
文件。导入成功后,在 Color Presets
下选择 Solarized Dark
主题,就可以了。
3. 设置 iTerm2 的背景图片
打开 iTerm2,按Command +,
键,打开Preferences
配置界面Profiles
-> Window
->Background mage
,选择一张自己喜欢的背景图。
4. 配置Meslo字体
使用 Solarized Dark
主题,需要 Meslo
字体支持,要不然会出现乱码的情况。
- 安装
PowerLine
(状态栏工具 )
- 先安装pip命令 :pip是python的一个维护命令
#方式一
sudo easy_install pip
#方式二:下载脚本文件 get-pip.py
curl 'https://bootstrap.pypa.io/get-pip.py' > get-pip.py
# 执行脚本文件
sudo python3 get-pip.py
- 安装Powerline:(—user好像是表示基于用户的权限)
pip install powerline-status --user
- 安装
PowerFonts
字体
#—depth=1表示值clone最近一次commit的
git clone https://github.com/powerline/fonts.git --depth=1
cd fonts
# 运行install shell
./install.sh
然后打开iTerm2
,按Command + ,
键,打开Preferences
配置界面,然后Profiles
-> Text
-> Font
->Chanage Font
,选择 Meslo LG S Regular for Powerline
字体。
5. 配置高亮
配置后,特殊
命令和错误
命令,会有高亮显示。
- 使用brew安装
# install
brew install zsh-syntax-highlighting
# uninstall
brew uninstall zsh-syntax-highlighting
- clone到本地安装
cd ~/.oh-my-zsh/custom/plugins/
# clone到本地
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
# 编辑配置文件
vim ~/.zshrc
输入i
进入编辑模式
,将plugins=
""编辑为 plugins=(git zsh-syntax-highlighting)
,如图
注意
:要保证zsh-syntax-highlighting
在plugins
字段的最后一个
再在配置文件最后一行增加下面配置:
#git方式安装
source ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
#brew方式安装,则用以下配置
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
然后按下esc
键退出编辑,输入:wq
保存退出。如图
6. 配置自动建议填充
这个功能是非常实用的,可以方便我们快速的敲命令。
# clone到指定目录
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
# 编辑配置文件
vim ~/.zshrc
输入i
进入编辑模式
,将plugins=
""编辑为 plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
,然后按下esc
键退出编辑,输入:wq
保存退出。如图
注意
:要保证zsh-syntax-highlighting
在plugins
字段的最后一个
7. 配置快速隐藏和显示iTerm2 窗口
打开 iTerm2
,按Command + ,
键,打开Preferences
配置界面,然后Profiles
→ Keys
→Hotkey
,自定义一个快捷键即可。如图:
8. iTerm2的快捷指令
在iterm2
中,选中某个路径或者某个词汇,iterm2
就自动复制
了,很方便。
command + enter 进入与返回全屏模式
command + t 新建标签
command + w 关闭标签
command + 数字 command + 左右方向键 切换标签
command + enter 切换全屏
command + f 查找
command + d 水平分屏
command + shift + d 垂直分屏
command + option + 方向键 command + [ 或 command + ] 切换屏幕
command + ; 查看历史命令
command + shift + h 查看剪贴板历史
ctrl + u 清除当前行
ctrl + l 清屏
ctrl + a 到行首
ctrl + e 到行尾
ctrl + f/b 前进后退
ctrl + p 上一条命令
ctrl + r 搜索命令历史
9. 配置autojump
- git方式下载
git clone https://github.com/joelthelion/autojump.git
- 进入autojump文件夹
cd autojump
- 执行脚本文件
. /install.py
- 如果提示找不到
python
但又安装了python
,建立软链接
#查看python的位置
which python3
#位置为/Library/Frameworks/Python.framework/Versions/3.11/bin/python3
#建立软链接
ln -s /Library/Frameworks/Python.framework/Versions/3.11/bin/python3 /Library/Frameworks/Python.framework/Versions/3.11/bin/python
- 修改配置文件
vim ~/.zshrc
在配置文件中添加以下代码:
# Add wisely, as too many plugins slow down shell startup.
plugins=(
git
autojump
zsh-autosuggestions
zsh-syntax-highlighting
)
[[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.sh
- 让配置文件生效
source ~/.zshrc
10.Go2Shell实现在文件目录中打开iTerm2
待更新