Git 在不同选项卡窗口中并发执行脚本
我正在尝试在不同的Mac终端标签中同时克隆git repo,因为克隆需要很长时间 我已经尝试了下面的许多变体,但似乎无法获得每个单独的克隆,然后在3个单独的终端选项卡中同时运行以下命令,关于如何在不安装外部设备(如ttab)的情况下更改下面的命令来实现这一点,有什么想法吗Git 在不同选项卡窗口中并发执行脚本,git,bash,osascript,Git,Bash,Osascript,我正在尝试在不同的Mac终端标签中同时克隆git repo,因为克隆需要很长时间 我已经尝试了下面的许多变体,但似乎无法获得每个单独的克隆,然后在3个单独的终端选项卡中同时运行以下命令,关于如何在不安装外部设备(如ttab)的情况下更改下面的命令来实现这一点,有什么想法吗 cwd=$(pwd) osascript -e 'tell application "Terminal" to activate' -e 'tell application "System Events" to tell pr
cwd=$(pwd)
osascript -e 'tell application "Terminal" to activate' -e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' -e 'tell application "Terminal" to do script "cd '$cwd' && git clone git@github.com:me/myrepo1.git && cd myrepo1 && git pull && nvm use && npm install &" in selected tab of the front window' &
osascript -e 'tell application "Terminal" to activate' -e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' -e 'tell application "Terminal" to do script "cd '$cwd' && git clone git@github.com:me/myrepo3.git && cd myrepo2 && git pull && nvm use && npm install" in selected tab of the front window' &
git clone git@github.com:me/myrepo3.git && cd myrepo3 && git pull && nvm use && npm install
这就行了
#!/bin/bash
declare -a repos=("myrepo1" "myrepo2" "myrepo3")
me="git@github.com:me"
pwd=`pwd`
for i in "${repos[@]}"
do
osascript -e "tell application \"Terminal\"" -e "tell application \"System Events\" to keystroke \"t\" using {command down}" -e "do script \"cd $pwd; git clone $me/$i.git && cd $i && git pull && nvm use && npm install\" in front window" -e "end tell" > /dev/null
done
注:
- 在克隆回购协议之后,您不必使用
,但我还是将其保留在脚本中,因为它不会造成任何伤害git pull
- 如果使用
,请确保每个项目的根目录中都有一个nvmuse
文件,其中包含指定的节点版本。否则,.nvmrc
将不起作用。nvm use
- 你可能已经知道了,但我想在 如果你的脚本没有运行