Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
mac sublime-text python build&execute shell script
#!/bin/sh
osascript -e '
on run parameters
set TID to text item delimiters
set text item delimiters to " "
set myfile to parameters as text
set text item delimiters to TID
tell application "Finder"
set fileName to name of (POSIX file myfile as alias)
set filePath to do shell script ("dirname " & quoted form of myfile)
end tell
tell application "System Events"
if not (exists (processes where name is "Terminal")) then
tell application "Terminal"
activate
do script ("cd " & quoted form of filePath & "; clear") in first window
delay 0.1
do script ("python3 " & quoted form of myfile) in first window
end tell
else
tell application "Terminal"
activate
delay 0.1
tell application "System Events" to tell process "Terminal.app" to keystroke "n" using command down
delay 0.1
do script ("cd " & quoted form of filePath & "; clear") in selected tab of the front window
delay 0.1
do script ("python3 " & quoted form of myfile) in selected tab of the front window
end tell
end if
end tell
end run
' $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.