Skip to content

Commit 20fe917

Browse files
committed
Support $XDG_CONFIG_HOME
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 #3
1 parent f5943f0 commit 20fe917

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

cd-bookmark

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,18 @@
1717
# or: cd-bookmark [-l]
1818
#
1919

20+
function _cdbookmark_get_config_file() {
21+
if ! [ -z ${CD_BOOKMARK_FILE+x} ]; then
22+
echo "$CD_BOOKMARK_FILE"
23+
elif [ -d ${XDG_CONFIG_HOME:-$HOME/.config}/cd-bookmark ]; then
24+
echo "${XDG_CONFIG_HOME:-$HOME/.config}/cd-bookmark/bookmarks"
25+
else
26+
echo "${HOME}/.cdbookmark"
27+
fi
28+
}
29+
2030
typeset -r SCRIPT_NAME="cd-bookmark"
21-
typeset -r BOOKMARK_FILE="${CD_BOOKMARK_FILE:-${HOME}/.cdbookmark}"
31+
typeset -r BOOKMARK_FILE="$(_cdbookmark_get_config_file)"
2232

2333
function _cdbookmark_print_usage() {
2434
cat << EOF

0 commit comments

Comments
 (0)