您的位置:首页 > 移动开发

automator来解决mac terminal终端快速连接

2017-02-12 20:46 866 查看
因最近网络不太稳定,远程连接的ssh服务有时会断掉,于是在网上参考了一些mac terminal终端快速连接的办法,最后选择使用automator来解决。


    下面是antomator 服务的使用方法,并附有一段可运行代码

1、新建服务





2、将服务绑定到终端




3、一段AppleScript代码
on run {input, parameters}
tell application "Terminal"
activate
do script ""
set Terminal to front window
set tab1 to tab 1 of Terminal

# 窗口1中输出
do script "echo 1" in tab1
# 或者ssh登录
# do script "ssh ***" in tab1
# delay 1    #延迟 1 秒
# do script "..."

# 如果标签2不存在则创建
if not (exists tab 2 of Terminal) then
tell application "System Events"
keystroke "t" using command down    #相当于  command+T
end tell
set tab2 to tab 2 of Terminal
end if

# 窗口2中输出
do script "echo 2" in tab2
# 或者ssh登录
# do script "ssh ***" in tab2
# delay 1
# do script "..."
end tell
return input
end run


4、进入终端服务修改快捷键



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息