home/.zsh/themes/spaceship-prompt/sections/conda.zsh

43 lines
1.4 KiB
Bash

#
# Conda
#
# Package, dependency and environment management for any language
# Link: https://conda.io/
# ------------------------------------------------------------------------------
# Configuration
# ------------------------------------------------------------------------------
SPACESHIP_CONDA_SHOW="${SPACESHIP_CONDA_SHOW=true}"
SPACESHIP_CONDA_ASYNC="${SPACESHIP_CONDA_ASYNC=false}"
SPACESHIP_CONDA_PREFIX="${SPACESHIP_CONDA_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}"
SPACESHIP_CONDA_SUFFIX="${SPACESHIP_CONDA_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}"
SPACESHIP_CONDA_SYMBOL="${SPACESHIP_CONDA_SYMBOL="🅒 "}"
SPACESHIP_CONDA_COLOR="${SPACESHIP_CONDA_COLOR="blue"}"
SPACESHIP_CONDA_VERBOSE="${SPACESHIP_CONDA_VERBOSE=true}"
# ------------------------------------------------------------------------------
# Section
# ------------------------------------------------------------------------------
# Show current conda virtual environment
spaceship_conda() {
[[ $SPACESHIP_CONDA_SHOW == false ]] && return
# Check if running via conda virtualenv
spaceship::exists conda && [ -n "$CONDA_DEFAULT_ENV" ] || return
local conda_env=${CONDA_DEFAULT_ENV}
if [[ $SPACESHIP_CONDA_VERBOSE == false ]]; then
conda_env=${CONDA_DEFAULT_ENV:t}
fi
spaceship::section \
--color "$SPACESHIP_CONDA_COLOR" \
--prefix "$SPACESHIP_CONDA_PREFIX" \
--suffix "$SPACESHIP_CONDA_SUFFIX" \
--symbol "$SPACESHIP_CONDA_SYMBOL" \
"$conda_env"
}