Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: c1ba0cfe24
Fetching contributors…

Cannot retrieve contributors at this time

file 131 lines (121 sloc) 3.835 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>saveActiveFile</string>
<key>command</key>
<string>#!/usr/bin/env bash
[[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] &amp;&amp; . "${TM_SUPPORT_PATH}/lib/bash_init.sh"

#
# Compile a single file to a.out and execute the code in the frontmost Terminal
#

# Get some HTML niceties
. "${TM_SUPPORT_PATH}/lib/html.sh"
. "${TM_SUPPORT_PATH}/lib/webpreview.sh"

# Prepare output HTML in case the compilation fails
html_header "`basename "${TM_FORTRAN:-gfortran}"` compile"

# TIP (from Allan Odgaard)
# command1 &amp;&gt; &gt;(command2)
# pipes the output of 'command1' to 'command2' but the status is still evaluated from 'command1'. Really cool.

# Pipe the output of the compiler to 'pre' which formats it nicely for HTML output
if cd "$TM_DIRECTORY" &amp;&amp; "${TM_FORTRAN:-gfortran}" $TM_FFLAGS "`basename "$TM_FILEPATH"`" &amp;&gt; &gt;(pre); then

# if compilation went well, execute the code in the frontmost Terminal
# TIP (from jacobolus): using -SOMETHING as entry point allows the end SOMETHING to be indented with the rest of the code
# TIP (from infinilight): use TM_TERMINAL to detect which terminal to run
TM_TERMINAL=`echo $TM_TERMINAL | tr "[:upper:]" "[:lower:]"`
echo $TM_TERMINAL

if [ "$TM_TERMINAL" == "iterm" ]; then
# iTerm code - simple and not necessarily robust
osascript &lt;&lt;-APPLESCRIPT
tell application "iTerm"
activate
if not (exists current terminal) then
set myterm to (make new terminal)
tell myterm
launch session "Default Session"
end tell
end if
tell current terminal
tell current session
write text "cd " &amp; "$TM_DIRECTORY"
write text "./a.out"
end tell
end tell
end tell
tell application "TextMate"
activate
end tell
APPLESCRIPT
else
# Apple Terminal code - checks that a window exists and is not buzy
osascript &lt;&lt;-APPLESCRIPT
tell application "Terminal"
activate
set windowCount to (count of the windows)
if windowCount is greater than 0 then
repeat with w from 1 to windowCount
if window 1 is busy then
set frontmost of window 1 to false
else
do script "cd " &amp; "$TM_DIRECTORY" in window 1
do script "./a.out" in window 1
set frontmost of window 1 to true
return
end if
end repeat
end if
tell window 1
do script "cd " &amp; "$TM_DIRECTORY" &amp; " &amp;&amp; ./a.out"
set frontmost to true
end tell
end tell
tell application "TextMate"
activate
end tell
APPLESCRIPT
fi

exit_discard

else
# if compilation failed, show compiler's output in HTML preview
exit_show_html "&lt;h2&gt;Compilation failed&lt;/h2&gt;"

fi
</string>
<key>input</key>
<string>none</string>
<key>inputFormat</key>
<string>text</string>
<key>keyEquivalent</key>
<string>@r</string>
<key>name</key>
<string>Compile &amp; Execute Single File</string>
<key>outputCaret</key>
<string>afterOutput</string>
<key>outputFormat</key>
<string>text</string>
<key>outputLocation</key>
<string>discard</string>
<key>requiredCommands</key>
<array>
<dict>
<key>command</key>
<string>gfortran</string>
<key>locations</key>
<array>
<string>/opt/local/bin/gfortran</string>
<string>/usr/local/bin/gfortran</string>
</array>
<key>variable</key>
<string>TM_FORTRAN</string>
</dict>
</array>
<key>scope</key>
<string>source.fortran</string>
<key>semanticClass</key>
<string>process.build-and-run.fortran</string>
<key>uuid</key>
<string>EDD1628F-BB8C-4EC1-AFBD-90EC260F45B9</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>
Something went wrong with that request. Please try again.