-
Notifications
You must be signed in to change notification settings - Fork 44
Add support for XDG Base Directory spec #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,12 +22,25 @@ | |
|
|
||
| command -v fzf >/dev/null 2>&1 || return | ||
|
|
||
| PROGRAM_NAME="${PROGRAM_NAME:-fzf-marks}" | ||
|
|
||
| CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/$PROGRAM_NAME" #currently unused, but in the future can be used to load (and store?) an .env file from to more easily switch between multiple configuration | ||
| DATA_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/$PROGRAM_NAME" | ||
| LEGACY_FZF_MARKS_FILE="${HOME}/.fzf-marks" | ||
|
|
||
| if [[ -z ${FZF_MARKS_FILE-} ]] ; then | ||
| FZF_MARKS_FILE=${HOME}/.fzf-marks | ||
| FZF_MARKS_FILE="${DATA_DIR}/default_bookmarks.fzf-marks" | ||
| fi | ||
|
|
||
| if [[ ! -f ${FZF_MARKS_FILE} ]]; then | ||
| if [[ ! -f "${FZF_MARKS_FILE}" ]]; then | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These quotes ( Similarly, the right-hand side of the variable assignments is neither subject to word splitting and pathname expansions, so the quotes in
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess I'm just used to using double quotes where possible to prevent word splitting. :)
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I think there is no downside to quote the parameter expansion, so yeah, this is a matter of preference. One of the reasons that the keyword
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @akinomyoga makes a good point. At some point in the future, I'll go through the codes and make sure we are consistent everywhere. Same with |
||
| # Fallback support for the previous default location of the bookmarks file. | ||
| if [[ -f "$LEGACY_FZF_MARKS_FILE" ]]; then | ||
| echo "Your FZF_MARKS_FILE is still in its legacy location of $LEGACY_FZF_MARKS_FILE; you might want to consider moving it to "$FZF_MARKS_FILE" so it follows the XDG standard, or explicitly set FZF_MARKS_FILE='$LEGACY_FZF_MARKS_FILE'." >&2 | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are the quotes around "$FZF_MARKS_FILE" necessary here? Since there are no quotes around $LEGACY_FZF_MARKS_FILE, it might be good to remove them for consistency?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe I already changed that based on @akinomyoga 's suggestions :)
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good, many thanks! :) |
||
| FZF_MARKS_FILE="$LEGACY_FZF_MARKS_FILE" | ||
| else | ||
| [[ ! -d "$DATA_DIR" ]] && mkdir "$DATA_DIR" && chmod 700 "$DATA_DIR" | ||
|
FiXato marked this conversation as resolved.
Outdated
|
||
| touch "${FZF_MARKS_FILE}" | ||
| fi | ||
| fi | ||
|
|
||
| if [[ -z ${FZF_MARKS_COMMAND-} ]] ; then | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.