notesmd-cli icon indicating copy to clipboard operation
notesmd-cli copied to clipboard

Accept a note absolute path as argument to the `open` command

Open lyndhurst opened this issue 3 years ago • 5 comments

Hi,

I am trying to make obsidian more terminal friendly, and I gotta say that your utility could be a great help to me.

I am personally not satisfied at all with the way obsidian handles tags and file names in searches, and I use another CLI application called zk to manage my notes from the terminal or neovim.

zk has a nice built-in fzf search functionality that I would like to use instead of obsidian searches. Unfortunately, it seems that zk passes the absolute path to the editor command I have set obs open in its config file.

Do you think it would be possible to make obsidian-cli accept absolute paths to a note as an argument ?

Please Note: I have set a default vault, and I can make obsidian-cli open notes without any problem using vault relative paths, but if I pass an absolute path to obsidian-cli, nothing happens.

lyndhurst avatar Mar 01 '23 11:03 lyndhurst

Looking at your code I got the idea that you are actually taking the file basename, and constructing a valid obsidian url. This means two things for me:

  1. the obsidian documentation states that using a full path in the obsidian url is possible, and removes the requirement of specifying the vault; which in my personal case would be nice.
  2. I was able to make a little script to solve my problem with a simple xdg-open magic.

I am leaving this issue open in case you are interested in adding this feature to your code as it is more sophisticated than my little script, and I am sure it can be useful to people needing some external processing.

Thanks for your time.

lyndhurst avatar Mar 01 '23 13:03 lyndhurst

Thank you for using obsidian-cli, I am glad you're finding it useful. I can definitely add that to my list of feature requests as it should be possible with Obsidian URIs (as you said) but its not something I will focus on in the short term.

Yakitrak avatar Mar 15 '23 16:03 Yakitrak

Please feel free to add a pull request if you want to contribute and know how to achieve this. It shouldn't be too hard but we need to make sure it doesn't break existing functionality which should default to using path from the vault root.

Yakitrak avatar Mar 15 '23 16:03 Yakitrak

Thank you for your answer.

Thanks to your code logic, I managed very easily to solve my problem with a one line script, so I am in no hurry.

The added benefit of using absolute path is that it really simplifies the logic since the vault root path does not have to be specified. Maybe a routine to check that a vault exists within that path could be added to avoid errors.

Anyway, since I do not know go and do not have an urgent need for that feature anymore, chances of me adding a PR are very slim, sorry. But thanks again for considering this feature request :+1:

lyndhurst avatar Mar 18 '23 07:03 lyndhurst

Hi, sorry this is late but the new search command starts a fuzzy search which will allow you to search by note name or path. This should resolve your issue / feature request. Please let me know if you have any issues.

Yakitrak avatar Jan 13 '25 13:01 Yakitrak