I wrote this stuff in August, 2008

Textmate Emulation Applescripts for Coda

Update: TEA for Coda documentation and other information has now moved over to One Crayon:

http://onecrayon.com/tea/coda/

Textmate is a fantastic editor. Every once in a while I try a different text editor, but none of them allow me to get even close to the speed and productivity that I enjoy with Textmate.

However, I recently took another look at Coda when it was updated to version 1.5 because the update came out at the same time that a project which benefited a lot from Coda’s all-in-one interface hit my plate (gotta love remote editing with SSH access in the other split). Although nothing can salvage Coda’s craptastic CSS editing (nothing but a straight-up duplication of CSSEdit‘s fantastic auto-complete and intelligent indentation, that is) with a little Applescript I was able to emulate four of the functions from Textmate that I find absolutely critical to my coding happiness and productivity. Without further ado, I give you the Textmate Emulation Applescripts for Coda:

Download TEA for Coda

TEA for Coda currently offers four of my favorite actions from the Textmate HTML and Hyperlink Helper bundles (in slightly less elegant and feature-rich implementations, of course, given that it’s Applescript and Coda’s less-powerful editing environment):

  • Insert Open/Close Tag: this is the functionality that I can’t live without. Just type the tag you want and run the script to have the tag automatically created and your cursor inserted inside (you can also type a tag with attributes, select it, and the script will intelligently exclude the attributes from the closing tag). The only thing that makes me sad is that Coda doesn’t have Textmate’s intelligent text indentation, so adding divs with the script is still a little frustrating.
  • Tidy HTML: this runs Tidy HTML optimized to correctly indent your code rather than clean up messy code (Coda lacks automatic code indentation, and I write clean code anyway; see the Read Me for info on changing Tidy’s default options if you’d rather use it to fix Word HTML, for instance).
  • Wrap Selection in Link: this mimics the basic functionality of Textmate’s Hyperlink Helper Wrap Word as Link, but without the cool automatic title attribute generation or tab controls. It will automatically grab whatever’s on the clipboard, though, making it easy to create links if you’ve copied them from elsewhere.
  • Wrap Selection in Tag: use this script to wrap the selected text in an arbitrary tag. Like Textmate, it allows you to enter attributes but doesn’t stick them in the closing tag. Unlike Textmate, it forces you to use enter the tag in a dialog box; about the same speed, but much less elegant.

Make sure after installing the scripts that you customize yourself some shortcuts either using the System Preference Keyboard and Mouse area, or with a utility like FastScripts. The ReadMe includes a list of the default Textmate shortcuts for your reference if you’re a Textmate user.

Hopefully these scripts will help other people who want to leverage the awesome HTML editing capabilities of Textmate along with the all-in-one sweetness of Coda. If you’re an Applescript ninja and decide to improve on or add to the scripts, please let me know! I’d love to implement better solutions to my own workflow, and I’m a bit of an Applescript noob so the scripts could doubtless be improved.

As far as my own plans for the bundle go, I intend to add a script to emulate Textmate’s Wrap Each Selection in Open/Close Tag and I’m also hoping to increase the intelligence of some of the scripts by offloading some of the logic to shell scripts; just need to work on my Python-fu or something before that can happen.

While Coda is still a jack of all trades and master of none, the TEA for Coda bundle has at least made it usable for me on those projects where its collection of features and awesome split abilities make it a better choice than Textmate. I just hope that Panic will implement some intelligent indentation for a future version, as that’s still the most glaring omission when trying to perform basic text editing, even with TEA for Coda installed.

Minor update Sept. 1, 2008: With thanks to Brian Haslanger, Format with Em (menu title: Em) and Format with Strong (menu title: Strong) are now a part of the TEA for Coda. If you’ve already installed the bundle, just redownload, copy the HTML/Format folder into your ~/Library/Scripts/Applications/Coda/HTML folder, and add the cmd-I and cmd-B shortcuts in System Preferences.

