![]() Line 8 puts the contents of the temporary file onto the clipboard, and Line 9 moves it to the Trash, where you can retrieve it if necessary. If you’re an Emacs or Vim user, you probably already have something that works like this macro, so why have you bothered to read this far? I know both TextMate and Sublime Text have commands analogous to bbedit. If you use a text editor other than BBEdit, Line 6 is also where you need to specify that editor. The -wait option stops the execution of the script until the BBEdit file is closed. If you’re like Dan Frakes, you might find that the bbedit command is in /usr/bin instead of /usr/local/bin. Line 5 puts the text cut from the original application into the temporary file, and Line 6 opens it in BBEdit. If you want a different name or location for the temporary file, these are the lines to edit. If I see a file like this on my Desktop after I’m done editing, I know something’s gone wrong. The first two parts are a date and time stamp, and the final part is in ALL CAPS so it stands out. It sits on the Desktop and has a name like 20150806-071423-BBTMP.txt. Lines 2–3 set the name of the temporary file that BBEdit will open and edit. The shell script in the third step is this: bash:ģ: TEMPFILE="$HOME/Desktop/$TSTAMP-BBTMP.txt"Ħ: /usr/local/bin/bbedit -wait "$TEMPFILE" In the first step, I use Keyboard Maestro’s %CurrentApplication% token to save the name of the original application (MailMate in the example above) so the macro knows what to return to at the end. The logic of most of the steps is pretty obvious, but I do think a few things are worth mentioning. When the steps are collapsed, it looks like this: ![]() Basically, it works the way you want it to, assuming BBEdit is your editor of choice. If the original application has no text in it-if, for example, I knew right away I was going to write a long email-BBEdit opens with a blank document. ![]() ![]() If text is selected in the original application, only that text is cut out and replaced with the new text. MailMate comes back to the front, and the new text is pasted into the message window. Save the document (⌘S), and close it (⌘W). I finish writing the text of the message, I hit the ⌃⌥⌘⇧B key combination, and the text is cut out of MailMate and opened in a new BBEdit document. Let’s say I’m writing a new email message in MailMate, and I realize that it’s going to be long enough that I’d really rather write it in BBEdit. Here’s a brief rundown of how my macro works. TJ’s a nice guy, but he can’t be expected to drop everything to fix an old script just so I can edit my emails in BBEdit. I hate shell scripting in general and don’t know much about zsh, so I’d have a hard time making repairs to it if another OS X update breaks it. More important, though, is that TJ’s macros, both the original and the new one, rely on a significant chunk of zsh shell scripting. TJ likes using notifications and other signals to let the user know whether things are working correctly or not I prefer to just let’er rip-if the macro isn’t working, I’ll get an error message from Keyboard Maestro. In parallel, I worked on my own macro for doing the same thing, using TJ’s original as my model. He wrote about it today on MacStories and has posted the new macro on GitHub. TJ’s two-year-old macro had stopped working for mysterious reasons that can probably be traced to an update of either OS X or Keyboard Maestro, and he decided to come up with an improved version. Unfortunately, QuickCursor didn’t survive Apple’s new sandboxing rules. It was, in effect, an OS X version of the old Unix $EDITOR and $VISUAL environment variables.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |