POSTS

Using mutt with MacVim as external editor

Blog

I love usig the mutt mail reader to turn through my mail. I recently set it up to make use of my MacVim installation by adding the following configuration to the .muttrc.

set editor="mvim --remote-tab-wait-silent "

This is pretty neat. When I go to reply or compose, I’m thrown into a new tab in MacVim and I can compose / reply there. After hitting ZZ or :wq!, mutt properly handled the signal, but didn’t change OSX’s focus back to the terminal window where Mutt was running. By changing the editor to the following configuration:

set editor="osascript $HOME/bin/mutt_edit.sh"

I was able to tell Mutt to send my temp file (for the edit) to osascript, a utility that runs Applscript. In mutt_edit.sh I provided a bit of a wrapper around the mvim command such that it told OSX to re-activate my terminal session after the editing activity finished. Here’s the code:

on run argv
  tell application "Finder"
    do shell script "mvim --remote-tab-wait-silent " & item 1 of argv
  end tell
  tell application "iTerm (1.0.0.20111020)"
    activate
  end tell
end run