Skip to content

Conversation

@Sneethe
Copy link

@Sneethe Sneethe commented Jun 12, 2025

This conforms to ZSH behavior on where to put ZSH files.
As $ZDOTDIR is where things like .zshrc and .zsh_history is stored.

For majority of users $ZDOTDIR will = $HOME thus the default location is preserved.

If user has changed $ZDOTDIR to say $HOME/.config/zsh then upon this plugin's installation, .z will be in $HOME/.config/zsh

To avoid breakage for users who have set a custom $ZDOTDIR to something other than $HOME. but haven't changed the default database location of $HOME/.z
We do this:

: ${datafile:=$HOME/.z}
  [[ -f $datafile ]] || datafile=${ZDOTDIR:-$HOME}/.z

So even if $ZDOTDIR has been customized, we still default to the default database file location if it exists.

And thank you for making this plugin. Its very much appreciated.

Sneethe added 2 commits June 12, 2025 14:03
This better follows ZSH behavior on where to put ZSH files.
@Sneethe
Copy link
Author

Sneethe commented Jun 12, 2025

And as for why. Well if a user has gone out of their way to configure $ZDOTDIR then its very likely they don't like their $HOME cluttered with dotfiles.

Also I felt it made sense for .z to be in the same path as .zsh_history

@agkozak agkozak self-assigned this Jun 12, 2025
@Sneethe
Copy link
Author

Sneethe commented Jun 16, 2025

Just read through #20.
I think using 'XDG Base Directory Specification' just for a single file isn't appropriate. With #96 not even following the actual XDG spec.

setting datafile=$XDG_CONFIG_HOME/.z or $HOME/.local/state.z both of these aren't valid.

I do however agree with bavalpey that the number of people who use both zsh-z and bash's z simultaneously has to very small.

This PR would only break rupa/z if a user did the following steps in order:

  • Starts using zsh-z
  • Sets $ZDOTDIR to something
  • Then decides to start using bash with rupa/z

@Sneethe Sneethe changed the title Follow $ZDOTDIR on installation Respect $ZDOTDIR on installation Jun 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants