当前位置:网站首页>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

边栏推荐
- Usage of requests module
- Go language foundation ----- 05 ----- structure
- Huawei switch basic configuration (telnet/ssh login)
- Implementation of breadth first in aggregation in ES
- Technical dry goods Shengsi mindspire innovation model EPP mvsnet high-precision and efficient 3D reconstruction
- [at] abc 258G - Triangle 三元组可达-暴力
- [MySQL 13] if you change your password for the first time after installing mysql, you can skip MySQL password verification to log in
- C2-关于VCF文件合并的几种方法
- PAT甲级 1028 List Sorting
- Lucene skip table
猜你喜欢

Traversal in Lucene
![[Development Notes] cloud app control on device based on smart cloud 4G adapter gc211](/img/55/fea5fe315932b92993d21f861befbe.png)
[Development Notes] cloud app control on device based on smart cloud 4G adapter gc211
![[MySQL 11] how to solve the case sensitive problem of MySQL 8.0.18](/img/9b/db5fe1a37e0de5ba363f9e108310a5.png)
[MySQL 11] how to solve the case sensitive problem of MySQL 8.0.18

Robots protocol

Analysis of the ninth Blue Bridge Cup single chip microcomputer provincial competition

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

密西根大学张阳教授受聘中国上海交通大学客座教授(图)

Hnsw introduction and some reference articles in lucene9

技术干货|昇思MindSpore创新模型EPP-MVSNet-高精高效的三维重建

Analysis of the problems of the 12th Blue Bridge Cup single chip microcomputer provincial competition
随机推荐
技术干货|利用昇思MindSpore复现ICCV2021 Best Paper Swin Transformer
【MindSpore论文精讲】AAAI长尾问题中训练技巧的总结
Partage de l'expérience du projet: mise en œuvre d'un pass optimisé pour la fusion IR de la couche mindstore
Go language foundation ----- 09 ----- exception handling (error, panic, recover)
Go language foundation ----- 13 ----- file
C2 several methods of merging VCF files
Redis view client connection
输入三次猜一个数字
IndexSort
How to clear the console password for s7700 device
【MySQL 12】MySQL 8.0.18 重新初始化
【踩坑系列】mysql 修改root密码失败
Technical dry goods | reproduce iccv2021 best paper swing transformer with Shengsi mindspire
Technical dry goods | thinking about the unification of dynamic and static diagrams of AI framework
密西根大学张阳教授受聘中国上海交通大学客座教授(图)
PAT甲级 1031 Hello World for U
研究显示乳腺癌细胞更容易在患者睡觉时进入血液
Project experience sharing: handwritten Chinese character recognition based on Shengsi mindspire
UA camouflage, get and post in requests carry parameters to obtain JSON format content
Go language foundation ----- 19 ----- context usage principle, interface, derived context (the multiplexing of select can be better understood here)