#!/usr/bin/env bash

nv_cmd_default() {
    local env_name=`nv current`
    local env_name_full=$(nv_get_env_full_path $env_name)

    if [ "$env_name" = "" ]; then
        echo "Nothing to deactivate."
    elif [ "$NV_IN_NEW_SHELL" = "yes" ]; then
        exit
    else
        for plug in $(find $env_name_full/bin/ -type f -iname "deactivate-*" )
        do
            . $plug
        done

        export PATH=$NV_OLD_PATH
        unset NV_OLD_PATH
        unset NV_USED_ENV

        if [ "$NV_OLD_PS1" != "" ]; then
            export PS1="$NV_OLD_PS1"
            unset NV_OLD_PS1
        fi

        echo "Environment `nv_bold $env_name` was deactivated."
    fi
}

nv_cmd_desc() {
    echo "Deactivate environment (alias: off)"
}

nv_cmd_help() {
    nv_show_usage
    nv_show_desc "$(nv_cmd_desc)"
}

# /* vim: set filetype=sh : */
