Problem
nb.plugin.zsh currently sets no defaults for the variables upstream nb
uses to decide where it writes files, so a fresh install falls back to
$HOME/.nbrc, $HOME/.nb, and (for nb shell) $HOME/.nb_history.
Upstream nb (vendored at src/nb) already honors these as
"${VAR:-default}", so exporting them before nb runs is enough — no
upstream patch needed.
Complication
Both of z-shell/nb's own documented Zi install recipes skip sourcing
nb.plugin.zsh entirely:
docs/README.md's primary recipe uses as'program'.
package.json's zi-ices.default uses as'completion'.
Zi does not source the plugin file under either as mode, so defaulting
logic placed only in nb.plugin.zsh's body is effectively dead code for
users following the README. The fix needs an atinit hook (which Zi runs
regardless of as) added to both the README recipes and
package.json's zi-ices.default, in addition to the same guarded logic
inside nb.plugin.zsh for anyone who does source it directly (Oh My Zsh,
manual source, or a non-as'program' ice).
Proposed defaults
| Variable |
New default |
Skip if this legacy path already exists |
NBRC_PATH |
${XDG_CONFIG_HOME:-$HOME/.config}/nb/nbrc |
~/.nbrc |
NB_DIR |
${XDG_DATA_HOME:-$HOME/.local/share}/nb |
~/.nb |
NB_HIST |
${XDG_STATE_HOME:-$HOME/.local/state}/nb/history |
~/.nb_history |
Each default only applies when the variable is unset and its legacy
$HOME path doesn't already exist, so existing installs keep working
unchanged and only fresh installs get XDG paths. All other nb variables
need no plugin change since nb already reads them the same way.
NBRC_PATH's parent directory needs an explicit mkdir -p when we default
it to the nested .../nb/nbrc path, because upstream _init_create_rc_file
(nb init) writes the rc file with a bare > redirect and no mkdir -p
safety net, unlike its data-dir creation path.
Out of scope (tracked separately)
nb.plugin.zsh's current entry-point boilerplate uses the shared Plugins
hash key pattern that PATTERNS.md and the current Zsh Plugin Standard both
say not to use (unconditional overwrite with no pre-load snapshot, no
unload function). That's a distinct, more mechanical fix and will get its
own issue rather than being bundled into this one.
Problem
nb.plugin.zshcurrently sets no defaults for the variables upstreamnbuses to decide where it writes files, so a fresh install falls back to
$HOME/.nbrc,$HOME/.nb, and (fornb shell)$HOME/.nb_history.Upstream
nb(vendored atsrc/nb) already honors these as"${VAR:-default}", so exporting them beforenbruns is enough — noupstream patch needed.
Complication
Both of z-shell/nb's own documented Zi install recipes skip sourcing
nb.plugin.zshentirely:docs/README.md's primary recipe usesas'program'.package.json'szi-ices.defaultusesas'completion'.Zi does not source the plugin file under either
asmode, so defaultinglogic placed only in
nb.plugin.zsh's body is effectively dead code forusers following the README. The fix needs an
atinithook (which Zi runsregardless of
as) added to both the README recipes andpackage.json'szi-ices.default, in addition to the same guarded logicinside
nb.plugin.zshfor anyone who does source it directly (Oh My Zsh,manual
source, or a non-as'program'ice).Proposed defaults
NBRC_PATH${XDG_CONFIG_HOME:-$HOME/.config}/nb/nbrc~/.nbrcNB_DIR${XDG_DATA_HOME:-$HOME/.local/share}/nb~/.nbNB_HIST${XDG_STATE_HOME:-$HOME/.local/state}/nb/history~/.nb_historyEach default only applies when the variable is unset and its legacy
$HOMEpath doesn't already exist, so existing installs keep workingunchanged and only fresh installs get XDG paths. All other
nbvariablesneed no plugin change since nb already reads them the same way.
NBRC_PATH's parent directory needs an explicitmkdir -pwhen we defaultit to the nested
.../nb/nbrcpath, because upstream_init_create_rc_file(
nb init) writes the rc file with a bare>redirect and nomkdir -psafety net, unlike its data-dir creation path.
Out of scope (tracked separately)
nb.plugin.zsh's current entry-point boilerplate uses the sharedPluginshash key pattern that PATTERNS.md and the current Zsh Plugin Standard both
say not to use (unconditional overwrite with no pre-load snapshot, no
unload function). That's a distinct, more mechanical fix and will get its
own issue rather than being bundled into this one.