Created
December 8, 2023 21:10
-
-
Save DArmstrong87/b1ad5842faa7c7eb52265c423ee1c2f3 to your computer and use it in GitHub Desktop.
Shell executable to run an Applescript in iTerm2 which opens repos in separate tabs, pulls latest code and runs a command for each repo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on run argv | |
local basePath | |
set basePath to item 1 of argv | |
tell application "iTerm2" | |
create window with default profile | |
end tell | |
set repos to {"repo-1", "repo-2", "repo-3"} | |
set npms to {"repo-1", "repo-2"} | |
repeat with repo in repos | |
set filepath to basePath & repo | |
tell application "iTerm2" | |
tell current window | |
set repo_tab to (create tab with default profile) | |
end tell | |
tell current session of repo_tab | |
set name to (repo as text) | |
write text "title " & (repo as text) | |
write text "cd " & filepath | |
write text "git pull origin $(git branch --show-current)" | |
if (npms contains repo) then | |
write text "npm start" | |
else | |
write text "some other command" | |
end if | |
end tell | |
end tell | |
end repeat | |
end run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script launches an AppleScript to create a terminal window with several tabs. | |
# Each tab represents a unique repo. | |
# List npm repos within the applescript list to run automaticaly | |
# Can be modified to run commands for non-npm projects | |
# | |
# Usage: | |
# * Just run `./run_repos.sh`. | |
# * If your repositories are checked out under a different base path, then set the BASEPATH var: | |
# `BASEPATH=path/to/all/repos ./run_repos.sh`. | |
if [ -z "${BASEPATH:-}" ]; then | |
BASEPATH="${HOME}/code" | |
echo "Using the default base path for the repos as ${BASEPATH}. To change, set the BASEPATH var when calling this script." | |
fi | |
# Sets the title of each tab | |
function title { | |
echo -ne "\033]0;\"$*\"\007" | |
} | |
osascript ./run-locally/run_repos.applescript "${BASEPATH}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment