dotfiles
dotfiles copied to clipboard
Break up Zsh configuration files
Depends on https://github.com/holman/dotfiles/pull/246
defrank/dotfiles#10
Utilize:
- zshenv
-
**/*path.zsh
(except**/*fpath.zsh
) -
**/*env.zsh
-
- zprofile
-
**/*profile.zsh
-
- zshrc
-
**/*fpath.zsh
-
**/*.zsh
(except**/*completion.zsh
,**/*path.zsh
,**/*env.zsh
,**/*profile.zsh
,**/*login.zsh
,**/*logout.zsh
) -
**/*completion.zsh
-
- zlogin
-
**/*login.zsh
-
- zlogout
-
**/*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.
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?
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.
👍 Thanks for clarifying @defrank, makes sense (I'm still new to zsh).
Yeah don't worry. I'm no expert either. Thanks for reviewing!
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.
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)
.
I think I'd rather just remove the wildcard prefix feature. It is an overcomplication.
-
zshenv
- ~
**/*path.zsh
~**/path.zsh
- ~
**/*env.zsh
~**/env.zsh
- ~
-
zprofile
- ~
**/*profile.zsh
~**/profile.zsh
- ~
-
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
- ~
-
zlogin
- ~
**/*login.zsh
~**/login.zsh
- ~
-
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.