下载地址
https://github.com/fitztrev/shuttle
该工具十分简单,下载后通过 json 文件配置命令行快捷启动
配置格式
{
//.....
"hosts": [
{
"name": "命令一",
"cmd": "ps aux | grep defaults",
# 可选
"title": "title of terminal"
"theme": "basic",
"inTerminal": "tab | new | current",
},
{
"name": "命令二",
"cmd": "ps aux | grep defaults"
},
{
"分组名称": [
{
"name": "命令一",
"cmd": "ps aux | grep defaults",
},
{
"name": "命令二",
"cmd": "ps aux | grep defaults"
},
{
"二级分组": [
{
"name": "命令一",
"cmd": "ps aux | grep defaults"
},
{
"name": "命令二",
"cmd": "ps aux | grep defaults"
}
]
}
]
}
]
}
shuttle 的本质就是快速打开一个终端,并输入预置的命令并执行(也可以仅输入不执行),对于常用命令,就不用每次都输入了,Mac 默认终端旧版本实用 bash,新版本为 zsh,二者很接近,但又有些许不同,有些命令,我们执行完并不需要保留终端窗口,需要立即退出;有些命令需要在后台运行,这就有些不同了
# 执行完命令并关闭终端
# bash
$ command & exit
# zsh
$ command; exit
# 在后台运行
# bash
$ command &
# zsh
$ command &!
另外,默认情况下,执行 exit 之后窗口仍然不会关闭,需要打开终端:偏好设置 > 描述文件 > Shell
配置:当 shell 退出时 > 关闭窗口
举些实用的例子:
- apache 管理,快速启动、停止、重启;实用 vscode 编辑 apache 配置
"apache": [
{
"name": "Restart",
"cmd": "echo | sudo -S apachectl restart &>/dev/null; exit"
},
{
"name": "Start",
"cmd": "echo | sudo -S apachectl start &>/dev/null; exit"
},
{
"name": "Stop",
"cmd": "echo | sudo -S apachectl stop &>/dev/null; exit"
},
{
"name": "VHosts",
"cmd": "/Applications/Visual\\ Studio\\ Code.app/Contents/Resources/app/bin/code /etc/apache2/extra/httpd-vhosts.conf; exit"
}
],
- 快速链接远程远程 linux 服务器
"server": [
{
"name": "远程服务器一",
"cmd": "sshpass -p '' ssh @"
},
{
"name": "远程服务器二",
"cmd": "sshpass -p '' ssh @"
}
],
- 快速打开 Android 模拟器
"android emulator": [
{
"name": "打开模拟器",
"cmd": "$ANDROID_HOME/emulator/emulator -avd &>/dev/null &!; exit"
},
{
"name": "可写模式打开模拟器",
"cmd": "$ANDROID_HOME/emulator/emulator -writable-system -avd &>/dev/null &!; exit"
}
],
- 启动一个具有魔法的终端
"Tools": [
{
"name": "魔法终端",
"cmd": "export ALL_PROXY=socks5://127.0.0.1:1086 export all_proxy=socks5://127.0.0.1:1086"
}
]