Created
April 2, 2011 13:40
-
-
Save ttscoff/899503 to your computer and use it in GitHub Desktop.
Returns the best running editor on a Mac, if any, based on my personal order of preference.
This file contains hidden or 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
#!/usr/bin/ruby | |
# | |
# Returns the best running editor (Mac), if any, based on my personal order of preference. | |
def pick_editor | |
editors = ['TextMate','MacVim','Espresso','Coda','TextEdit'] | |
ps = %x{ps Ao comm|grep .app|awk '{match($0,/([^\\/]+).app/); print substr($0,RSTART,RLENGTH)}'}.split("\n") | |
editors.each {|editor| | |
return editor if ps.include?(editor+".app") | |
} | |
return false | |
end | |
puts pick_editor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment