🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] # 简介 [iTerm2](https://www.iterm2.com/) 是mac 上一款非常好用的命令行工具,具有一些比自带的 terminal 更好用的特性。 提供了诸如Split Panes等一群实用特性。它默认的黑色背景让我毫不犹豫的抛弃了 Terminal。 # 安装: ~~~ brew install iterm2 --cask ~~~ # 特性 1. 选择即复制:在 iTerm2 界面,选择了一行,不用执行`command + c`就已经复制了 2. 可以保留 ssh 链接账户信息,在 Profile 里进行设置 3. 全文查找,按下`command + f`即可 4. 分屏:iTerm2 可以分很多个显示界面,每个都是一个新的窗口,这样子可以不用等待上一个命令结束就输入下一个命令,方便操作。 # 设置 **iTerm2 - Preferences - Profiles - Text - Text Rendering**,将 Draw bold text in bright colors 前面的勾去掉. 然后重启 iterm2 看看。 # iTerm2 配置文件 ## 保存配置文件 看一下`Preferences -> General -> Preferences`,在面板底部有一个设置`Load Preferences from a custom folder or URL`,它旁边有一个按钮`Save settings to folder`,点击到处配置! 最后可以看到文件名为:`com.googlecode.iterm2.plist`的 plist( Apple Property Lists)格式文件 > 如果“Save settings to Folder”被禁用,勾选☑️ `Load preferences from a custom folder or URL` ,然后,再选择一个文件夹(例如`Download`)。 > [How to export iTerm2 Profiles](https://stackoverflow.com/a/23356086) ## 导入配置文件 1. 官方导入配置文件 > 官方已提供了导入配置文件的方法:[documentation-dynamic-profiles](https://www.iterm2.com/documentation-dynamic-profiles.html)。 iTerm 会监控`~/Library/Application Support/iTerm2/DynamicProfiles`路径,如果发现该路径下有新的文件,且符合要求即会加载为配置文件,也支持`JSON`等格式。 因此只需把原来的配置文件`com.googlecode.iterm2.plist`拷贝到指定目录即可。加载成功后可点击菜单`Preferences -> Profiles`找到加载的配置文件。 2. 当然也可以通过 `Preferences -> General -> Preferences -> Load Preferences from a custom folder or URL` ,在线应用配置文件! # color scheme https://hub.fastgit.org/MartinSeeler/iterm2-material-design https://hub.fastgit.org/wesbos/Cobalt2-iterm 如果使用了 zsh 的话,用户的环境变量设置变为: ~~~ ~/.zshrc ~~~ zsh 的配置文件不再是`/.zsh_profile`去调用`/.zshrc`,而是直接就是`/.zshrc`就可以了。所以对于zsh的一切设置,直接去`/.zshrc`中设置。 # 快捷键 ~~~ ----------------分屏-------------------- 1. 垂直分屏:command + d 2. 水平分屏:command + shift + d 3. 切换屏幕:command + option + 方向键 command + [ 或 command + ] 4. 查看历史命令:command + ; 5. 查看剪贴板历史:command + shift + h ----------------分屏-------------------- 7. 新建标签:command + t 8. 关闭标签:command + w 9. 切换标签:command + 数字 command + 左右方向键 10. 切换全屏:command + enter 11. 查找:command + f 12. ----------------分屏-------------------- 13. 清除当前行:ctrl + u 14. 到行首:ctrl + a 15. 到行尾:ctrl + e 16. 前进后退:ctrl + f/b (相当于左右方向键) 17. 上一条命令:ctrl + p 18. 搜索命令历史:ctrl + r 19. 删除当前光标的字符:ctrl + d 20. 删除光标之前的字符:ctrl + h 21. 删除光标之前的单词:ctrl + w 22. 删除到文本末尾:ctrl + k 23. 交换光标处文本:ctrl + t 24. 清屏1:command + r 25. 清屏2:ctrl + l 26. ⌘ + f 所查找的内容会被自动复制 27. ⌘ + r = clear,而且只是换到新一屏,不会想 clear 一样创建一个空屏 28. ctrl + u 清空当前行,无论光标在什么位置 29. 输入开头命令后 按 ⌘ + ; 会自动列出输入过的命令 30. ⌘ + shift + h 会列出剪切板历史 ~~~ # starship [Starship](https://starship.rs/zh-cn/advanced-config/) Starship:用Rust 编写的极简且快速的Shell 提示符 > [Share your custom commands/modules](https://github.com/starship/starship/discussions/1252#discussioncomment-822676) # 技巧 [iterm2有什么酷功能?](https://www.zhihu.com/question/27447370) [使用iTerm2快捷连接SSH访问Linux](http://blog.csdn.net/fangxiaoji/article/details/50710220) # 参考 [iterm-as-a-slide-out-terminal-from-the-top-of-the-screen](https://apple.stackexchange.com/questions/48796/iterm-as-a-slide-out-terminal-from-the-top-of-the-screen) [iterm2有什么酷功能?](https://www.zhihu.com/question/27447370)