当前位置:网站首页>Iterm2 setting
Iterm2 setting
2022-07-03 07:47:00 【nsnsttn】
Item2
1. install item2
Use homebrew install item2
brew install item2
Can open item2 Used
View all shell
cat /etc/shells
View the current shell
echo $SHELL
Switch shell
// Switch to base
chsh -s /bin/bash
// Switch to zsh
chsh -s /bin/zsh
2. Installing a plug-in
install on-my-zsh
install …
Modify the configuration
vim ~/.zshrc
Save configuration
source ~/.zshrc
3. To configure expect automatic logon
Create script
vim alecs.sh
#!/usr/bin/expect -f
set user user name
set host ip Address
set password password
set port Port number ( It's usually 22)
set timeout -1
spawn ssh -o StrictHostKeyChecking=no -p $port $user@$host
expect "*assword:*"
send "$password\r"
interact
expect eof
To configure Iterm2

4. install rz sz Upload and download
mac Upper use brew install lrzsz
brew install lrzsz
Linux Upper use yum install lrzsz
yum install -y lrzsz
stay mac Create two scripts on
- iterm2-recv-zmodem.sh
cd /usr/local/bin
vim iterm2-recv-zmodem.sh
If the execution fails, add sudo
sudo vim iterm2-recv-zmodem.sh
sudo chmod 777 iterm2-*
iterm2-recv-zmodem.sh Content
#!/bin/bash
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 --bufsize 4096
sleep 1
echo
echo
echo \# Sent \-\> $FILE
fi
- iterm2-send-zmodem.sh
cd /usr/local/bin
vim iterm2-send-zmodem.sh
chmod 777 iterm2-*
If the execution fails, add sudo
sudo vim iterm2-send-zmodem.sh
sudo chmod 777 iterm2-*
iterm2-send-zmodem.sh Content
#!/bin/bash
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" --escape --binary --bufsize 4096
sleep 1
echo
echo \# Received $FILE
fi
To configure Iterm2


| Regular expression | Action | Parameters | Instant | Enabled |
|---|---|---|---|---|
| **B00000000000000 | Run Silent Coprocess… | /usr/local/bin/iterm2-recv-zmodem.sh | Will do | √ |
| rz waiting to receive.**B0100 | Run Silent Coprocess… | /usr/local/bin/iterm2-send-zmodem.sh | Will do | √ |
rz : Upload
# stay bash in , That is to say iTerm2 The input terminal rz The file selection box will pop up , Select File choose Start uploading , Will be uploaded to the current directory
rz
Be careful : Alone with rz There will be two questions : Upload interrupted 、 Upload file changes (md5 Different ), The solution is to upload rz -be, And remove the pop-up dialog box “Upload files as ASCII” Check before .
-a, –ascii
-b, –binary use binary The way to upload and download , Do not interpret characters as ascii
-e, –escape mandatory escape All control characters , such as Ctrl+x,DEL etc.
rar,gif And other documents -b use binary Way to upload .
If the file is large and the upload error occurs , Using parameters -e
If you use... Without parameters rz When the command uploads a large file , It is often broken in the middle of uploading , Probably rz It is assumed that the uploaded stream contains some special control characters , cause rz Exit ahead of time .
Sum up , Please use rz -be
sz : download
#sz fileName( The name of the file you want to download ) enter , A window will pop up We can choose the place to save .
sz aaa.txt
5. solve No such file or directory
Use rz perhaps sz This error occurred after
/usr/local/bin/iterm2-send-zmodem.sh: line 17: /usr/local/bin/sz: No such file or directory
as a result of :
Because we use brew install lrzsz, Our script cannot be found in the current directory lrzsz
lrzsz The installation directory can be viewed in this way
brew list lrzsz
/opt/homebrew/Cellar/lrzsz/0.12.20_1/bin/lrb
/opt/homebrew/Cellar/lrzsz/0.12.20_1/bin/lrx
/opt/homebrew/Cellar/lrzsz/0.12.20_1/bin/lrz
/opt/homebrew/Cellar/lrzsz/0.12.20_1/bin/lsb
/opt/homebrew/Cellar/lrzsz/0.12.20_1/bin/lsx
/opt/homebrew/Cellar/lrzsz/0.12.20_1/bin/lsz
/opt/homebrew/Cellar/lrzsz/0.12.20_1/bin/rz
/opt/homebrew/Cellar/lrzsz/0.12.20_1/bin/sz
/opt/homebrew/Cellar/lrzsz/0.12.20_1/share/man/ (2 files)
The key is these two
/opt/homebrew/Cellar/lrzsz/0.12.20_1/bin/rz
/opt/homebrew/Cellar/lrzsz/0.12.20_1/bin/sz
There are two solutions
Mode one : Create a soft connection
stay /usr/local/bin/ Create a soft connection in the directory
sudo ln -s /opt/homebrew/Cellar/lrzsz/0.12.20_1/bin/rz /usr/local/bin/rz
sudo ln -s /opt/homebrew/Cellar/lrzsz/0.12.20_1/bin/sz /usr/local/bin/sz
Mode two : Modify the configuration file
modify iterm2-recv-zmodem.sh
#!/bin/bash
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 --bufsize 4096
#/opt/homebrew/Cellar/lrzsz/0.12.20_1/bin/rz You install lrzsz The path of , The one I just found
/opt/homebrew/Cellar/lrzsz/0.12.20_1/bin/rz -E -e -b --bufsize 4096
sleep 1
echo
echo
echo \# Sent \-\> $FILE
fi
** modify iterm2-send-zmodem.sh **
#!/bin/bash
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" --escape --binary --bufsize 4096
#/opt/homebrew/Cellar/lrzsz/0.12.20_1/bin/sz You install lrzsz The path of , The one I just found
/opt/homebrew/Cellar/lrzsz/0.12.20_1/bin/sz "$FILE" --escape --binary --bufsize 4096
sleep 1
echo
echo \# Received $FILE
fi
6. Solve the problem of using expect After automatic login , Out of commission rz and sz The question of orders
take Mac The local LC_CTYP The environment variable is set to en_US
# Direct modification is not recommended , Create a script , Execute... In a script
vim aliecs1.sh
#!/bin/sh
# take Mac The local LC_CTYP The environment variable is set to en_US, The solution can't be rz The problem of
export LC_CTYPE=en_US
# This is you expect Script for automatic login
/Users/zhangzhiyuan/ssh/aliecs.sh
take Iterm2 there aliecs.sh Change to aliecs1.sh

边栏推荐
- Go language foundation ----- 06 ----- anonymous fields, fields with the same name
- 技术干货|昇思MindSpore NLP模型迁移之Roberta ——情感分析任务
- Analysis of the problems of the 7th Blue Bridge Cup single chip microcomputer provincial competition
- Redis批量启停脚本
- PAT甲级 1032 Sharing
- IndexSort
- 技术干货|昇思MindSpore算子并行+异构并行,使能32卡训练2420亿参数模型
- Project experience sharing: realize an IR Fusion optimization pass of Shengsi mindspire layer
- 华为交换机:配置telnet和ssh、web访问
- C2-关于VCF文件合并的几种方法
猜你喜欢

Go language foundation ------ 12 ------ JSON

Project experience sharing: realize an IR Fusion optimization pass of Shengsi mindspire layer

技术干货|昇思MindSpore NLP模型迁移之LUKE模型——阅读理解任务

Technical dry goods | some thoughts on the future of AI architecture

Technical dry goods Shengsi mindspire innovation model EPP mvsnet high-precision and efficient 3D reconstruction

【MindSpore论文精讲】AAAI长尾问题中训练技巧的总结

Go language foundation ----- 18 ----- collaboration security, mutex lock, read-write lock, anonymous lock, sync Once

Technical dry goods | hundred lines of code to write Bert, Shengsi mindspire ability reward

Pat class a 1030 travel plan

Pat grade a 1029 median
随机推荐
输入三次猜一个数字
技术干货|昇思MindSpore可变序列长度的动态Transformer已发布!
PAT甲级 1032 Sharing
PAT甲级 1028 List Sorting
Traversal in Lucene
[Development Notes] cloud app control on device based on smart cloud 4G adapter gc211
技术干货|百行代码写BERT,昇思MindSpore能力大赏
What to do after the browser enters the URL
Go language foundation ----- 18 ----- collaboration security, mutex lock, read-write lock, anonymous lock, sync Once
Microsoft Security Response Center
Go language foundation ----- 15 ----- reflection
在浏览器输入url后执行什么
Go language foundation ------17 ----- channel creation, read-write, security shutdown, multiplexing select
[at] ABC 258g - Triangle triples reachable - violence
Screenshot tool snipaste
【LeetCode】2. Valid Parentheses·有效的括号
lucene scorer
[MySQL 13] if you change your password for the first time after installing mysql, you can skip MySQL password verification to log in
GoLang之结构体
基于RNA的新型癌症疗法介绍