Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: example startup file



Bart Schaefer wrote:
> 
> However, if you know (as in the example) that fpath is non-empty, you can
> just do one loop like this:
> 
>     for func in $^fpath/*(N-.x:t); autoload $func

That looks good. I've switched it to that with a comment about the
non-empty issue.

> I use:
> 
>     typeset -U path cdpath fpath manpath

So do I and I'll add it to the example. I was just suprised that
compinit added duplicates.

> That never was csh-compatible.  This is:
> 
>     setenv() { typeset -x "${1}${1:+=}${(@)argv[2,$#]}" }

ok. I'll put it in even though it ceases to be a nice simple example.
I'd like yp and yu from Functions/Example in here instead because
they are simple and easy to understand.

Has anyone got a useful and very short user-defined zle widget we could
add?

> > +freload() { while (( $# )); do; unfunction $1; autoload -U $1; shift; done }
> 
> I'd throw in a check that the argument actually is a function before calling
> unfunction on it.

That would either need zmodloading zsh/parameter, a redirected which or
redirected stderr from unfunction. I think I'd prefer to keep it simple,
I'm even tempted to remove the while loop. If you prefer, either change
it or remove the function, I'm not really bothered but I've left it as
above for now.

Andrej wrote:

> >  manpath=($X11HOME/man /usr/man /usr/lang/man /usr/local/man)

> That's bad and does not belong to generic .zshrc. It blindly overwrites

I thought it was meant to be an example really as opposed to being
generic but judging from the comment at the top, maybe I'm wrong. That
isn't a line I added it was there before and I think it serves a useful
purpose in showing that you can setup your manpath there. I also think
it wouldn't be a bad thing if the examples break lots of things to
force them to be read before being used.

If you really want to remove those lines, I don't mind but following
the same principle much of zlogin and all of zshenv would also have to
go too.

Anyway, I'm going to be away for a few days so I'll commit this now
before I forget. Patch is to be applied on top of the previous. I also
added a few zmodload -a commands.

> zefram wrote:
> >       directory stack access with =num
> It was changed to ~num some time ago.

Ok, thanks, I've also updated that line before it is forgotten.

Oliver

Index: Etc/FEATURES
===================================================================
RCS file: /cvsroot/zsh/zsh/Etc/FEATURES,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 FEATURES
--- Etc/FEATURES        1999/04/15 18:05:37     1.1.1.1
+++ Etc/FEATURES        2001/05/09 16:41:27
@@ -5,13 +5,13 @@
 very close to ksh/sh grammar, with csh additions
 most features of ksh, bash, and tcsh
 can emulate ksh or POSIX sh
-81 builtins, 102 options, 162 key bindings
+100 builtins, 145 options, 166 key bindings
 short for loops, ex: for i (*.c) echo $i
 select
 shell functions
 conditional expressions (test builtin, [ ... ], and ksh-style [[ ... ]])
 global aliases (may be expanded anywhere on the line)
-directory stack access with =num
+directory stack access with ~num
 process substitution (vi =(cmd) edits the output of cmd)
 generalized pipes (ls foo >>(cmd1) 2>>(cmd2) pipes stdout to cmd1
   and stderr to cmd2)
--- zshrc       Tue May  8 18:42:07 2001
+++ zshrc       Wed May  9 17:30:10 2001
@@ -41,20 +41,20 @@
 alias lsa='ls -ld .*'
 
 # Shell functions
-setenv() { export $1=$2 }  # csh compatibility
+setenv() { typeset -x "${1}${1:+=}${(@)argv[2,$#]}" }  # csh compatibility
 freload() { while (( $# )); do; unfunction $1; autoload -U $1; shift; done }
 
 # Where to look for autoloaded function definitions
 fpath=($fpath ~/.zfunc)
 
-# Autoload all shell functions from all directories
-# in $fpath that have the executable bit on
-# (the executable bit is not necessary, but gives
-# you an easy way to stop the autoloading of a
-# particular shell function).
-#for dirname in $fpath; do
-#  autoload $dirname/*(.x:t)
-#done
+# Autoload all shell functions from all directories in $fpath (following
+# symlinks) that have the executable bit on (the executable bit is not
+# necessary, but gives you an easy way to stop the autoloading of a
+# particular shell function). $fpath should not be empty for this to work.
+for func in $^fpath/*(N-.x:t); autoload $func
+
+# automatically remove duplicates from these arrays
+typeset -U path cdpath fpath manpath
 
 # Global aliases -- These do not have to be
 # at the beginning of the command line.
@@ -93,6 +93,12 @@
 setopt   autoresume histignoredups pushdsilent noclobber
 setopt   autopushd pushdminus extendedglob rcquotes mailwarning
 unsetopt bgnice autoparamslash
+
+# Autoload zsh modules when they are referenced
+zmodload -a zsh/stat stat
+zmodload -a zsh/zpty zpty
+zmodload -a zsh/zprof zprof
+zmodload -ap zsh/mapfile mapfile
 
 # Some nice key bindings
 #bindkey '^X^Z' universal-argument ' ' magic-space



Messages sorted by: Reverse Date, Date, Thread, Author