Skip to content

Instantly share code, notes, and snippets.

@brettz9
Last active May 12, 2019 00:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brettz9/c3afb987e8ca2f51aaf3f817d0a745ed to your computer and use it in GitHub Desktop.
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
#!/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