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

边栏推荐
- EtherCAT state machine transition (ESM)
- [MySQL 12] MySQL 8.0.18 reinitialization
- Technical dry goods | Bert model for the migration of mindspore NLP model - text matching task (2): training and evaluation
- Technical dry goods | alphafold/ rosettafold open source reproduction (2) - alphafold process analysis and training Construction
- 【LeetCode】2. Valid Parentheses·有效的括号
- 什么是定义?什么是声明?它们有何区别?
- 技术干货|昇思MindSpore初级课程上线:从基本概念到实操,1小时上手!
- Lucene introduces NFA
- 哪一刻你才发现青春结束了
- Go language foundation ----- 13 ----- file
猜你喜欢

Technology dry goods | luxe model for the migration of mindspore NLP model -- reading comprehension task

Es writing fragment process

Pat class a 1028 list sorting

Go language foundation ----- 19 ----- context usage principle, interface, derived context (the multiplexing of select can be better understood here)

技术干货|利用昇思MindSpore复现ICCV2021 Best Paper Swin Transformer

研究显示乳腺癌细胞更容易在患者睡觉时进入血液

Pat class a 1031 Hello world for u

Pat class a 1032 sharing

【LeetCode】4. Best time to buy and sell stock

【MySQL 11】怎么解决MySQL 8.0.18 大小写敏感问题
随机推荐
项目经验分享:实现一个昇思MindSpore 图层 IR 融合优化 pass
UA camouflage, get and post in requests carry parameters to obtain JSON format content
Redis查看客户端连接
技术干货|利用昇思MindSpore复现ICCV2021 Best Paper Swin Transformer
lucene scorer
[MySQL 12] MySQL 8.0.18 reinitialization
优质博客——
微软安全响应中心
Analysis of the ninth Blue Bridge Cup single chip microcomputer provincial competition
Pat grade a 1027 colors in Mars
Implementation of breadth first in aggregation in ES
[at] ABC 258g - triple Reach - violence
技术干货|百行代码写BERT,昇思MindSpore能力大赏
Analysis of the eighth Blue Bridge Cup single chip microcomputer provincial competition
The babbage industrial policy forum
Redis批量启停脚本
【MindSpore论文精讲】AAAI长尾问题中训练技巧的总结
PHP常用排序算法
Go language foundation ----- 16 ----- goroutine, GPM model
What did the DFS phase do