Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions nb
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,30 @@ _option_value_is_present() {

# $NBRC_PATH
#
# Default: `$HOME/.nbrc`
#
# The location of the .nbrc configuration file.
export NBRC_PATH="${NBRC_PATH:-"${HOME}/.${_ME}rc"}"
# Default: `$HOME/.nbrc`, or `$XDG_CONFIG_HOME/nb/config` if `XDG_CONFIG_HOME`
# is defined and `$HOME/.nbrc` does not already exist

# This is the old way of determining the global nbrc path, to preserve
# backwards compatibility. I propose deprecating it.
_deprec_default_nbrc="${HOME}/.${_ME}rc"

# This is the new, XDG-compliant default location
_xdg_default_nbrc="${XDG_CONFIG_HOME:-${HOME}/.config}/${_ME%%.*}/${_ME}rc"

# Choose a default path to use
if [[ -e "${_deprec_default_nbrc}" ]]; then
# If the old default nbrc file exists, use it
_nbrc_path="${_deprec_default_nbrc}"
# TODO: Potentially output a warning here that this location is deprecated.
else
# Otherwise, use the new, XDG-compliant default path
_nbrc_path="${_xdg_default_nbrc}"
fi

# In either case, defer to a potential external definition of NBRC_PATH
export NBRC_PATH="${NBRC_PATH:-${_nbrc_path}}"
# TODO: Create the path to the nbrc file if it does not exist yet. Perhaps do
# this in the _init_create_rc_file function.

# Handle symlinked NBRC_PATH.
if [[ -L "${NBRC_PATH}" ]]
Expand Down