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

Break up Zsh configuration files #265

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

defrank
Copy link
Contributor

@defrank defrank commented Dec 12, 2016

Depends on #246

defrank#10

Utilize:

  1. zshenv
    1. **/*path.zsh (except **/*fpath.zsh)
    2. **/*env.zsh
  2. zprofile
    1. **/*profile.zsh
  3. zshrc
    1. **/*fpath.zsh
    2. **/*.zsh (except **/*completion.zsh, **/*path.zsh, **/*env.zsh, **/*profile.zsh, **/*login.zsh, **/*logout.zsh)
    3. **/*completion.zsh
  4. zlogin
    1. **/*login.zsh
  5. zlogout
    1. **/*logout.zsh

Benefits

  • Inclusion of zprofile/zlogin and zlogout allow for specific files to be sourced when shell is a login shell. Useful for printing todo files, fortune, or cowsay files and scripts.
  • Inclusion of zshenv allows for non-interactive shells to still have the proper environment setup. That especially matters for any scripts that use #!/bin/zsh and are run as cronjobs.
  • zshrc is still the primary file with exception of environment variables moving to zshenv.

Derek Michael Frank added 3 commits July 17, 2016 13:13
Using `$ZSH` for the project root directory conflicts with zsh projects
and plugins (e.g., oh-my-zsh).  Change `$ZSH` -> `$DOTFILES`.

WIP: #8/b
 1. zshenv: path.zsh, env.zsh
 2. zprofile: profile.zsh
 3. zshrc: *.zsh, completion.zsh
 4. zlogin: login.zsh
 5. zlogout: logout.zsh

WIP: #10
 1. zshenv: *path.zsh, *env.zsh, *alias.zsh, *aliases.zsh
 2. zprofile: *profile.zsh
 3. zshrc: *fpath.zsh, *.zsh, *completion.zsh
 4. zlogin: *login.zsh
 5. zlogout: *logout.zsh

WIP: #10
typeset -U fpath_files interactive_files completion_files
fpath_files=($DOTFILES/**/*fpath.zsh)
interactive_files=($DOTFILES/**/*.zsh~**/*completion.zsh~**/*path.zsh~**/*env.zsh~**/*alias.zsh~**/*aliases.zsh~**/*profile.zsh~**/*login.zsh~**/*logout.zsh)
completion_file=($DOTFILES/**/*completion.zsh)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be completion_files...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thank you

# all of our non-path/env/profile/login/logout zsh files
typeset -U fpath_files interactive_files completion_files
fpath_files=($DOTFILES/**/*fpath.zsh)
interactive_files=($DOTFILES/**/*.zsh~**/*completion.zsh~**/*path.zsh~**/*env.zsh~**/*alias.zsh~**/*aliases.zsh~**/*profile.zsh~**/*login.zsh~**/*logout.zsh)
Copy link

@carhartl carhartl Dec 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe ~**/*aliases.zsh doesn't belong here. Otherwise aliases defined in zsh/aliases.zsh won't be sourced...

Copy link
Contributor Author

@defrank defrank Dec 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another good catch. Remnants of considering to source alias files in zshenv. Decided it was best to consider aliases as interactive only.

@carhartl
Copy link

Having read about startup files, according to http://zsh.sourceforge.net/Intro/intro_3.html:

`.zprofile' is meant as an alternative to `.zlogin' for ksh fans; the two are not intended to be used together

Should we even keep a .zprofile around?

@defrank
Copy link
Contributor Author

defrank commented Dec 17, 2016

Pros for .zprofile

the two are not intended to be used together, although this could certainly be done if desired

  • My intent was to not be exclusive or make the decision for people.
  • I added notes at the top of the two files to point out this concern.
  • There could still be a use for.zprofile as it gets sourced before .zshrc, unlike .zlogin which is sourced after.
  • .profile has long been a file of importance for shells. I think including the additional **/*profile.zsh files can offer more separation of configuration files.
  • Startup time is probably negligible globbing for **/*profile.zsh.

Cons for .zprofile

the two are not intended to be used together

  • May cause confusion with regards to .zlogin.
  • Slower startup time globbing for **/*profile.zsh and excluding it from **/*.zsh in .zshrc interactive files.

Conclusion

Overall, I don't think it hurts to keep .zprofile. If you worry it may cause confusion, the file is small which makes the note at the top likely to be read.

If .zprofile were also sourced after .zshrc, then I would lean towards its removal. However, this is not the case.

As .zprofile is still a ZSH startup file, I would prefer to keep it.

@carhartl
Copy link

carhartl commented Dec 17, 2016

👍 Thanks for clarifying @defrank, makes sense (I'm still new to zsh).

@defrank
Copy link
Contributor Author

defrank commented Dec 17, 2016

Yeah don't worry. I'm no expert either. Thanks for reviewing!

@carhartl
Copy link

Another problem I only noticed now: excluding ~**/*env.zsh in interactive_files leads to ruby/rbenv.zsh no longer being sourced, rendering rbenv setup broken... should we maybe presume that topic based env files will have to be named zshenv.zsh, e.g. topic/zshenv.zsh (and then same for all the other startup files)? Would make sense to me.

@carhartl
Copy link

I think there's also room for simplification if we were to adopt the suggested naming scheme. All topic path.zsh files would become zshenv.zsh, removing the need for maintaining both path_files=($DOTFILES/**/*path.zsh) and env_files=($DOTFILES/**/*env.zsh).

@defrank
Copy link
Contributor Author

defrank commented Dec 26, 2016

I think I'd rather just remove the wildcard prefix feature. It is an overcomplication.

  1. zshenv
    • **/*path.zsh **/path.zsh
    • **/*env.zsh **/env.zsh
  2. zprofile
    • **/*profile.zsh **/profile.zsh
  3. zshrc
    • **/*fpath.zsh
    • **/*.zsh~**/*completion.zsh~**/*path.zsh~**/*env.zsh~**/*profile.zsh~**/*login.zsh~**/*logout.zsh **/*.zsh~**/completion.zsh~**/path.zsh~**/env.zsh~**/profile.zsh~**/login.zsh~**/logout.zsh
    • **/*completion.zsh **/completion.zsh
  4. zlogin
    • **/*login.zsh **/login.zsh
  5. zlogout
    • **/*logout.zsh **/logout.zsh

This will allow rbenv.zsh to be sourced as an interactive file instead of an environment file. I suspect it was being sourced too early.

I will probably also want to rename system/_path.zsh --> system/path.zsh.

ajdexter pushed a commit to ajdexter/dotfiles that referenced this pull request Jan 5, 2019
lgo pushed a commit to lgo/dotfiles that referenced this pull request Jun 5, 2021
lgo pushed a commit to lgo/dotfiles that referenced this pull request Jun 5, 2021
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.

None yet

2 participants