Skip to content

Commit

Permalink
Support $XDG_CONFIG_HOME
Browse files Browse the repository at this point in the history
Backwards compatible change that supports storing the bookmarks in
$XDG_CONFIG_HOME/cd-bookmarks.

* If the user as set the previously
existing $CD_BOOKMARK_FILE, this is always overriding.
* If the user has created the directory/file
  $XDG_CONFIG_HOME/cd-bookmarks/(bookmarks), use this
* Else fall back to old default $HOME/.cdbookmark

Fixes mollifier#3
  • Loading branch information
erikw committed Nov 4, 2021
1 parent f5943f0 commit 20fe917
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cd-bookmark
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,18 @@
# or: cd-bookmark [-l]
#

function _cdbookmark_get_config_file() {
if ! [ -z ${CD_BOOKMARK_FILE+x} ]; then
echo "$CD_BOOKMARK_FILE"
elif [ -d ${XDG_CONFIG_HOME:-$HOME/.config}/cd-bookmark ]; then
echo "${XDG_CONFIG_HOME:-$HOME/.config}/cd-bookmark/bookmarks"
else
echo "${HOME}/.cdbookmark"
fi
}

typeset -r SCRIPT_NAME="cd-bookmark"
typeset -r BOOKMARK_FILE="${CD_BOOKMARK_FILE:-${HOME}/.cdbookmark}"
typeset -r BOOKMARK_FILE="$(_cdbookmark_get_config_file)"

function _cdbookmark_print_usage() {
cat << EOF
Expand Down

0 comments on commit 20fe917

Please sign in to comment.