export PYTHONPATH=$PYTHONPATH…

Do you find yourself doing this all the time?


$ export PYTHONPATH=$PYTHONPATH:/path/to/some/package

If so, then save yourself some keystrokes! Just put the following into your .bash_profile:


function pypath {
if [ "$1" = "" ]; then
export PYTHONPATH=$PYTHONPATH:`pwd -P`
else
export PYTHONPATH=$PYTHONPATH:`pushd -n $1; pwd -P; popd -n`
fi
echo $PYTHONPATH
}

Now just type “pypath” inside any directory, and it gets appended to your PYTHONPATH. If you type “pypath /some/other/dir”, then that directory will get appended to your PYTHONPATH. Easy!

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: