はじめに
フロントエンドとバックエンドで分けて起動したい時、
1. terminalを起動して
2. タブを分割して
3. 各々で起動コマンドを実行する
という流れが面倒だったのでシェルスクリプトにしました。
実行すれば垂直分割されたiTermが起動して、それぞれでコマンドを実行してくれます。(↓の状態のiTermが起動します)
実装
今回はiTerm2を使います。
こちらの記事を参考にApple Scriptで書きました。
.init.sh
#!/usr/bin/osascript
tell application "iTerm"
create window with default profile
tell current window
# tabの分割
tell current session of current tab
split vertically with default profile
end tell
# tab1の処理
tell current session of current tab
write text "cd ~/[対象のpath]"
write text "実行したいコマンド"
end tell
# tab2の処理
tell second session of current tab
write text "cd ~/[対象のpath]"
write text "実行したいコマンド"
end tell
end tell
end tell
$ ./init.sh
を実行したら垂直分割されたiTermが起動されます。