zsh-users
 help / color / mirror / code / Atom feed
* Please implement auto-handling of ${HOME}/.zsh/
@ 2013-03-20 19:16 Larry Schrof
  2013-03-20 19:54 ` Moritz Bunkus
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Larry Schrof @ 2013-03-20 19:16 UTC (permalink / raw)
  To: zsh-users

I have been dying for this for many years.  I have a ton of zsh configs,
so I like to organize them in ~/.zsh/ , but here's the problem.

First, I have to create a symlink ~/.zshenv and point it to ~/.zsh/.zshenv
Then, as the first thing to do in ~/.zsh/.zshenv, I have to do:
   export ZDOTDIR=${HOME}/.zsh

This is janky and is messier than it needs to be.

It would be awesome if something like the following happened. Forgive me
if the implementation is flawed; just note the spirit of my suggestion.

- Before zsh begins to process the first user-based config file
  (I believe ~/.zshenv), look for the existence of ~/.zsh/ (a directory).
- If this directory does not exist, proceed normally. (Start reading
~/.zshenv)
- If this directory DOES exist:
---> Automatically set ZDOTDIR to ${HOME}/.zsh/
---> Ignore any ~/.zsh* files (If the user is using ~/.zsh/ it's their job
to
     understand that ~/.zsh* files won't be read.)
--> Begin reading ${HOME}/.zsh/.zshenv

What's the likelihood this would be implemented in the near future?


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Please implement auto-handling of ${HOME}/.zsh/
  2013-03-20 19:16 Please implement auto-handling of ${HOME}/.zsh/ Larry Schrof
@ 2013-03-20 19:54 ` Moritz Bunkus
  2013-03-20 20:55 ` Paul Hoffman
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Moritz Bunkus @ 2013-03-20 19:54 UTC (permalink / raw)
  To: Larry Schrof; +Cc: zsh-users

Hey,

I'd love to have this, but two things that could be made even better
in my opinion:

1. Check $XDG_CONFIG_HOME/zsh as well as ~/.zsh. The former is from
the XDG Base Directory Specification[1] which I'd love to see zsh
follow. $XDG_CONFIG_HOME defaults to ~/.config if unset.

2. If one of those directories exists then look for $that_dir/zshenv
and not $that_dir/.zshenv. Hiding the files only makes sense for
$HOME, not for a sub-directory. Same should be true for
$that_dir/zshrc and the other files.

So my proposal would be:

- Look for an existing directory $XDG_CONFIG_HOME/zsh (if
$XDG_CONFIG_HOME is unset assume default $HOME/.config) or $HOME/.zsh
- If that directory exists set ZDOTDIR to it and read configuration
files from that directory. The files are not prefixed with .
- If that directory does not exist then proceed as before: read
configuration files from $HOME, the files are prefixed with .

Kind regards,
mosu


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Please implement auto-handling of ${HOME}/.zsh/
  2013-03-20 19:16 Please implement auto-handling of ${HOME}/.zsh/ Larry Schrof
  2013-03-20 19:54 ` Moritz Bunkus
@ 2013-03-20 20:55 ` Paul Hoffman
  2013-03-20 21:25   ` TJ Luoma
  2013-03-21  5:41 ` Bart Schaefer
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: Paul Hoffman @ 2013-03-20 20:55 UTC (permalink / raw)
  To: zsh-users

On Wed, Mar 20, 2013 at 07:16:39PM +0000, Larry Schrof wrote:
> I have been dying for this for many years.  I have a ton of zsh configs,
> so I like to organize them in ~/.zsh/ , but here's the problem.
> 
> First, I have to create a symlink ~/.zshenv and point it to ~/.zsh/.zshenv
> Then, as the first thing to do in ~/.zsh/.zshenv, I have to do:
>    export ZDOTDIR=${HOME}/.zsh
> 
> This is janky and is messier than it needs to be.

Yes, but OTOH you only have to do it once.  

> It would be awesome if something like the following happened. Forgive me
> if the implementation is flawed; just note the spirit of my suggestion.
> 
> - Before zsh begins to process the first user-based config file
>   (I believe ~/.zshenv), look for the existence of ~/.zsh/ (a directory).
> - If this directory does not exist, proceed normally. (Start reading
> ~/.zshenv)
> - If this directory DOES exist:
> ---> Automatically set ZDOTDIR to ${HOME}/.zsh/
> ---> Ignore any ~/.zsh* files (If the user is using ~/.zsh/ it's their job
> to
>      understand that ~/.zsh* files won't be read.)
> --> Begin reading ${HOME}/.zsh/.zshenv

Interesting, but some people (well, *I*) have already organized their 
~/.zsh/* differently and this change would break things.

> What's the likelihood this would be implemented in the near future?

I hope it isn't -- IMNSHO janky is better than something that might 
break things and that would complicate the already complicated startup 
process (and add to its long and complicated documentation).

Paul.

-- 
Paul Hoffman <nkuitse@nkuitse.com>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Please implement auto-handling of ${HOME}/.zsh/
  2013-03-20 20:55 ` Paul Hoffman
