[Grml] A scheme to manage several ZSH config file collections?
Frank Terbeck
ft at grml.org
Thu Jul 24 21:07:40 CEST 2008
Richard Hartmann <richih.mailinglist at gmail.com>:
> On Thu, Jul 24, 2008 at 14:58, Frank Terbeck <ft at grml.org> wrote:
> >> 1. Don't touch the current zshrc at all. It works fine and should be
> >> left intact unmodified.
> >
> > We'll need to stop the normal zshrc from sourcing, so something like:
>
> If there _is_ no normal zshrc, zsh-newuser-install will run. As we can
> easily replace this function, ZSH does the handling of this for free.
As I said, I would not want to touch /etc/zsh/zshrc. It will always be
there. Hence, the catch is needed.
I also do not want to touch ~/.zshrc. It should always be there. If we
can set ZDOTDIR before zsh is run, we do have means to support the
*full* range of zsh config files. No need to touch ~/.zshrc at all.
I really would prefer to keep grml's zsh config like it is now, and if
you want to switch, you use a function, say 'zmode <whateverrc>' to
spawn a differently set up shell.
You can even write the current mode into a file, so that subsequently
opened shells automatically use that setup.
No need to fiddle with newuser-install, at all.
[...]
> >> 4. add /etc/zsh/rcs/richih.d/ at the *beginning* be $fpath so that
> >> colliding functions are not taken from the default dir, but from
> >> the dir that is part of the config, that is in action.
>
> [[ -n $ZSHRC_ALT ]] && . /etc/zsh/rcs/$ZSHRC_ALT.d
>
> in all zshrcs would mean you can fork and otherwise mangle them
> without needing to touch anything in the actual file.
With '/etc/zsh/rcs/$ZSHRC_ALT.d' being a directory, that would
certainly lead to funny results.
It should be a directory that holds the function files specific for
the configuration in question. And in order to overwrite same-named
functions from /etc/zsh/functions.d it *must* be put at the start of
$fpath.
> >> Do NOT source /etc/zsh/zshrc in that case.
>
> This should exist and overwrite the normal zsh-newuser-install.
It shou
> >> Do NOT source ~/.zshrc in that case (set $ZDOTDIR to
> >> ~/.zshrc.$ZSHRC_ALT - that would make ~/.zshrc.$ZSHRC_ALT/.zshrc
> >> to be sourced; standard zsh mechanism.)
> >
> > We should touch a .zshrc in there if a given configuration does not
> > provide one in order to avoid the newuser-module-dialog.
>
> I would rather have a ~/.zshrc that simply uses $ZDOTDIR to
> source everything. Solves two problems in one go.
That's not what $ZDOTDIR is meant for at all.
It is meant for switching to alternate configurations.
If $ZDOTDIR is unset, the value of $HOME is used. Hence $HOME/.zshrc
is used in normal environments.
Is $ZDOTDIR is /foo/bar/, /foo/bar/.zshrc is used. No matter what
$HOME is set to.
This is (besides the obvious need to set $ZSHRC_ALT, and the
previously explained need for setting $fpath) the reason for my point
no. 5.
> >> 5. Do the handling of $ZSHRC_ALT, $ZDOTDIR and $fpath in the global
> >> zshenv (/etc/zsh/zshenv) in a
> >>
> >> if [[ -o interactive ]] ; then
> >> fi
> >>
> >> Block;
>
> Would also be solved by the above, so make that three.
It wouldn't. IMHO. See above.
Regards, Frank
--
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
-- RFC 1925
More information about the Grml
mailing list