Programmatically determine when MacVim finishes editing a file

Viewed 147

I want to write a script that opens a specified file with MacVim and then waits until the file is closed before continuing. My original idea was:

#!/bin/sh
file="some-file.txt"
mvim $file
cat $file | pbcopy

This opens the specified file with MacVim and immediately executes the next command. I've been thinking of something incredibly hackish with lsof but I was hoping there is a better way.

If this isn't possible with plain shell script, I'm open to ideas in anything else. (AppleScript, etc.)

2 Answers
Related