@ 2013-03-20 21:25   ` TJ Luoma
  0 siblings, 0 replies; 8+ messages in thread
From: TJ Luoma @ 2013-03-20 21:25 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 926 bytes --]

On Wed, Mar 20, 2013 at 4:55 PM, Paul Hoffman <nkuitse@nkuitse.com> wrote:

> On Wed, Mar 20, 2013 at 07:16:39PM +0000, Larry Schrof wrote:
> > I have been dying for this for many years.  I have a ton of zsh configs,
> > so I like to organize them in ~/.zsh/ , but here's the problem.
> >
> > First, I have to create a symlink ~/.zshenv and point it to
> ~/.zsh/.zshenv
> > Then, as the first thing to do in ~/.zsh/.zshenv, I have to do:
> >    export ZDOTDIR=${HOME}/.zsh
> >
> > This is janky and is messier than it needs to be.
>
> Yes, but OTOH you only have to do it once.
>

Assuming this is your computer, you do something with /etc/z* which would
look for ~/.zsh and save you having to symlink ~/.zshenv

Personally I have all of my Zsh stuff in ~/Dropbox/etc/zsh/ and when I
setup a new system all I have to do is

ln -s Dropbox/etc/zsh/zshenv.sh .zshenv

ln -s Dropbox/etc/zsh/zshrc.sh .zshrc

hardly seems onerous.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Please implement auto-handling of ${HOME}/.zsh/
  2013-03-20 19:16 Please implement auto-handling of ${HOME}/.zsh/ Larry Schrof
  2013-03-20 19:54 ` Moritz Bunkus
  2013-03-20 20:55 ` Paul Hoffman
@ 2013-03-21  5:41 ` Bart Schaefer
  2013-03-21 12:05   ` Richard Hartmann
  2013-03-21  8:17 ` Axel Beckert
  2013-03-21 12:03 ` Richard Hartmann
  4 siblings, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2013-03-21  5:41 UTC (permalink / raw)
  To: zsh-users

On Mar 20,  7:16pm, Larry Schrof wrote:
}
} First, I have to create a symlink ~/.zshenv and point it to ~/.zsh/.zshenv
} Then, as the first thing to do in ~/.zsh/.zshenv, I have to do:
}    export ZDOTDIR=${HOME}/.zsh

Why not create a ~/.zshenv that does

    export ZDOTDIR=${HOME}/.zsh
    source $ZDOTDIR/.zshenv

and forget about the symlinks?  Then you can even do the rest of the stuff
you're suggesting:

    if [[ -d ~/.zsh ]]; then
      export ZDOTDIR=${HOME}/.zsh
      source $ZDOTDIR/.zshenv
    fi

} What's the likelihood this would be implemented in the near future?

As C code, small to none.

Like TJ, I have a common set of config files stored on the web.  (Not
in Dropbox, in a source repository from which I check out to ~/.zsh,
but it's the same idea.)  One of the files in that repository is a
script called ".installer" which writes something much like the above
into ~/.zshenv (with a warning if that would clobber an existing file,
etc.).  I haven't yet needed to, but I've considered having .installer
also write bash init files that exec zsh if zsh is not in /etc/shells.

So on any new host, I just check out the .zsh directory, run .installer,
resolve a conflict if it reports one, and I'm done.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Please implement auto-handling of ${HOME}/.zsh/
  2013-03-20 19:16 Please implement auto-handling of ${HOME}/.zsh/ Larry Schrof
                   ` (2 preceding siblings ...)
  2013-03-21  5:41 ` Bart Schaefer
@ 2013-03-21  8:17 ` Axel Beckert
  2013-03-21 12:03 ` Richard Hartmann
  4 siblings, 0 replies; 8+ messages in thread
From: Axel Beckert @ 2013-03-21  8:17 UTC (permalink / raw)
  To: zsh-users

Hi,

On Wed, Mar 20, 2013 at 07:16:39PM +0000, Larry Schrof wrote:
> I have been dying for this for many years.  I have a ton of zsh configs,
> so I like to organize them in ~/.zsh/,

Same here.

> but here's the problem.

I actually don't see it as problem, though. Works fine here with a
minimal implementation. Nevertheless I'd be happy to see this being
part of zsh officially to reduce dot file clutter in my ~/ and to make
the zsh config more VCS-suitable.

> First, I have to create a symlink ~/.zshenv and point it to ~/.zsh/.zshenv

Same here, except that I use ~/.zsh/zshenv and hence have a symlink
.zsh/.zshrc → .zsh/zshrc.

> Then, as the first thing to do in ~/.zsh/.zshenv, I have to do:
>    export ZDOTDIR=${HOME}/.zsh

Dito.

> This is janky and is messier than it needs to be.

IMHO that's a very small "workaround". Could be way messier.

> It would be awesome if something like the following happened. Forgive me
> if the implementation is flawed; just note the spirit of my suggestion.
> 
> - Before zsh begins to process the first user-based config file
>   (I believe ~/.zshenv), look for the existence of ~/.zsh/ (a directory).
> - If this directory does not exist, proceed normally. (Start reading
> ~/.zshenv)
> - If this directory DOES exist:
> ---> Automatically set ZDOTDIR to ${HOME}/.zsh/
> ---> Ignore any ~/.zsh* files (If the user is using ~/.zsh/ it's their job

Why not concatenating them? That's what I'd have expected in a first
run. Then, after some thinking, I see that your suggestion potentially
makes sense, too.

Anyway, +1 for the basic idea.

On Wed, Mar 20, 2013 at 10:41:52PM -0700, Bart Schaefer wrote:
> } First, I have to create a symlink ~/.zshenv and point it to ~/.zsh/.zshenv
> } Then, as the first thing to do in ~/.zsh/.zshenv, I have to do:
> }    export ZDOTDIR=${HOME}/.zsh
> 
> Why not create a ~/.zshenv that does
> 
>     export ZDOTDIR=${HOME}/.zsh
>     source $ZDOTDIR/.zshenv
> 
> and forget about the symlinks?

Because you than have to create that file and store its content
elsewhere. But you need to have that file around anyway for that, so
symlinking seems the easier variant, at least if you have ~/.zsh/
under version control.

> Like TJ, I have a common set of config files stored on the web.  (Not
> in Dropbox, in a source repository from which I check out to ~/.zsh,
> but it's the same idea.)  One of the files in that repository is a
> script called ".installer" which writes something much like the above
> into ~/.zshenv (with a warning if that would clobber an existing file,
> etc.).  I haven't yet needed to, but I've considered having .installer
> also write bash init files that exec zsh if zsh is not in /etc/shells.

I use .$DOTDIR/bin/setup-symlinks.sh for that purpose in a bunch of
gitified dotdirs (including my .xsession), but that's more or less the
same (with the exception that I prefer symlinks, of course).

> So on any new host, I just check out the .zsh directory, run .installer,
> resolve a conflict if it reports one, and I'm done.

git clone … + .$DOTDIR/bin/setup-symlinks.sh

(Plan is to use mr in the future to clone all relevant dot dirs at
once the way RichiH does..)

On Wed, Mar 20, 2013 at 04:55:09PM -0400, Paul Hoffman wrote:
> Interesting, but some people (well, *I*) have already organized their 
> ~/.zsh/* differently and this change would break things.

Well, yeah, me, too, because I use ~/.zsh/zshenv and ~/.zsh/zshrc
because I dislike dot files inside dot dirs. But then again, I'd still
happy if that would become an official zsh feature and I'd change my
setup for that.

> I hope it isn't -- IMNSHO janky is better than something that might 
> break things and that would complicate the already complicated startup 
> process (and add to its long and complicated documentation).

I think it's worth it. And automatically setting $ZDOTDIR isn't very
complicated, neither to implement nor to document. The only more
complicated thing would be that, if $ZDOTDIR is set, it would look for
$ZDOTDIR/zshenv and $ZDOTDIR/zshrc, too (or only, see below).

On Wed, Mar 20, 2013 at 08:54:22PM +0100, Moritz Bunkus wrote:
> I'd love to have this, but two things that could be made even better
> in my opinion:
> 
> 1. Check $XDG_CONFIG_HOME/zsh as well as ~/.zsh. The former is from
> the XDG Base Directory Specification[1] which I'd love to see zsh
> follow. $XDG_CONFIG_HOME defaults to ~/.config if unset.

Good idea! +1

> 2. If one of those directories exists then look for $that_dir/zshenv
> and not $that_dir/.zshenv. Hiding the files only makes sense for
> $HOME, not for a sub-directory. Same should be true for
> $that_dir/zshrc and the other files.

Yeah, that's my preference, too.

> So my proposal would be:
> 
> - Look for an existing directory $XDG_CONFIG_HOME/zsh (if
> $XDG_CONFIG_HOME is unset assume default $HOME/.config) or $HOME/.zsh
> - If that directory exists set ZDOTDIR to it and read configuration
> files from that directory. The files are not prefixed with .
> - If that directory does not exist then proceed as before: read
> configuration files from $HOME, the files are prefixed with .

+1 for having it work that way.

		Kind regards, Axel
-- 
/~\  Plain Text Ribbon Campaign                   | Axel Beckert
\ /  Say No to HTML in E-Mail and News            | abe@deuxchevaux.org  (Mail)
 X   See http://www.asciiribbon.org/              | abe@noone.org (Mail+Jabber)
/ \  I love long mails: http://email.is-not-s.ms/ | http://noone.org/abe/ (Web)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Please implement auto-handling of ${HOME}/.zsh/
  2013-03-20 19:16 Please implement auto-handling of ${HOME}/.zsh/ Larry Schrof
                   ` (3 preceding siblings ...)
  2013-03-21  8:17 ` Axel Beckert
@ 2013-03-21 12:03 ` Richard Hartmann
  4 siblings, 0 replies; 8+ messages in thread
From: Richard Hartmann @ 2013-03-21 12:03 UTC (permalink / raw)
  To: Larry Schrof; +Cc: zsh-users

On Wed, Mar 20, 2013 at 8:16 PM, Larry Schrof <larrys@fb.com> wrote:

> ---> Ignore any ~/.zsh* files (If the user is using ~/.zsh/ it's their job
> to
>      understand that ~/.zsh* files won't be read.)

Where is this behaviour specified and documented?

How do you intend to deal with an unknown number of, possibly
automated, systems breaking after an upgrade?

What's the benefit of linking into ~/.zsh/ instead of sourcing it from
~/.zshenv/ ?


-- 
Richard


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Please implement auto-handling of ${HOME}/.zsh/
  2013-03-21  5:41 ` Bart Schaefer
@ 2013-03-21 12:05   ` Richard Hartmann
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Hartmann @ 2013-03-21 12:05 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

On Thu, Mar 21, 2013 at 6:41 AM, Bart Schaefer
<schaefer@brasslantern.com> wrote:

> Like TJ, I have a common set of config files stored on the web.  (Not
> in Dropbox, in a source repository from which I check out to ~/.zsh,
> but it's the same idea.)  One of the files in that repository is a
> script called ".installer" which writes something much like the above
> into ~/.zshenv (with a warning if that would clobber an existing file,
> etc.).  I haven't yet needed to, but I've considered having .installer
> also write bash init files that exec zsh if zsh is not in /etc/shells.

This is a tad off topic, but vcsh[1] does exist and deals with this
issue nicely without the need for installer scripts.

Your zsh, and other, configs is then a simple `vcsh clone` away which
is basically a wrapper around git, forcing it to put several working
copies into $HOME along each other.


Richard

[1] https://github.com/RichiH/vcsh


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-03-21 12:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-20 19:16 Please implement auto-handling of ${HOME}/.zsh/ Larry Schrof
2013-03-20 19:54 ` Moritz Bunkus
2013-03-20 20:55 ` Paul Hoffman
2013-03-20 21:25   ` TJ Luoma
2013-03-21  5:41 ` Bart Schaefer
2013-03-21 12:05   ` Richard Hartmann
2013-03-21  8:17 ` Axel Beckert
2013-03-21 12:03 ` Richard Hartmann

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).