Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
managing PATH, MANPATH, LD_LIBRARY_PATH, etc.
- X-seq: zsh-workers 34427
- From: Dave Yost <Dave@xxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: managing PATH, MANPATH, LD_LIBRARY_PATH, etc.
- Date: Wed, 28 Jan 2015 10:06:12 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:content-type:subject:date:message-id:to:mime-version :sendlaterdate; bh=IcL3MU6i0olVYmJC5hvnVWIavAQdp/7Qlo/lV7Z4O0Y=; b=JF8tWVWR9AtSWiiBvBQPZs+Ef+5kW2cZ+VCQgnvvdXRiqXwFEYB9Ux+pDMcYfY1gqG Lt0Tmvgu9/3yLi6JER2WobqY5t4VfuOKsvbNJBrk0F0R05jrRiZ5kwTu5qsx+C/Ozsmj C2k/fKYtuITIwvQ6bcO8vczo+tvRe08odwNJ/lW1ZFiBKeQE9tXy/nObxid7iTOyGqRc lUZDIrbOVsy5nkq5B953RwWEGU2CVtoniT9mozAGqfWSq937blwP4PAWYB3yRDfnOhT2 79GMBNFxld5AmNouRRri5MEtdJe5wyiMRYt30ugHLY+IIz4F21/vraigT3d1AQLCyCjk vt8Q==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Sender: Dave Yost <daveyostcom@xxxxxxxxx>
- Sendlaterdate: Wed, 28 Jan 2015 10:06:12 -0800
AFAIK we have no choice in zsh but to tediously add things individually by hand to the various path environment variables. The Environment Modules System <https://en.wikipedia.org/wiki/Environment_Modules_(software)> for linux gives higher-level control, but it’s a whole ball of wax of its own. If I do this
module load llvm/3.5.1
then the relevant directories from /usr/local/llvm/3.5.1 will be added to the front of PATH, LD_LIBRARY_PATH, LIBRARY_PATH, and CPATH, or whatever paths have been specified in the “modulefile” for llvm/3.5.1.
A zsh shell function could allow similarly convenient manipulation of paths, without buying into the whole Environment Modules thing.
Imagine a shell function called “paths”. Doing this:
paths set /usr/local /usr /
wants to set PATH to this:
/usr/local/bin
/usr/local/sbin
/usr/bin
/usr/sbin
/bin
/sbin
and does so, except that directories that don’t exist, such as /usr/local/sbin, are not added.
An important convenience of the paths function would be that it also works similarly for MANPATH, LD_LIBRARY_PATH, LIBRARY_PATH, and CPATH.
You can also do these:
paths remove /usr/local/llvm/3.5.1
paths addlast /usr/local/llvm/3.5.1
paths addfirst /usr/local/llvm/3.5.1
with the obvious effects (including removing from paths before adding at the desired position), and
paths list
would output like this
/usr/local/llvm/3.5.1
/usr/local
/usr
/
One notable exception is adding “.” to PATH. The paths function could help here, too:
paths --no-subdirs --only=PATH addlast .
On my Mac, here’s what’s in /etc/paths
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
But what about MANPATH, LD_LIBRARY_PATH, LIBRARY_PATH, and CPATH? The paths function could be smart enough to eat /etc/paths as input, stripping off the /bin part of each item and then doing:
paths /usr/local /usr /
That way /etc/paths wouldn’t have to change. Better would be a new overriding file, called /etc/prefixes or something, that just has a list of arguments to the paths function:
/usr/local
/usr
/
Comments? Volunteers? Is this already out there somewhere?
I do not plan to implement this anytime soon.
Dave
Messages sorted by:
Reverse Date,
Date,
Thread,
Author