zsh-users
 help / color / mirror / code / Atom feed
* zsh startup files
@ 2006-03-14 17:38 zzapper
  2006-03-14 18:16 ` [zsh] " Francisco Borges
  2006-03-14 19:50 ` Wayne Davison
  0 siblings, 2 replies; 7+ messages in thread
From: zzapper @ 2006-03-14 17:38 UTC (permalink / raw)
  To: zsh-users

Hi,
At the risk of exposing my ignorance, I think there's a concept of multi-
level startup files of type .z* such that ideally you don't have rerun all 
your setup every time you run say a small 3 line script.

I've got everything in my ~/.zshenv can I do better?


-- 
http://successtheory.com/ 100 FREE Success and Self-Improvement Tips


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

* Re: [zsh]  zsh startup files
  2006-03-14 17:38 zsh startup files zzapper
@ 2006-03-14 18:16 ` Francisco Borges
  2006-03-14 19:47   ` Dan Nelson
  2006-03-14 19:50 ` Wayne Davison
  1 sibling, 1 reply; 7+ messages in thread
From: Francisco Borges @ 2006-03-14 18:16 UTC (permalink / raw)
  To: zsh-users

» On Tue, Mar 14, 2006 at 05:38PM +0000, zzapper wrote:

> At the risk of exposing my ignorance, I think there's a concept of multi-
> level startup files of type .z* such that ideally you don't have rerun all
> your setup every time you run say a small 3 line script.
>
> I've got everything in my ~/.zshenv can I do better?

There is also .zlogin and .zshrc.

You should move all the "interactive" part of your .zshenv into .zshrc,
i.e. anything that you won't need to run your scripts. My zshenv is
mostly about setting $PATH and other non interactive env. variables.

While I'm sure there is good use for dot-login files, I never discovered
which would be these...

Oh, yes... there is .zlogout as well, but I haven't found a good excuse
to create one.

Cheers,
Francisco


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

* Re: [zsh]  zsh startup files
  2006-03-14 18:16 ` [zsh] " Francisco Borges
@ 2006-03-14 19:47   ` Dan Nelson
  0 siblings, 0 replies; 7+ messages in thread
From: Dan Nelson @ 2006-03-14 19:47 UTC (permalink / raw)
  To: zsh-users

In the last episode (Mar 14), Francisco Borges said:
> On Tue, Mar 14, 2006 at 05:38PM +0000, zzapper wrote:
> > At the risk of exposing my ignorance, I think there's a concept of
> > multi-level startup files of type .z* such that ideally you don't
> > have rerun all your setup every time you run say a small 3 line
> > script.
> >
> > I've got everything in my ~/.zshenv can I do better?
> 
> There is also .zlogin and .zshrc.
> 
> You should move all the "interactive" part of your .zshenv into
> .zshrc, i.e. anything that you won't need to run your scripts. My
> zshenv is mostly about setting $PATH and other non interactive env.
> variables.

I alwys put one of the following comments at the top of my startup
scripts so I remember what goes where, and in what order:

# .zprofile -- loaded if login shell        .zshenv .zprofile .zshrc .zlogin
# .zshenv -- always loaded                  .zshenv .zprofile .zshrc .zlogin
# .zshrc -- loaded if interactive shell     .zshenv .zprofile .zshrc .zlogin

The comments at at the top of the example scripts also have good
descriptions of what should go into what script.
 
-- 
	Dan Nelson
	dnelson@allantgroup.com


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

* Re: zsh startup files
  2006-03-14 17:38 zsh startup files zzapper
  2006-03-14 18:16 ` [zsh] " Francisco Borges
@ 2006-03-14 19:50 ` Wayne Davison
  2006-03-15  2:43   ` Bart Schaefer
  1 sibling, 1 reply; 7+ messages in thread
From: Wayne Davison @ 2006-03-14 19:50 UTC (permalink / raw)
  To: zzapper; +Cc: zsh-users

On Tue, Mar 14, 2006 at 05:38:37PM +0000, zzapper wrote:
> I've got everything in my ~/.zshenv can I do better?

Doing this means that you can't override anything that is set in the
.zshenv file and have it affect another zsh script or indeed any command
that was spawned using $SHELL (which affects a lot of commands that run
other commands, such as gdb).  Because of this, I moved all my non-
interactive variable settings into ~/.zprofile (my interactive settings
have always been in ~/.zshrc) and I reduced the ~/.zshenv file to these
3 lines:

if [[ $SHLVL == 1 && ! -o LOGIN ]]; then
    source ~/.zprofile
