Skip to content

Instantly share code, notes, and snippets.

@rafaelrinaldi
Created October 20, 2012 04:45
Show Gist options
  • Save rafaelrinaldi/3922040 to your computer and use it in GitHub Desktop.
Save rafaelrinaldi/3922040 to your computer and use it in GitHub Desktop.
Command for the native Markdown bundle of TextMate which allows you to preview the current document on Marked.

This is a simple TextMate command that allows you to preview the current document you're editing right on Marked editor.

Installation

  • Go to BundlesBundle EditorShow Bundle Editor (or simply ⌃⌥⌘B):
  • Locate the Markdown bundle then click on it:
  • On the bottom of the window you'll find a plus icon. Click on it then select New Command:
  • Name it as "Preview on Marked", and make its shortcut ⌘R:
  • Now you just need to paste the script below to the command input.

* To test it out, you can create a `.md` file, save it then hit `⌘R`. If you have everything set, Marked will open with the preview of your file. If you don't have it installed, it'll prompt an error with the link for the download:
![](http://imageshack.us/a/img62/1300/screenshot20121020at140.png)

Happy editing!

#!/usr/bin/env bash
MARKED_APP="/Applications/Marked.app"
fail() {
echo "<html>
<head>
<title>Fail</title>
</head>
<body>
<h2>Something went wrong ⚠</h2>
<hr />
<p>Seems like you don't have <strong>Marked</strong> installed. <a href='http://itunes.apple.com/us/app/marked/id448925439?ls=1&mt=12'>Download it</a>.</p>
</body>
</html>"
}
if [[ -a $MARKED_APP ]]; then
open -a $MARKED_APP $TM_FILEPATH;
echo "<html><script>window.close();</script></html>"
else
fail
fi
@Behinder
Copy link

It's a matter of taste of course but under 10.6 Marked is called MarkedSL so user must either change name of the app or chenge name in the script

@rafaelrinaldi
Copy link
Author

Didn't knew that. As you said, all you need to get it working is to edit the application path (MARKED_APP variable) and voilá.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment