Created
August 23, 2018 20:56
-
-
Save LazyRen/6e33fb372bf19c171f4b722cc2d90dd5 to your computer and use it in GitHub Desktop.
mac sublime-text c++ build&execute shell script
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 | |
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 | |
set fileBaseName to text 1 thru ((offset of "." in fileName) - 1) of fileName | |
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 ("./" & fileBaseName & ".out") 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 ("./" & fileBaseName & ".out") in first 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