A standalone Obsidian markdown editor would be excellent, naysayers be damned. +1
uh since my request got merged into this one, Iām going to clarify that opening ANY markdown file even files within the vault folderā¦ does not open that markdown file using GNOME. It just opens obsidian in whatever prior context it was regardless of the file selected.
simply opening a new tab of the markdown requested would be better behavior.
This is a very fascinating discussion. I think obsidian should eventually implement this natively, where if it can resolve the file to a vault, it opens the file within the vault, else it opens in a vault-less mode that allows editing or previewing of the individual file. Code editors like sublime and vscode have āprojectā views and āfileā views, and are smart enough to display one or the other depending on what you open in them.
In obsidianās defense, code editors generally allow you to configure plugins system wide (and thus they are available while editing individual files) whereas obsidianās plugins are on a per-vault basis. Users with lots of plugins would get a severely limited experience when opening a vaultless file, since there is no global or default plugin configuration for obsidian to fall back to. This makes this request a unique user experience problem that doesnāt have a perfectly analogous solution that the obsidian developers can follow.
In the meantime: I really liked some of the above suggestions. On macOS a separate āmarkdown openerā application that could be used as the handler for all md files, or a quick action that could be used as an alternate to opening the markdown file seem like the next best solution. As others have stated the logic in either case would be (1) if the note is part of an obsidian vault, open with obsidian url handler or (2) open with a default editor if not
I figured out a way to create an application on macOS that can do exactly this, now when I double click a markdown file it will either open in obsidian or sublime text. Instructions for Sublime text below. If you wish to use another application (such as TextEdit), just replace the āSublime Textā with the name of the text editor you want to use before saving your Automator application.
Instructions
- Open Automator:
- Navigate to your Applications folder and open Automator.
- Create a New Application:
- In Automator, choose to create a new
Application
.
- In Automator, choose to create a new
- Add a Run Shell Script Action:
- In the search bar at the top left, type āRun Shell Scriptā to find the action.
- Drag the āRun Shell Scriptā action to the workflow area on the right.
- Configure the Shell Script Action:
- In the āRun Shell Scriptā action, youāll see a text area where you can write your bash script.
- Set the
Shell
to/bin/bash
. - Set
Pass input
toas arguments
. - Copy and paste the below bash script into the text area provided.
# For each file that we are passed
for f in "$@"
do
# start at the folder the file is in
dir=$(dirname "$f")
# while we are not at the root of the hard drive
while [ "$dir" != "/" ]; do
# check to see if we have reached an obsidian vault
if [ -d "$dir/.obsidian" ]; then
# If we have, open in obsidian
open "obsidian://open?vault=$(basename "$dir")&file=${f#$dir/}"
exit
fi
# go up one folder to se if we are in an obsidian vault
dir=$(dirname "$dir")
done
# if we get this far, then we reached the root of the hard drive, and did not find an obsidian vault
# Fallback to Sublime Text
open -a "Sublime Text" "$f"
done
- Save the Automator Application:
- Go to File > Save or press Command-S.
- Save the Automator Application in your Applications folder with a suitable name (e.g.,
MarkdownHandler.app
).
- Set the Automator Application as the Default Handler:
- Find a
.md
file in Finder and right-click it. - Choose
Get Info
. - Expand the
Open with:
section. - Click the dropdown and choose
Other...
. - Navigate to and select your Automator Application (
MarkdownHandler.app
). - Click
Add
. - Click
Change All...
to set this application as the default for all.md
files.
- Find a
Now, whenever you open a markdown file, it will be processed by the inline script in your Automator Application and opened in the fileās containing obsidian vault whenever possible, or your fallback application otherwise.
Fallback editors Iāve tested the above script with:
- Sublime Text
- TextEdit
- iA Writer
- Visual Studio Code
You sir, are the grand master!
Works like a charm and I truly appreciate you sharing this.
I donāt know if something like this could be used by the developers of Obsidian to workaround the issues some people mentioned here. Iām not a developer myself, so whatever others were trying to explain on why Obsidian canāt open the .md files, goes over my head 100%.
Anyway, just wanted to thank you for sharing this
The .md files now have a different icon based on the MarkdownHandler.app
I was able to change this by changing the .icns file inside the MarkdownHandler.app (Right click > Show Package Contents > Contents > Resources > AutomatorApplet.icns).
I delete that file and copied the one inside Obsidian.app and put it in that same Resources folder.
I kept the name āAutomatorApplet.icnsā just in case, because I donāt know if that would make a difference or not.
And now all my files open using your script, and have the Obsidian icon:
Thereās a feature request to rectify that here: Global Settings / Same settings, themes, and plugins across multiple vaults
Without that, or at least an option to choose a primary vault and use its settings and plugins, the ability to use Obsidian as a markdown editor for files system-wide would be almost pointless.
Thank you! Thank you! Thank you!
I was looking for something exactly like this and I will promote it.
And it works with MarkEdit ( GitHub - MarkEdit-app/MarkEdit: Just like TextEdit on Mac but dedicated to Markdown. ) as well.
It works perfectly out-of-the-box on Windows 11. Thanks!
oh, great!
We could probably make a mac OS shortcut out of it.
It would be even easier to set up: just a download link and installā¦
not sure I can make it myself, but I might give it a try in the next daysā¦
I think it might be possible to solve it this way.
First Iām assuming that all the features in Obsidian are modularized and that itās relatively simple to set a feature to be enabled and disabled.
Next, the Vault configuration file could be placed in a fixed path, for example in My Documents, or in a path specified by the user.
Then, add a new entry point for Obsidian, such as āOpen file in standalone modeā.
When starting Obsidian from this entry, Obsidian will quit reading the .obsidian
folder in other directories, and instead read the contents from the path mentioned above.
At this point, Obsidian can disable all plugins and functions related to Vault features.
Next, itās just a matter of reading and saving the specified markdown file.
I think this might be a simpler way to implement this.
Thank you a lot! Thatās exactly what I wanted! Itās perfect and simple.
Iām on Linux. I use GitHub Desktop and git-cola (diffing my files).
I wanted to be able to quickly open the given file in Obsidian where I have tons of customized goodies for editing (Templater Js scripts, hotkey combos etc., while I donāt have those in other editors such as Sublime Text).
Enter obsidian-cli, which works on all platforms.
Iāll just put here a how-to on Linux, but itās a similar setup for other platforms.
Add in your file manager the default markdown opener a shell file, which should contain (provided you installed with brew):
#!/bin/bash
# Full path to the obs command
OBS_COMMAND="/home/linuxbrew/.linuxbrew/bin/obs"
# Check if a filename is provided as an argument
if [ $# -eq 0 ]; then
echo "Usage: $0 <markdown_file>"
exit 1
fi
# Get the filename from the first argument
markdown_file="$1"
# Extract the note name from the full file path and remove the leading directory path and the ".md" extension
note_name=$(basename "$markdown_file" .md)
# Open the Markdown file in Obsidian
$OBS_COMMAND open "$note_name"
- Save the file with .sh extension and make it executable (e.g.
chmod +x open_markdown_in_obsidian.sh
). You can put this file in a folder in your vault so it will be synced and not lost on a hard drive crash.
The experience is really good. The file opens faster than if I want to open a file inside Obsidian.
The cli has much more to give than just open files, of course. Itās an alternative to Obsidian URI.
+1 for this!
Would love to be able to open Obsidian files from Finder or iPhone search and for that file to be opened in the correct vault. +1
Loving Obsidian (and Typora for standalone files).
So Iām using a simple-stupid approach (windows - not perfect. only single vault and no pretty icons).
Create a file called obsition-typora.bat (code below ā requires customization). Then right click your .md-file and open with ā obsition-typora.bat. This automatically opens files in Obsidian if they are in VAULT_PATH, and uses ALT_EDITOR for everything else.
:: open a file either in obsidian or an alternative editor (based on path)
:: https://stackoverflow.com/questions/10218451/how-can-i-url-encode-spaces-in-an-nt-batch-file
:: Delayed Expansion will cause variables within a batch file to be expanded at execution time rather than at parse time
setlocal enableDelayedExpansion
:: the path with your obsidian notes. Change this to your own path
set "VAULT_PATH=Nextcloud\Notes"
:: the path to your alternative editor. Change this to your own path
set "ALT_EDITOR=C:\foobar\Typora.exe"
set "URLPATH=%*"
:: replace spaces with %20
set "URLPATH=!URLPATH: =%%20!"
ECHO.%URLPATH%| findstr /C:%VAULT_PATH%>Nul && (
Echo.Found %VAULT_PATH%
start explorer "obsidian://open?path=!URLPATH!"
) || (
Echo.Did not find %VAULT_PATH%
start %ALT_EDITOR% !URLPATH!
)
:: use pause for debugging
:: pause
Thatās an interesting workaround, but I still find Obsidian notably superior to Typora and other apps as a markdown editor, and wish I could use it on .md files located anywhere on my computer.
I really resonate with the frustration shared here about Obsidian not handling .md
files outside of vaults. It feels so limiting when I canāt quickly edit files that arenāt in my vault or open ones that are without jumping through extra hoops. Itās such a basic need for anyone working with Markdown regularly, and it would make a world of difference in our workflows. Hereās hoping this gets prioritized soon!