Minor update Sept. 2, 2008: TEA for Coda now includes the most recent version of Tidy (the HTML Tidy site provides binaries that are several years out of date). Additionally, the Tidy script will now accept selected text and only tidy that text (without inserting a bunch of useless body tags and so forth). If you don’t select any text, it will tidy the entire document. I’ve also revised the tidy_config.txt file to some more sensical defaults. Updating procedure is the same as before.

Minor update Sept. 25, 2008: TEA for Coda now has a dedicated landing page; please reference that for the most up-do-date information about the scripts. I’ve also updated the scripts with bug fixes and more, but I won’t be updating this post any more when I update the scripts down the road.

Minor update Nov. 10, 2008: So I lied about never updating this again; since this post continues to be a popular landing spot for Google, I wanted to let folks know that TEA for Coda now includes a Universal Binary version of Tidy HTML. If you’re using a PPC, definitely grab the download above and update (more info on updating in the Read Me, or here).

Minor update Nov. 11, 2008: TEA for Coda now requires Coda 1.6 (which is a free update for all Coda users), and the scripts will now perform their actions in the active document, even if there are multiple windows open.

The perfect time tracker

I just discovered an odd little website called ididwork (via Chris Bowler). It’s basically a personal or small-team Twitter, but with built-in tags and the ability to analyze your logged comments. The intent is that whenever you do something during the day, you log it into ididwork and then you (or your manager) can analyze your time.

Well, okay, that’s kind of cool, but to be honest it’s just one more damned web app that I’d need to track, so the ididwork service itself seems like more effort than I’m ready to put into it. Chris Bowler wonders whether there’s a desktop solution (so far as I know he’s out of luck, but maybe someone will tip him off to something wonderful and he’ll share).

For myself, though, ididwork makes me wonder why this kind of thing isn’t built into a time tracker. Currently, most of the time trackers out there can be used in one of two ways: you either track your time for a project in a chunk and write what you did in the notes (easier to manage, harder to see specifically how long a task took) or you can open a new timing ticket for every task (major pain in the ass, but makes retrospective analysis extremely simple). What if instead, while you were timing, you could hit a hotkey, enter a short description of what you just did, and the timetracker would log that snippet with the active session along with the time that you entered it?

OfficeTimeI currently use OfficeTime because it’s the best of a large selection of imperfect solutions. Specifically I chose OfficeTime because:

  • It lets me start/pause and stop/restart any timing session and only rounds once (rounds when you stop, removes rounding if you restart).
  • If I start a new session (in another project or not) the current session is automatically paused.
  • It allows me to pause any active session and start a session for any active project from the menubar.
  • It has robust reports that let me easily filter past sessions, invoice sessions, and check off sessions as invoiced or reported.

No other time tracker that I’ve found has quite this configuration of features (particularly not in a package that’s so straight-forward and simple to use; interface bloat is a serious problem for time trackers). Where OfficeTime fails me is that it is incapable of showing me the times when I paused and restarted a project, and I usually forget to fill out the comments field as I go, which causes me some headache at the end of the day. Additionally, thanks to my one-session-per-project-per-day usage, when looking back after a week or two it’s almost impossible to remember how long a task on any given day took (assuming that I remembered to note it in the comments field at all).

If all that OfficeTime did was offer an easy way to enter comment snippets and associated them with a timestamp (either real time or, preferably, relative to the active session) then almost all of my issues with it would be solved. Heck, I wouldn’t mind if it just appended “2:13 Finished feature X” to the comments field of the active timer (assuming 2:13 is 2:13 into the timer, not 2:13 PM) most of the weaknesses of the program would be solved (from my workflow’s perspective). Additional analysis tools would be a nice bonus, perhaps, but might just be interface bloat.

Of course, I’m not picky. If some time tracker other than OfficeTime implemented comment logging (assuming that it already had my must-have reports, pause/restart, simple interface, and only-rounding-once features) I’d be more than happy to switch over. Because that particular selection of features sounds to me like about the perfect time tracker.

Track me like a stalker:
  • Tagamac
  • Twitter
Clicky Web Analytics