tag:iddogino.com,2013:/posts Iddo Gino 2025-05-15T01:12:05Z tag:iddogino.com,2013:Post/2197518 2025-05-15T01:12:04Z 2025-05-15T01:12:05Z Right click to copy any file as markdown on Mac

One underrated side effect of the AI revolution - everyone's finally using Markdown! I find myself often converting files to Markdown for use in AI prompts (ChatGPT and Claude let you upload files, but can’t do that running Ollama locally & on many other chat platforms) so manual markdown conversion is still useful.

My go-to is to use the markitdown utility from microsoft which is great for almost everything (PDFs, Office Docs, even ZIPs). But I wish it was even quicker. What if I could right click on any file in Finder and just copy it as markdown? Someone has to build it. I already had Xcode booting up and I remembered Automator. Surely this should be an automatorable task, right? Heck yeah!

A few short minutes later – I can now copy almost any file on my computer as markdown - just as god intended. Add it to you mac yourself below:

Pre-requisite - install Markitdown:

See here for installation instructions: https://github.com/microsoft/markitdown?tab=readme-ov-file#installation

Now to automator:

You can skip the next part and just download the automator quick action I created here: https://www.dropbox.com/t/UjvXmFmte6EZVLwj

If you are curious, want to build it yourself or just don’t trust unsigned Mac automations from random people on the internet (smart!) just do it yourself:

  1. Open Automator

  2. New > Quick Action

  3. On the top configure:

    1. Workflow receives current: files or folders

    2. Image: whatever you want the icon to be

  4. Look for the “Run Shell Script” action and drag it in

  5. Configure the shell script:

    1. Shell: /bin/bash

    2. Pass Input: as arguments

  6. Paste the code below (make sure to double check your markitdown install location with which markitdown in the second to last line)

  7. Save it - the name you save it as is how it’ll appear in the right click menu

Easy - now you can right click on any file and copy it as markdown!

Code:


#!/bin/bash

osascript -e 'display notification "Converting to Markdown..." with title "MarkItDown"'

for f in "$@"
do
  # Extract filename and directory
  filename=$(basename "$f")
  dirname=$(dirname "$f")
  name="${filename%.*}"
  
  # Set output path
  output="$dirname/$name.md"

  # Run markitdown
  /opt/homebrew/bin/markitdown "$f" | pbcopy
done

Sidenotes:

  1. If you are curious, Quickaction automations in mac are stored in ~/Library/Services. There doesn't seem to be a way to see all currently active Quick actions in the automator app - you have to open that folder and see them there.

  2. It seems that the bash used for running shell scripts in Automator is different / limited, and I couldn’t get the search path to work in it. So I had to put the direct path the installed Markitdown instance in the script. Use which markitdown to find its install path.

  3. Markitdown can take a few seconds/minutes to run on larger files. I tried to add a notification when it starts / finishes but couldn’t get notifications working properly inside Automator. It does show a spinning gear on the toolbar 



]]>
tag:iddogino.com,2013:Post/2118381 2024-06-22T23:46:55Z 2024-06-22T23:46:55Z Configuring Posthaven with Clouldflare -- too many redirects?

meta: part of my purpose with this site was to document things I am working on. In that spirit I figured I should document a lil challenge I had in setting up this site.

Setting up a post haven site with a custom domain seems deceptively easy - just put your custom domain name in the Posthaven dashboard and you are all set... right? Setting up my domain - I quickly ran into a problem. Namely, every time I tried to access the site I got a ERR_TOO_MANY_REDIRECTS in my browser.

After much painstaking research (Posthaven's docs are a lil light...) - turns out the issue is with Cloudflare's SSL settings. Specifically, you need to change the SSL mode from "flexible" to "full" and disable Cloudflare's SSL redirects (as Posthaven already does that itself). You can read about the specifics here: https://developers.cloudflare.com/ssl/troubleshooting/too-many-redirects/

Anyway, leaving this here in the hopes that the SEO gods index this page so that the next lost sole googling "Cloudflare Posthaven ERR_TOO_MANY_REDIRECTS" can save a few minutes.

]]>