TIL How to open any file in browser from the terminal
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.txt
It’s the same for any 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 don’t want to have two applications but have a single app showing editing and previewing mode.
Visual Studio Code is a great alternative
The existing 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, one can use Neovim plugins. They are generally faster than electron app based solutions (not that it matters a lot but the inner purists in use can disagree).
~ updated at: 2025-10-09T07:54:47.495Z