一、安装iterm2
首先安装iterm2,参考:
MacOS必备效率神器--Go2Shell+iTerm2+Oh My Zsh
二、脚本文件
set timeout 30
#连接远程服务器,[lindex $argv 0/1/2/3]是外部输入的参数,当然也可以写里面,第一个参数是端口。第二个参数是登录的账号,点个参数是服务器地址,第四个参数是密码
spawn ssh -p [lindex $argv 0] [lindex $argv 1]@[lindex $argv 2]
#自动输入
expect {
"(yes/no)?"
{send "yes\n";exp_continue}
"password:"
{send "[lindex $argv 3]\n"}
}
#终端清屏
expect "~"
send "clear\n"
#cd到服务器想要的目录
send "cd /home/byxf-acc-front/jetty/logs/acc-front/\n"
#打开实时日志文件
send "tail -f acc-front.log\n"
三、设置profile
1、保存脚本文件
将脚本文件保存在一个目录,我是保存在桌面一个文件夹,路径是
/Users/zhaojing/Desktop/shPofile/1_app-front_Log.sh
2、打开iterm的profile

新建一个profile


在send text at star里面填入:
脚本路径 端口号 用户名 服务器地址 密码
中间用空格隔开,密码如果带有特殊字符最好用''圈起来
四、自动链接服务器

点击一下,就能自动链接到服务器,并且能到达指定目录
五、item自动执行脚本
有时候想执行一些脚本文件,需要先到脚本文件目录,然后在执行,比较麻烦,item也可以设置快捷方式:
同样添加profile

在custom shell里面填上脚本的路径就行了,执行的时候直接打开profile点击一下即可
网友评论