xwmx / nb

CLI and local web plain text note‑taking, bookmarking, and archiving with linking, tagging, filtering, search, Git versioning & syncing, Pandoc conversion, + more, in a single portable script.
https://xwmx.github.io/nb
GNU Affero General Public License v3.0
6.64k stars 188 forks source link

[bug?] Unable to override `EDITOR` variable #241

Closed amithm7 closed 7 months ago

amithm7 commented 1 year ago

Say, EDITOR is set to vim.

And I would want to open a specific file only in VS code.

EDITOR=code nb e file.md

doesn't seem to work, it would still open in vim.

xwmx commented 1 year ago

nb previously used $EDITOR internally, so the value in .nbrc was originally intended to override the environment value. In recent versions there is a new $NB_EDITOR variable that can be used, so this should work:

NB_EDITOR=code nb e file.md
amithm7 commented 1 year ago

So, I believe all variables in .nbrc override environment variables.

That would mean everything set by nb set can't be overridden!!! (or is there a way?)

This gets a little confusing:

Edit the note with \<editor>, overriding the editor specified in the $EDITOR environment variable.

Usage:
  nb edit ([<notebook>:][<folder-path>/][<id> | <filename> | <title>])
          [-c <content> | --content <content>] [--edit]
          [-e <editor> | --editor <editor>] [--overwrite] [--prepend]

Options:
  -e, --editor <editor>    Edit the note with <editor>, overriding the editor
                           specified in the `$EDITOR` environment variable.
xwmx commented 1 year ago

That would mean everything set by nb settings can't be overridden!!! (or is there a way?)

This only applies to $EDITOR when set through nb set. Other variables set through nb set use the environment value when available. This is part of why the $NB_EDITOR variable was added. The behavior is confusing because this particular setting is intended to override the environment variable.

xwmx commented 7 months ago

This should be working now, and further improvements were made as part of #303. Let me know if you run into any more issues with it. Thanks!