def METHOD_NAME(env, shell, prompt=None):
    # Construct the commands to run
    cmds = ""
    if shell == "csh":
        # TODO: figure out how to make color work for csh
        cmds += "setenv SPACK_ENV %s;\n" % env.path
        cmds += 'alias despacktivate "spack env deactivate";\n'
        if prompt:
            cmds += "if (! $?SPACK_OLD_PROMPT ) "
            cmds += 'setenv SPACK_OLD_PROMPT "${prompt}";\n'
            cmds += 'set prompt="%s ${prompt}";\n' % prompt
    elif shell == "fish":
        if "color" in os.getenv("TERM", "") and prompt:
            prompt = colorize("@G{%s} " % prompt, color=True)
        cmds += "set -gx SPACK_ENV %s;\n" % env.path
        cmds += "function despacktivate;\n"
        cmds += "   spack env deactivate;\n"
        cmds += "end;\n"
        #
        # NOTE: We're not changing the fish_prompt function (which is fish's
        # solution to the PS1 variable) here. This is a bit fiddly, and easy to
        # screw up => spend time reasearching a solution. Feedback welcome.
        #
    elif shell == "bat":
        # TODO: Color
        cmds += 'set "SPACK_ENV=%s"\n' % env.path
        # TODO: despacktivate
        # TODO: prompt
    elif shell == "pwsh":
        cmds += "$Env:SPACK_ENV='%s'\n" % env.path
    else:
        if "color" in os.getenv("TERM", "") and prompt:
            prompt = colorize("@G{%s}" % prompt, color=True, enclose=True)
        cmds += "export SPACK_ENV=%s;\n" % env.path
        cmds += "alias despacktivate='spack env deactivate';\n"
        if prompt:
            cmds += "if [ -z ${SPACK_OLD_PS1+x} ]; then\n"
            cmds += "    if [ -z ${PS1+x} ]; then\n"
            cmds += "        PS1='$$$$';\n"
            cmds += "    fi;\n"
            cmds += '    export SPACK_OLD_PS1="${PS1}";\n'
            cmds += "fi;\n"
            cmds += 'export PS1="%s ${PS1}";\n' % prompt
    return cmds