Skip to content

Commit

Permalink
Don't accidentally open Coda when all we needed was to check what tab…
Browse files Browse the repository at this point in the history
…s are running
  • Loading branch information
bobthecow committed May 7, 2011
1 parent f1b2566 commit b4f7e1a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions coda
Expand Up @@ -28,21 +28,29 @@ parser.version = "%%prog: %s" % version
def osascript(scpt):
return commands.getoutput("osascript<<ENDSCRIPT\n%s\nENDSCRIPT\n:" % scpt)

def coda_is_running():
return osascript("tell application \"System Events\" to (count (every process whose creator type is \"TStu\")) as boolean") == "true"

def open_tabs():
scpt = """
set AppleScript's text item delimiters to "\n"
tell application "Coda"
return file path of every editor of every split of every tab of every document as text
end tell
"""
return [os.path.realpath(tab) for tab in filter(lambda a: a != "missing value", osascript(scpt).rstrip("\n").split("\n"))]
if coda_is_running():
return [os.path.realpath(tab) for tab in filter(lambda a: a != "missing value", osascript(scpt).rstrip("\n").split("\n"))]
else:
return None

if options.version:
parser.print_version()
exit()

if options.lstabs:
print "\n".join(open_tabs())
tabs = open_tabs()
if tabs:
print "\n".join(tabs)
exit()

from_stdin = (files == ['-'] or not sys.stdin.isatty())
Expand Down

0 comments on commit b4f7e1a

Please sign in to comment.