zsh-users
 help / color / mirror / code / Atom feed
* source ~/dir/*.zsh
@ 2012-06-22  0:01 TJ Luoma
  2012-06-22  8:12 ` Frank Terbeck
  2012-06-22  8:18 ` René Neumann
  0 siblings, 2 replies; 3+ messages in thread
From: TJ Luoma @ 2012-06-22  0:01 UTC (permalink / raw)
  To: Zsh-Users List

I have split my .zshenv into a bunch of different files which all end
with different suffixes. For example, functions are called "foo.f.zsh"
or "bar.f.zsh"

My idea was to put them all into a special directory and then source
them like so in ~/.zshenv

      source ~/dir/*.f.zsh

But that doesn't seem to work.

I'm not getting any errors, it just doesn't seem to actually do anything.

So I need some sort of setopt or other setting to make this work?

TjL


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

* Re: source ~/dir/*.zsh
  2012-06-22  0:01 source ~/dir/*.zsh TJ Luoma
@ 2012-06-22  8:12 ` Frank Terbeck
  2012-06-22  8:18 ` René Neumann
  1 sibling, 0 replies; 3+ messages in thread
From: Frank Terbeck @ 2012-06-22  8:12 UTC (permalink / raw)
  To: Zsh-Users List

TJ Luoma wrote:
> My idea was to put them all into a special directory and then source
> them like so in ~/.zshenv
>
>       source ~/dir/*.f.zsh
>
> But that doesn't seem to work.

You'll have to use a for loop, because this is not how `source' works
(see below).

> I'm not getting any errors, it just doesn't seem to actually do anything.

It should source *one* file:

  source file [ arg ... ]
       Same  as  `.', except  that  the  current directory  is
       always searched  and is  always searched  first, before
       directories in $path.

  . file [ arg ... ]
       Read commands from file and execute them in the current
       shell environment.
     [...]
       If  any  arguments  arg  are  given,  they  become  the
       positional  parameters; the  old positional  parameters
       are restored when the file  is done executing.
     [...]


So, if you'd add a line

  printf '%s\n' "$@"

to the top of the alphabetically first file in the directory, it should
print the names of the other files because `source' will put them into
the positional parameters during the execution of the first file.

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


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

* Re: source ~/dir/*.zsh
  2012-06-22  0:01 source ~/dir/*.zsh TJ Luoma
  2012-06-22  8:12 ` Frank Terbeck
@ 2012-06-22  8:18 ` René Neumann
  1 sibling, 0 replies; 3+ messages in thread
From: René Neumann @ 2012-06-22  8:18 UTC (permalink / raw)
  To: TJ Luoma; +Cc: Zsh-Users List

Am 22.06.2012 02:01, schrieb TJ Luoma:
> I have split my .zshenv into a bunch of different files which all end
> with different suffixes. For example, functions are called "foo.f.zsh"
> or "bar.f.zsh"
>
> My idea was to put them all into a special directory and then source
> them like so in ~/.zshenv
> 
>       source ~/dir/*.f.zsh

A file bla.f.zsh contains exactly the function
bla ()
{
   # bla_content
}
?

If so: just put all functions in a single dir (say ~/.zsh/functions/).
And there into a file 'bla' you put just "# bla_content", i.e. you omit
the function definition.

Then via

typeset -U path fpath

fpath=(~/.zsh/functions $fpath)

# load all things in there
autoload ${fpath[1]}/*(:t)

you have all you wanted :)

Sorry, if this description is confusing -- see here [1] for the official
documentation on this feature.

- René

[1] http://zsh.sourceforge.net/Doc/Release/Functions.html


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

end of thread, other threads:[~2012-06-22  8:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-22  0:01 source ~/dir/*.zsh TJ Luoma
2012-06-22  8:12 ` Frank Terbeck
2012-06-22  8:18 ` René Neumann

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