Files
python-build/pythonbrew/scripts/bashrc
T

80 lines
1.5 KiB
Bash

PYTHONBREW_ROOT="@ROOT@"
PYTHONBREW_ETC="$PYTHONBREW_ROOT/etc"
__pythonbrew_set_default()
{
PATH_PYTHONBREW="$PYTHONBREW_ROOT/bin"
}
__pythonbrew_set_path()
{
PATH_WITHOUT_PYTHONBREW=$(printf $PATH | awk -v RS=: -v ORS=: "/${PYTHONBREW_ROOT//\//\/}/ {next} {print}" | sed -e 's#:$##')
export PATH=$PATH_PYTHONBREW:$PATH_WITHOUT_PYTHONBREW
}
__pythonbrew_set_temp_path()
{
if [[ -s "$PYTHONBREW_ETC/temp" ]] ; then
source "$PYTHONBREW_ETC/temp"
else
__pythonbrew_set_default
fi
__pythonbrew_set_path
}
__pythonbrew_set_current_path()
{
if [[ -s "$PYTHONBREW_ETC/current" ]] ; then
source "$PYTHONBREW_ETC/current"
else
__pythonbrew_set_default
fi
__pythonbrew_set_path
}
__pythonbrew_reload()
{
if [[ -s "$PYTHONBREW_ETC/bashrc" ]] ; then
source "$PYTHONBREW_ETC/bashrc"
fi
}
__pythonbrew_use()
{
command pythonbrew "$@"
__pythonbrew_set_temp_path
}
__pythonbrew_switch()
{
command pythonbrew "$@"
__pythonbrew_set_current_path
}
__pythonbrew_off()
{
command pythonbrew "$@"
__pythonbrew_set_current_path
}
__pythonbrew_update()
{
command pythonbrew "$@"
__pythonbrew_reload
}
pythonbrew()
{
case $1 in
use) __pythonbrew_use "$@";;
switch) __pythonbrew_switch "$@" ;;
off) __pythonbrew_off "$@" ;;
update) __pythonbrew_update "$@" ;;
*) command pythonbrew "$@" ;;
esac
builtin hash -r
}
# main
__pythonbrew_set_current_path