Sunday, March 15, 2015

osx snow leopard - OS X 10.6: How do I temporarily change $PATH for ZSH?

I'd like to create a script that sets the $PATH to a set of directories chosen by me (thus ignoring the predefined paths, such as /usr/bin, /usr/local/bin and so on...) followed by launching ZSH.


This does the trick for BASH:


#!/bin/sh
PATH="/Users/Thoht/Sites/djangostack/apps/django/bin"
# exec /bin/bash --noprofile --norc

I get a new BASH session with the path being only what is defined above that I cancel with Ctrl-D when done. I'd like to recreate this script for ZSH but have had no success. I tried this:


#!/bin/sh
PATH="/Users/Thoht/Sites/djangostack/apps/django/bin"
# exec /bin/zsh -f

However the predefined paths such as /usr/bin and all that jazz remains which makes the script useless.


Preferably I'd like to have my .zshrc loaded and merely the path temporarily changed.


EDIT
I forgot to add one thing - /etc/zshenv that is read first of all (or so I believe) contains this script:


# system-wide environment settings for zsh(1)
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi

EDIT 2
The first edit is irrelevant as I don't want to use the -f option. A more precise question is:


"How do I add paths to precede the .zshrc paths to $PATH in a shell script followed by launching ZSH normally (as in with it reading .zshrc)?"

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...