I’ve always been a vi guy, but OS X vi GUIs leave a lot to be desired. So for years I’ve put up with TextEdit as the default application when I double click a text file in Finder or an attachment in mail.
Until yesterday. Using this old macosxhints.com forum thread as the base, updated and modified to behave properly, double clicking a text file now opens it in vi in a new tab in Terminal, opening Terminal if it’s not already (which is rare, as I usually have 4 or 5 tabs open all the time).And here it is… Please let me know if it can be improved in any way.
on open inputfile
ignoring application responses
tell application “Terminal”
activate
tell application “System Events” to tell process “Terminal” to keystroke “t” using command down
do script “vi “ & quoted form of POSIX path of inputfile in selected tab of the front window
end tell
end ignoring
end open
Post a Comment
You must be logged in to post a comment.