I always knew we could open any file in the browser on my Mac but I didn’t know how. Today I did and it’s super simple.
open -a Safari notes.txts
It’s the same for any type file. Here’s an example of a markdown file:
open -a Safari notes.md
Side note
This knowledge opens a way to better deal with situations in real life.
Like, if we have a markdown previewer extension on the browser of our choice, then it’s super useful during demos and presentations where we can keep the text editor and preview windows decoupled from each other.
Ideally, we want a single application that shows both editing and preview modes.
Visual Studio Code is a great alternative
The go-to solution is to use Visual Studio Code. with the inbuilt preview markdown feature.
Command + Shift + V to preview the existing markdown file. It’s great for most use-cases.
If you need a simpler setup, you can use Neovim plugins. They are generally faster than electron app based solutions (not that matters much but the inner purist in us can disagree).