菜单
登录注册
欢 迎
登录
自动登录
忘记密码?
新朋友
注册
注册
老朋友
登录
笔记内容为空!
TA的笔记树 >>
iTerm2主题配置与常用技巧
开发工具
## iTerm2主题配置与常用技巧 [TOC] ### 序 - 系统:macOS Sierra 10.12.6 - iTerm2版本:3.1.4 > 最终效果:  ### 下载安装 1. 官网下载压缩包:http://www.iterm2.com/downloads.html 2. 双击解压,将`iTerm2.app`拷贝到`应用程序` 完成安装! ### 配置主题(可百度找最新配置: oh my zsh) - 打开iTerm2 - 执行命令:`curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh` - 执行命令:`sudo easy_install pip` - 执行命令:`pip install powerline-status` - 安装字体库 > - git地址:https://github.com/powerline/fonts > - 下载解压后,执行`./install.sh` > - 在iTerm2中配置  - 安装配色方案 > - git地址:https://github.com/altercation/solarized > - 下载解压后,找到iTerm2的配色方案:`solarized/iterm2-colors-solarized` >> 双击 `Solarized Dark.itermcolors` > > - 在iTerm2中配置(若未找到,重启iTerm2)  - 配置agnoster主题(可不弄,常用就是git项目会列出部分信息,但太长了) > - git地址:https://github.com/fcamblor/oh-my-zsh-agnoster-fcamblor > - 下载解压后执行里面的`install`文件 > - 修改文件:`vi ~/.zshrc` >> ``` ZSH_THEME="agnoster" ``` - 配置指令高亮(zsh-syntax-highlighting) > - git地址:https://github.com/zsh-users/zsh-syntax-highlighting > 下载解压压缩文件,拷贝目录所有文件到自定义目录,如:~/zsh-syntax-highlighting > 修改文件:`vi ~/.zshrc`,在文件最后添加: >> ``` source ~/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh plugins=(zsh-syntax-highlighting) ``` > > - 重启iTerm2,若在最上文没有错误或警告则表示配置成功 - 完成! ps: 配置后,`~/.zshrc`相当于文件:`~/.bash_profile` ### 常用命令 |命令|描述| |- |⌘ + n|新建窗口| |⌘ + t|新建标签页| |⌘ + w|关闭当前页| |⌘ + 数字 或 ⌘ + 方向键|切换标签页| |⌘ + enter|切换全屏| |⌘ + d|左右分屏| |⇧⌘ + d|上下分屏| |⌘ + ;|自动补全历史记录| |⇧⌘ + h|自动补全剪贴板历史| |⌥⌘ + e|查找所有来定位某个标签页| |⌘ + r 或 ⌃ + l|清屏| |⌘ + /|显示光标位置| |⌥⌘ + b|历史回放| |⌘ + f|查找,然后用 tab 和 ⇧ + tab 可以向右和向左补全,补全之后的内容会被自动复制, 还可以用 ⌥ + enter 将查找结果输入终端| |⌘ + o 或 ⇧⌘ + b|打个profile列表| |⇧⌘ + e|打开/关闭操作时间轴| ### 设置自动SSH远程登录服务器 - 创建脚本文件,名称任意(如:`touch ~/.ssh/login`)添加内容: ``` #!/usr/bin/expect # 解决自动登录后使用vi编辑错乱问题 trap { set rows [stty rows] set cols [stty columns] stty rows $rows columns $cols < $spawn_out(slave,name) } WINCH set timeout 30 spawn ssh -p [lindex $argv 3] [lindex $argv 1]@[lindex $argv 0] expect { "(yes/no)?" {send "yes\n";exp_continue} "password:" {send "[lindex $argv 2]\n"} } interact ``` - 打开iTerm2配置页,添加一个`profile`,在`Command`中输入: ``` 脚本绝对路径 ip地址 用户名 密码 端口号 如: expect ~/.ssh/login 127.0.0.1 root root123 22 ``` 如图所示:  > 注意: 上图第3步中,命令开头少了`expect ` - 右击iTerm2内容框找到新建的`profile`即可连接 ### 设置rzsz 参考:http://blog.csdn.net/citywolf4/article/details/49071679 - 安装lrzsz > - mac:`$ brew install lrzsz` > - linux:`$ yum install lrzsz` 或 `$ apt-get install lrzsz` - 下载zmoden脚本 1. git:https://github.com/mmastrac/iterm2-zmodem 2. 下载:iterm2-send-zmodem.sh(上传脚本)/ iterm2-recv-zmodem.sh(下载脚本) > 本文提供俩脚本具体内容: ``` #!/bin/bash # Author: Matt Mastracci (matthew@mastracci.com) # AppleScript from http://stackoverflow.com/questions/4309087/cancel-button-on-osascript-in-a-bash-script # licensed under cc-wiki with attribution required # Remainder of script public domain osascript -e 'tell application "iTerm2" to version' > /dev/null 2>&1 && NAME=iTerm2 || NAME=iTerm if [[ $NAME = "iTerm" ]]; then FILE=`osascript -e 'tell application "iTerm" to activate' -e 'tell application "iTerm" to set thefile to choose file with prompt "Choose a file to send"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")"` else FILE=`osascript -e 'tell application "iTerm2" to activate' -e 'tell application "iTerm2" to set thefile to choose file with prompt "Choose a file to send"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")"` fi if [[ $FILE = "" ]]; then echo Cancelled. # Send ZModem cancel echo -e \\x18\\x18\\x18\\x18\\x18 sleep 1 echo echo \# Cancelled transfer else /usr/local/bin/sz "$FILE" -e -b sleep 1 echo echo \# Received $FILE fi ``` > ↑↑↑ `iterm2-send-zmodem.sh` ``` #!/bin/bash # Author: Matt Mastracci (matthew@mastracci.com) # AppleScript from http://stackoverflow.com/questions/4309087/cancel-button-on-osascript-in-a-bash-script # licensed under cc-wiki with attribution required # Remainder of script public domain osascript -e 'tell application "iTerm2" to version' > /dev/null 2>&1 && NAME=iTerm2 || NAME=iTerm if [[ $NAME = "iTerm" ]]; then FILE=`osascript -e 'tell application "iTerm" to activate' -e 'tell application "iTerm" to set thefile to choose folder with prompt "Choose a folder to place received files in"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")"` else FILE=`osascript -e 'tell application "iTerm2" to activate' -e 'tell application "iTerm2" to set thefile to choose folder with prompt "Choose a folder to place received files in"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")"` fi if [[ $FILE = "" ]]; then echo Cancelled. # Send ZModem cancel echo -e \\x18\\x18\\x18\\x18\\x18 sleep 1 echo echo \# Cancelled transfer else cd "$FILE" /usr/local/bin/rz -E -e -b sleep 1 echo echo echo \# Sent \-\> $FILE fi ``` > ↑↑↑ `iterm2-recv-zmodem.sh` - 将俩脚本放到自定义目录,如: ``` /User/vanki/iterm2_conf/iterm2-send-zmodem.sh /User/vanki/iterm2_conf/iterm2-recv-zmodem.sh ``` - 配置iterm2 trigger 1. 打开iterm2 2. 快捷键`command + ,`打开配置 -> `Profiles` -> `Default` -> `Advanced` -> `Triggers`的`Edit`按钮,在弹出的界面配置以下参数: |Regular Expression|Action|Parameters|Instant| |- |\\\*\\\*B0100|Run Silent Coprocess|/User/vanki/iterm2_conf/iterm2-send-zmodem.sh|`选中`| |\\\*\\\*B00000000000000|Run Silent Coprocess|/User/vanki/iterm2_conf/iterm2-recv-zmodem.sh|`选中`| 如图:  > ps:可以快捷将选中的profile配置复制给其它profile中,操作如下: >> 快捷键`command + ,`打开配置 -> `Profiles` > 左下角:Other Actions -> Bulk Copy From Selected Profile... ### 如果遇到中文乱码如下情况  作如下修改:  ### 设置tab标题动态展示当前目录 1. vim ~/.zshrc ``` # 关闭AUTO_TITLE DISABLE_AUTO_TITLE="true" # 设置标题栏 function precmd () { print -Pn - '\e]0;$PWD~\a' } # $PWD -> 全部目录 # %1 -> 父级目录 # %2 -> 两层父级目录 ``` 2. 打开修改title开关 ``` Preferences -> Profiles -> General -> Applications in terminal may change the title(勾选) ``` 3. 重启iterm2 或 打开新窗口
vanki
我李某相貌堂堂,妻子花容月貌,岂会生出你这种山野莽夫呢?
浏览:
9931
创建:
2017-11-04 04:51:35
更新:
2021-04-19 17:54:35
TA的最新笔记
spring-boot配置redis多数据源
linux源修改(阿里)
python安装postgresql依赖
arthas使用
java基于spring的NamedParameterJdbcTemplate封装的获取sql工具类
Impala添加负载
S3常用使用
redis常用操作
hdfs相关命令
crontab使用
TA的最热笔记
java异步http请求工具类(org.asynchttpclient)
iTerm2主题配置与常用技巧
java基于spring.redisTemplate实现分布式锁工具类
Kotlin + SpringBoot + JPA(Hibernate) + Repository自定义方法
IDEA汉化
Sequel Pro连接mysql8打开数据库报错
centos-Hadoop2.7.3完全分布式搭建(HA)
SpringBoot上传文件报错(The temporary upload location [..] is not valid)
mac常用软件
kotlin对象属性值拷贝工具类