diff --git a/config/colors.conf b/config/colors.conf index 14b69b9..90fd2e4 100644 --- a/config/colors.conf +++ b/config/colors.conf @@ -35,6 +35,9 @@ SEGMENTS_RETURN_CODE_COLOR_SECONDARY=${SEGMENTS_RETURN_CODE_COLOR_SECONDARY:-$co SEGMENTS_TIMESTAMP_COLOR_PRIMARY=${SEGMENTS_TIMESTAMP_COLOR_PRIMARY:-$color2} SEGMENTS_TIMESTAMP_COLOR_SECONDARY=${SEGMENTS_TIMESTAMP_COLOR_SECONDARY:-$color5} +SEGMENTS_CONDA_COLOR_PRIMARY=${SEGMENTS_CONDA_COLOR_PRIMARY:-$color8} +SEGMENTS_CONDA_COLOR_SECONDARY=${SEGMENTS_CONDA_COLOR_SECONDARY:-$color9} + SEGMENTS_AWS_COLOR_PRIMARY=${SEGMENTS_AWS_COLOR_PRIMARY:-$color8} SEGMENTS_AWS_COLOR_SECONDARY=${SEGMENTS_AWS_COLOR_SECONDARY:-$color9} diff --git a/src/segments/conda.bash b/src/segments/conda.bash new file mode 100644 index 0000000..6a9e076 --- /dev/null +++ b/src/segments/conda.bash @@ -0,0 +1,7 @@ +#! /usr/bin/env bash + +segments::conda() { + if [[ -n "$CONDA_DEFAULT_ENV" ]]; then + print_themed_segment 'normal' "$CONDA_DEFAULT_ENV" + fi +} diff --git a/test/segments/conda.bats b/test/segments/conda.bats new file mode 100644 index 0000000..3f67f13 --- /dev/null +++ b/test/segments/conda.bats @@ -0,0 +1,18 @@ +#!/usr/bin/env bats + +load segment_helper + +@test "test that we recognize a Conda profile" { + export CONDA_DEFAULT_ENV='my_env' + mapfile -t result <<< "$(execute_segment)" + assert_equal "${#result[@]}" 2 + assert_equal "${result[0]}" 'normal' + assert_equal "${result[1]}" "$CONDA_DEFAULT_ENV" +} + +@test "test that we do nothing without a Conda profile" { + unset CONDA_DEFAULT_ENV + result="$(execute_segment)" + assert_equal "$result" '' +} +