pimterry/notes

Notes open does not cd to notes directory

Closed this issue · 3 comments

Issue Summary

The documentation as well as the --help command specify that using notes open|o would open my notes directory. But it does not.

Steps to Reproduce

  1. Install notes
  2. Specify your notes directory
  3. Enter notes o

After these steps, this is the output of the script: /usr/local/bin/notes: line 232: open: command not found

Technical details:

  • notes version: 1.3.0

This is the current design, yes, but I can see how that could be confusing here...

The intent is that the directory is opened in your default handler for directories (i.e. a file manager) rather than cd-ing directly. We assume that open (a very-common-but-not-actually-standard alias for xdg-open) is available to do this.

Do you have xdg-open on your machine? Do you have an open alias to it?

I think:

  • We should probably check for xdg-open first, and prefer that to open where available.
  • We could very easily fallback to cd if neither is available.
  • We could add a notes cd command, to support the kind of behaviour you're describing, since I can imagine cases where that might be helpful. An optional subdir argument would probably be helpful there too (notes cd projects/abc).

Would that work for you? PRs welcome!

In my .zshrc, I do have an alias open=xdg-open. However, running the script still results in an error open command not found.

A possible reason is may be since I am on ZSH, and the script is in #!/usr/bin/env bash, it does not recognise any of the zsh aliases on my machine.

I think your solution for checking for xdg-open > open in preference is the best way to approach using the open command. However, I think notes open should not default to cd as I may simply want to change directories in the terminal and not use a different application to open $NOTESDIR. notes cd seems like a great command.

Ah, that makes sense, yes if this is a zsh-only alias you'll run into problems. Of course you could quickly fix this by setting that alias more widely instead 😄.

But I do thing it would be nice to improve this anyway to avoid that. If you're interested in implementing some or all of the ideas above, please open a PR. Let me know if you have any questions about that at all.