fi

The overall idea is that I want these variables to be set once, and then
inherited from then on.  The reason for the above 3 lines is that some X
windows environments don't start a login shell for an xterm, so this
code makes sure that a top-level shell that is not a login shell still
includes the zprofile information that would have been included
automatically by a login shell.  If you have other settings that you
always want to be forced into a certain state regardless of the parent
environment, you could set them there as well.

..wayne..


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

* Re: zsh startup files
  2006-03-14 19:50 ` Wayne Davison
@ 2006-03-15  2:43   ` Bart Schaefer
  2006-03-15 18:22     ` Phil Pennock
  2006-03-16 19:29     ` Dominic Mitchell
  0 siblings, 2 replies; 7+ messages in thread
From: Bart Schaefer @ 2006-03-15  2:43 UTC (permalink / raw)
  To: zsh-users

On Mar 14, 11:50am, Wayne Davison wrote:
}
} I moved all my non- interactive variable settings into ~/.zprofile (my
} interactive settings have always been in ~/.zshrc) and I reduced the
} ~/.zshenv file to these 3 lines:

My .zshenv is only two lines:

export ZDOTDIR=$HOME/.zsh
. $ZDOTDIR/.zshenv

OK, so that's cheating.

$ZDOTDIR/.zshenv has 7 lines of variable assignments so that all the
variables that were ever set by zsh (back as far as about version 2.1)
have the values they would have in whatever version that was, so that
my 15 years (gah) of accumulated zsh configuration doesn't have to be
rewritten, only added-to.  (If I haven't got around to forward-porting
it by now, it's never going to happen.)  Then it sets $path, $fpath and
a few other environment variables read from a second file that I edit
for each specific machine, so that I can just copy around all the rest
of the configuration.  (I keep it in cvs and just "cvs co" it when I
get an account in a new place.)

The only job of $ZDOTDIR/.zprofile is to search $path to be sure that,
if more than one version of zsh is found in $path, everything refers to
the most recent possible version.  If necessary it execs that zsh.

$ZDOTDIR/.zshrc sets up options, prompt strings, aliases, bindkeys,
completion, xterm title, and history.

$ZDOTDIR/.zlogin sets up the tty driver, ssh agent if it isn't yet, and
anything interactive left over from .zshrc, like $mailpath.

Back when I was using timeshared computers a lot, I had a .zlogout that
cleared the screen and any scrollback buffers, but I removed that a long
time ago; I haven't thought of any other good use for it.


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

* Re: zsh startup files
  2006-03-15  2:43   ` Bart Schaefer
@ 2006-03-15 18:22     ` Phil Pennock
  2006-03-16 19:29     ` Dominic Mitchell
  1 sibling, 0 replies; 7+ messages in thread
From: Phil Pennock @ 2006-03-15 18:22 UTC (permalink / raw)
  To: zsh-users

On 2006-03-14 at 18:43 -0800, Bart Schaefer wrote:
> Back when I was using timeshared computers a lot, I had a .zlogout that
> cleared the screen and any scrollback buffers, but I removed that a long
> time ago; I haven't thought of any other good use for it.

Machine-rooms in third-party hosting facilities, when you've been in
logged in on a real virtual console.

I should probably get around to making it more portable to different TTY
naming schemes, but the very simple method works for me:
[[ $SHLVL -eq 1 && $TTY == /dev/ttyv* ]] && clear


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

* Re: zsh startup files
  2006-03-15  2:43   ` Bart Schaefer
  2006-03-15 18:22     ` Phil Pennock
@ 2006-03-16 19:29     ` Dominic Mitchell
  1 sibling, 0 replies; 7+ messages in thread
From: Dominic Mitchell @ 2006-03-16 19:29 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

Bart Schaefer wrote:
> Back when I was using timeshared computers a lot, I had a .zlogout that
> cleared the screen and any scrollback buffers, but I removed that a long
> time ago; I haven't thought of any other good use for it.

I've found it necessary to use .zlogout to kill my ssh-agent.  This was 
under cygwin though.  :-)

-Dom


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

end of thread, other threads:[~2006-03-16 19:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-14 17:38 zsh startup files zzapper
2006-03-14 18:16 ` [zsh] " Francisco Borges
2006-03-14 19:47   ` Dan Nelson
2006-03-14 19:50 ` Wayne Davison
2006-03-15  2:43   ` Bart Schaefer
2006-03-15 18:22     ` Phil Pennock
2006-03-16 19:29     ` Dominic Mitchell

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).