下載地址
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 的本質(zhì)就是快速打開一個終端呐粘,并輸入預置的命令并執(zhí)行(也可以僅輸入不執(zhí)行),對于常用命令业稼,就不用每次都輸入了赤兴,Mac 默認終端舊版本實用 bash,新版本為 zsh穴吹,二者很接近,但又有些許不同嗜侮,有些命令港令,我們執(zhí)行完并不需要保留終端窗口,需要立即退出锈颗;有些命令需要在后臺運行顷霹,這就有些不同了
# 執(zhí)行完命令并關(guān)閉終端
# bash
$ command & exit
# zsh
$ command; exit
# 在后臺運行
# bash
$ command &
# zsh
$ command &!
另外,默認情況下击吱,執(zhí)行 exit 之后窗口仍然不會關(guān)閉淋淀,需要打開終端:偏好設(shè)置 > 描述文件 > Shell
配置:當 shell 退出時 > 關(guān)閉窗口
舉些實用的例子:
- apache 管理,快速啟動覆醇、停止朵纷、重啟;實用 vscode 編輯 apache 配置
"apache": [
{
"name": "Restart",
"cmd": "echo <password> | sudo -S apachectl restart &>/dev/null; exit"
},
{
"name": "Start",
"cmd": "echo <password> | sudo -S apachectl start &>/dev/null; exit"
},
{
"name": "Stop",
"cmd": "echo <password> | 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 '<password>' ssh <user>@<hostname>"
},
{
"name": "遠程服務器二",
"cmd": "sshpass -p '<password>' ssh <user>@<hostname>"
}
],
- 快速打開 Android 模擬器
"android emulator": [
{
"name": "打開模擬器",
"cmd": "$ANDROID_HOME/emulator/emulator -avd <emulator_name> &>/dev/null &!; exit"
},
{
"name": "可寫模式打開模擬器",
"cmd": "$ANDROID_HOME/emulator/emulator -writable-system -avd <emulator_name> &>/dev/null &!; exit"
}
],
- 啟動一個具有魔法的終端
"Tools": [
{
"name": "魔法終端",
"cmd": "export ALL_PROXY=socks5://127.0.0.1:1086 export all_proxy=socks5://127.0.0.1:1086"
}
]