Last active
August 29, 2015 14:02
-
-
Save ynsta/1b463ece9fd698ff9823 to your computer and use it in GitHub Desktop.
bashrc: absdir and setenv functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function absdir() { | |
for i; do | |
python -c "import os; print os.path.abspath('$i')" | |
done | |
} | |
function setenv() { | |
for env ; do | |
if [ -d "${env}" ]; then | |
env=$(absdir "$env") | |
for i in \ | |
PATH:bin \ | |
MANPATH:man \ | |
INFOPATH:info \ | |
LIBRARY_PATH:lib \ | |
LD_LIBRARY_PATH:lib \ | |
PYTHONPATH:lib/python2.7/site-packages | |
do | |
var=${i%:*} | |
dir="${env}/${i#*:}" | |
[ -d "${dir}" ] && eval export $var=\"${dir}:\${${var}}\" | |
done | |
fi | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment