def get_environment():
    """Get the environment in which halo is running

    Returns
    -------
    str
        Environment name
    """
    try:
        from IPython import get_ipython
    except ImportError:
        return 'terminal'

    try:
        shell = get_ipython().__class__.__name__

        if shell == 'ZMQInteractiveShell':  # Jupyter notebook or qtconsole
            return 'jupyter'
        elif shell == 'TerminalInteractiveShell':  # Terminal running IPython
            return 'ipython'
        else:
            return 'terminal'  # Other type (?)

    except NameError:
        return 'terminal'