zsh-quickstart-kit icon indicating copy to clipboard operation
zsh-quickstart-kit copied to clipboard

Move all configurations into one directory

Open neiromaster opened this issue 1 year ago • 7 comments

Feature Request

Is your feature request related to a problem? Please describe.

Currently, all configuration files and directories (e.g., .zsh-quickstart-no-omz, .zsh-quickstart-kit-prompt-switch-warning, .zshrc.pre-plugins.d and many others) must be in the user directory, which is very cluttered with numerous settings. Should we consider moving all of these files to a single location? As an option, you can make a single hidden directory directly in the user directory, or as a more common option in .config dir.

Describe the solution you'd like

For example, move all settings into $HOME/.zqs-config/ or $HOME/.config/zqs-config (https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)

neiromaster avatar Mar 05 '23 19:03 neiromaster

Good idea. They started slowly accumulating. For backwards compatibility we should leave the local plugins in ~, everything else can go into ~/zqs-configuration

unixorn avatar Mar 05 '23 20:03 unixorn

I could add migration. For example, if there is no end directory, then we have the old location of the settings and we can migrate everything. We would end up with just one check for this.

I was also thinking that we could add a coloring of the output to accentuate certain events for users.

neiromaster avatar Mar 05 '23 20:03 neiromaster

I've actually been maintaining a fork since November that more or less does what @neiromaster is requesting. If the user has specifically gone out of their way to set $ZDOTDIR in ~/.zshenv and the fleet of $XDG_*_HOMEvariables, then all quickstart kit files (barring ~/.fzf/ and ~/.fzf.zsh) are decluttered from $HOME. If these variables are unset, then just operate on $HOME like before. Keeps everything simple and in plain site for new users who wouldn't have such variables set, while allowing powerusers to explicitly control their files.

Let's assume the user has set ZDOTDIR=~/.config/zsh, XDG_DATA_HOME=~/.local/share, and XDG_CACHE_HOME=~/.cache.

In ~/.config/zsh/:

  • .p10k.zsh
  • .zqs/
  • .zshrc.d/
  • .zshrc.pre-plugins.d/
  • .iterm2_shell_integration.zsh
  • .zcompdump* and .zcomp/ (completions)
  • .zcache/
  • .zgen-setup
  • .zsh_history
  • .zprofile (if needed for extra $PATH changes)[^1]
  • .zsh_aliases
  • .zsh_functions

In ~/.config/zsh/.zqs/ (examples):

  • zsh-quickstart-kit-prompt-switch-warning
  • zsh-quickstart-last-update
  • zqs-settings/

In ~/.config/zsh/.zqs/zqs-settings/:

  • list-ssh-keys
  • load-ssh-keys[^2]
  • Etc.

In ~/.cache/:

  • p10k-instant-prompt-*.zsh (instant prompt)

In ~/.local/share/:

  • .zqs-zgenom/
  • .zgenom/

The reason for organising where the quickstart kit's configurations are stored (and keeping zgenom, plugins and friends away from the configurations) is so that I can have any big or small change made to either the fork itself or my shell dotfiles (zsh, NeoVim, etc.) instantly and automatically propagate to every one of my machines

Unfortunately, I am by no means a trained developer. Most of the implementation relies on painfully simple abuse of ${ZDOTIDR:-$HOME}/<path>in all file checks or operations. Ideally, I'd define a variable in .zprofile or at the top of .zshrc that sets the required quickstart-kit-related directories with a few initial checks. And when operating on the ~/config/zsh/.zshrc.d/~/.config/zsh/.zqs/STUFF/~/local/share/.zgenom/etc. files, I'd check if we're using $ZDOTDIR and friends then remove the leading .s (or just set them at the top as well). The fork is just a personal hack. But I stumbled across this open issue and figured I'd engage in the discussion. I, too, would like it all to be just a little bit more organised.

Feel free to see the changes here, but please wear eye protection; it's dangerous in there: deetuned/zsh-quickstart-kit/tree/dev

P.S Thank you for all your hard work on this kit, @unixorn!

[^1]: When trying to prepend your $PATH in order to put custom- or user-installed search paths first, .zshrc.d won't cut it on macOS because it's loaded after .zshrc and as such Apple forces their directories at the start of $PATH. $ZDOTDIR/.zprofile is the only way I can override Apple's built-in shell commands/binaries.

[^2]: I added a check in the quickstart kit's .zshrc for the load-ssh-keys setting. If the setting is false, then don't load keys using ssh-add. GNU doesn't have --apple-load-keychain and I use gpg-agent with a YubiKey anyway.

deetuned avatar Apr 19 '23 04:04 deetuned

@deetuned I broke out yubikey ssh handling as https://github.com/unixorn/zsh-quickstart-kit/issues/267.

unixorn avatar Apr 19 '23 14:04 unixorn

@deetuned I broke out yubikey ssh handling as #267.

That was incredibly quick, and greatly appreciated!

Cheers! :)

deetuned avatar Apr 19 '23 14:04 deetuned

@unixorn, how would you feel about me using @deetuned's suggested folders to store zqs configuration?

neiromaster avatar May 08 '23 05:05 neiromaster

I think it'd be a good idea. I haven't had time to start work on it, so if you do, go ahead. Make it default to using ~ so we don't break existing installs, and there should be a zqs command to migrate the settings to the new directory structure.

I'm going to add a bin dir to store one-use commands like that so that they can be standalone scripts and not add to the size of .zshrc and increase start time for new sessions.

unixorn avatar May 08 '23 12:05 unixorn