Last active
May 12, 2019 00:18
-
-
Save brettz9/c3afb987e8ca2f51aaf3f817d0a745ed to your computer and use it in GitHub Desktop.
Sourcetree Custom action to open in Terminal *tab*; need `chmod 0755 OpenInTerminalTab.sh` enable SourceTree in `System Preferences->Security & Privacy->Privacy->Accessibility`; note: implementing as an application did not seem to work from within Sourcetree
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/sh | |
dir=$(dirname "$1") | |
scr=$(cat <<EOF | |
on run {} | |
set directory to "$dir" | |
set newTab to (application "Terminal" is running) | |
tell application "Terminal" | |
activate | |
if newTab then | |
tell application "System Events" | |
tell application process "Terminal" | |
set frontmost to true | |
keystroke "t" using command down | |
end tell | |
end tell | |
end if | |
do script "cd " & directory & ";clear" in front window | |
end tell | |
end run | |
EOF | |
) | |
# echo "$scr" | |
osascript -e "$scr" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment