All pastes #269486 Raw Edit

Untitled

public text v1 · immutable
·published 2006-12-06 16:53 UTC
rendered paste body
cd ()
{
    if [ -d "$@" ]; then
        command cd "$@";
        if [ -e "bin/activate" ]; then
            if [ -n "${ACTIVATED}" ]; then
                if [ "${ACTIVATED}" != "${PWD}" ]; then
                    if [[ -n "`type -t deactivate`" ]]; then
                        deactivate;
                    fi;
                    unset ACTIVATED;
                else
                    return;
                fi;
            fi;
            source "bin/activate";
            export ACTIVATED="$PWD";
        fi;
        if [ -n "${ACTIVATED}" ]; then
            if (( ! `expr match "${PWD}" "${ACTIVATED}"` )); then
                if [[ -n "`type -t deactivate`" ]]; then
                    deactivate;
                fi;
                unset ACTIVATED;
            fi;
        fi;
    else
        if [ -e "$@" ]; then
            command cd `dirname "$@"`;
        else
            if [[ "$@" == "^" && -n "${ACTIVATED}" ]]; then
                command cd "${ACTIVATED}";
                return;
            fi;
            command cd "$@";
        fi;
    fi
}