Skip to content

Commit

Permalink
Adding simple conda env segment (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
brujoand authored Aug 8, 2020
1 parent 22d77a1 commit f97a7ef
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config/colors.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
7 changes: 7 additions & 0 deletions src/segments/conda.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /usr/bin/env bash

segments::conda() {
if [[ -n "$CONDA_DEFAULT_ENV" ]]; then
print_themed_segment 'normal' "$CONDA_DEFAULT_ENV"
fi
}
18 changes: 18 additions & 0 deletions test/segments/conda.bats
Original file line number Diff line number Diff line change
@@ -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" ''
}

0 comments on commit f97a7ef

Please sign in to comment.