当前位置:网站首页>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
边栏推荐
- 微软安全响应中心
- PDO and SDO concepts
- [mindspire paper presentation] summary of training skills in AAAI long tail problem
- Huawei switch console password reset, device initialization, default password
- Paper learning -- Study on the similarity of water level time series of Xingzi station in Poyang Lake
- 【LeetCode】3. Merge Two Sorted Lists·合并两个有序链表
- Enter three times and guess a number
- 技术干货|利用昇思MindSpore复现ICCV2021 Best Paper Swin Transformer
- Go language foundation ----- 01 ----- go language features
- The concept of C language pointer
猜你喜欢
技术干货|昇思MindSpore算子并行+异构并行,使能32卡训练2420亿参数模型
HDMI2.1与HDMI2.0的区别以及转换PD信号。
【MindSpore论文精讲】AAAI长尾问题中训练技巧的总结
Technical dry goods Shengsi mindspire elementary course online: from basic concepts to practical operation, 1 hour to start!
Go language foundation ------17 ----- channel creation, read-write, security shutdown, multiplexing select
Robots protocol
技术干货|百行代码写BERT,昇思MindSpore能力大赏
Technical dry goods | thinking about the unification of dynamic and static diagrams of AI framework
Go language foundation ----- 18 ----- collaboration security, mutex lock, read-write lock, anonymous lock, sync Once
Leetcode 213: looting II
随机推荐
【MySQL 12】MySQL 8.0.18 重新初始化
HarmonyOS第三次培训笔记
Es writing fragment process
技术干货|昇思MindSpore创新模型EPP-MVSNet-高精高效的三维重建
技术干货|昇思MindSpore NLP模型迁移之Roberta ——情感分析任务
Huawei switch console password reset, device initialization, default password
[Development Notes] cloud app control on device based on smart cloud 4G adapter gc211
yarn link 是如何帮助开发者对 NPM 包进行 debug 的?
Go language foundation ----- 05 ----- structure
华为交换机Console密码重置、设备初始化、默认密码
Redis批量启停脚本
Go language foundation ------ 14 ------ gotest
UA camouflage, get and post in requests carry parameters to obtain JSON format content
OSPF protocol summary
Technical dry goods | hundred lines of code to write Bert, Shengsi mindspire ability reward
Analysis of the problems of the 12th Blue Bridge Cup single chip microcomputer provincial competition
How to clear the console password for s7700 device
[MySQL 12] MySQL 8.0.18 reinitialization
Leetcode 213: looting II
技术干货|昇思MindSpore算子并行+异构并行,使能32卡训练2420亿参数模型