Skip to content

Instantly share code, notes, and snippets.

@patrickwelker
Created May 18, 2014 19:25
Show Gist options
  • Select an option

  • Save patrickwelker/dbc90c39659c4cdc8538 to your computer and use it in GitHub Desktop.

Select an option

Save patrickwelker/dbc90c39659c4cdc8538 to your computer and use it in GitHub Desktop.
AppleScript for guessing the text editor you currently use. It's intended to be used in Keyboard Maestro. Read more here: http://rocketink.net/2014/05/upload-to-gist.html.
set activeEditorsList to {}
set appList to {"nvALT", "FoldingText", "Byword", "Mou", "Sublime Text", "MultiMarkdown Composer"}
-- Generate variable with running apps
tell application "System Events"
set activeProcesses to (name of every process)
end tell
-- Generate list of running text editors
repeat with appName in appList
if appName is in activeProcesses then
set end of activeEditorsList to appName
end if
end repeat
--return activeEditorsList
set editorCount to count activeEditorsList
if editorCount = 1 then
return item 1 of activeEditorsList as text
else if editorCount > 1 then
activate
return choose from list activeEditorsList
else
return "cancel"
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment