Skip to content

Instantly share code, notes, and snippets.

@stsievert
Last active August 29, 2015 14:10
Show Gist options
  • Save stsievert/83ebb64812c7e209efad to your computer and use it in GitHub Desktop.
Save stsievert/83ebb64812c7e209efad to your computer and use it in GitHub Desktop.
MacVim and latex-box

Description

I ran into the issue where MacVim could not compile latex files using latex-box under OSX Yosemite. This only occured when opening MacVim the most natural way (at least for me): using Spotlight or double clicking. Opening with the terminal (using mvim etc) gave me no compile errors. There's a related Github issue.

Fix

To fix this issue, I created a simple Automator workflow that acted as an application and would run mvim on a file received as input. This application is available for download but I have also detailed how I created this app. There are some limitations and restrictions I had to take; see below.

I open all latex files with Spotlight. To have all latex files open in this Automator script, I pressed ⌘i on a latex file and under open with selected the attached file and hit "Change all".

Limitations

  1. This application hangs while opening multiple files. It's best used only for compile.
  2. The attached application can not open without a file as input. Double clicking on the app will give you an error. I plan to use it by opening latex files with Spotlight (well, Alfred).
  3. mvim command is specific and hard-coded to /usr/local/bin/mvim.
  4. I assume you're using zsh; the Applescript at the heart of this runs zsh -c "/usr/local/bin/mvim ...". This is the zsh -c (with escaped quotes).
-- opened automator and selected "Standalone application".
-- This gives you access to a file you open with Spotlight.
-- I then added the action "Run AppleScript" to this application
on run {input, parameters}
set filename to (the POSIX path of input)
set output to do shell script "zsh -c \"/usr/local/bin/mvim \"" & filename
return output
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment