iterm2 常用操作
iterm2 常用操作
本文档介绍 iterm2 常用操作 的相关内容。
iTerm2 自定义快捷键
问题 通过iterm2访问服务器时,通常会输入一些简单的密码信息,如何快捷键入这些简单的密码,避免频繁输入呢? 解决方法 可以通过iterm2提供的快捷键功能来解决: iterm2 》preferences 》keys 》+ 然后选择一个快捷键,比如F1,**acton** 选择 **send text**,在下面的文本框中输入指定的文本,比如:password123123,然后点击ok退出即可。 用法:比如在iterm2中ssh登陆主机,在提示输入密码的地方按下F1,然后回车即可。 iterm2 配置rz sz上传下载
# 安装 brew install lrzsz # 下载zmodem git clone https://github.com/mmastrac/iterm2-zmodem cd iterm2-zmodem mv iterm2-* /usr/local/bin # 或直接创建两个文件 # iterm2-recv-zmodem.sh 文件 # !/bin/bash # Author: Matt Mastracci (your.email@example.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-send-zmodem.sh 文件 # !/bin/bash # Author: Matt Mastracci (your.email@example.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 # 配置rz sz 上传下载 # 进入到/usr/local/bin目录 cd /usr/local/bin chmod -R 777 iterm2-* # 配置iTerm2 添加rz sz 功能 # 点击iTerm2的设置界面Perference-> Profiles -> Default -> Advanced -> Triggers 的 Edit 按钮 # 添加以下内容 Regular expression: rz waiting to receive.\*\*B0100 Action: Run Silent Coprocess Parameters: /usr/local/bin/iterm2-send-zmodem.sh Regular expression: \*\*B00000000000000 Action: Run Silent Coprocess Parameters: /usr/local/bin/iterm2-recv-zmodem.sh 本文由作者按照 CC BY 4.0 进行授权