Skip to content
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

Move all configurations into one directory #262

Open
neiromaster opened this issue Mar 5, 2023 · 7 comments
Open

Move all configurations into one directory #262

neiromaster opened this issue Mar 5, 2023 · 7 comments

Comments

@neiromaster
Copy link
Contributor

neiromaster commented Mar 5, 2023

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)

@unixorn
Copy link
Owner

unixorn commented Mar 5, 2023

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

@neiromaster
Copy link
Contributor Author

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.

@deetuned
Copy link

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-keys2
  • 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!

Footnotes

  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.

@unixorn
Copy link
Owner

unixorn commented Apr 19, 2023

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

@deetuned
Copy link

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

That was incredibly quick, and greatly appreciated!

Cheers! :)

@neiromaster
Copy link
Contributor Author

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

@unixorn
Copy link
Owner

unixorn commented May 8, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants