Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions test/themes/powerline.base.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# shellcheck shell=bats

load "${MAIN_BASH_IT_DIR?}/test/test_helper.bash"

function local_setup_file() {
setup_libs "colors"
load "${BASH_IT?}/themes/powerline/powerline.base.bash"
}

function local_setup() {
LEFT_PROMPT=""
SEGMENTS_AT_LEFT=0

Check warning

Code scanning / shellcheck

SC2034 Warning test

SEGMENTS_AT_LEFT appears unused. Verify use (or export if used externally).
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
LAST_SEGMENT_COLOR=""

Check warning

Code scanning / shellcheck

SC2034 Warning test

LAST_SEGMENT_COLOR appears unused. Verify use (or export if used externally).
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
unset POWERLINE_PROMPT_FOREGROUND_COLOR
}

@test "powerline base: __powerline_left_segment omits fg color code when POWERLINE_PROMPT_FOREGROUND_COLOR is unset" {
__powerline_left_segment "hello|240"
run printf '%s' "${LEFT_PROMPT}"
refute_output --partial "38;5;"
assert_output --partial "48;5;240"
}

@test "powerline base: __powerline_left_segment applies POWERLINE_PROMPT_FOREGROUND_COLOR when set" {
POWERLINE_PROMPT_FOREGROUND_COLOR=15
__powerline_left_segment "hello|240"
run printf '%s' "${LEFT_PROMPT}"
assert_output --partial "38;5;15"
assert_output --partial "48;5;240"
}

@test "powerline base: __powerline_left_segment fg color changes take effect on each segment" {
POWERLINE_PROMPT_FOREGROUND_COLOR=7

Check warning

Code scanning / shellcheck

SC2034 Warning test

POWERLINE_PROMPT_FOREGROUND_COLOR appears unused. Verify use (or export if used externally).
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
__powerline_left_segment "first|32"
__powerline_left_segment "second|240"
run printf '%s' "${LEFT_PROMPT}"
assert_output --partial "38;5;7"
}
2 changes: 1 addition & 1 deletion themes/powerline-plain/powerline-plain.base.bash
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function __powerline_left_segment {
fi
fi

LEFT_PROMPT+="$(set_color - "${params[1]}")${pad_before_segment}${params[0]}${normal?}"
LEFT_PROMPT+="$(set_color "${POWERLINE_PROMPT_FOREGROUND_COLOR:--}" "${params[1]}")${pad_before_segment}${params[0]}${normal?}"
LAST_SEGMENT_COLOR=${params[1]}
((SEGMENTS_AT_LEFT += 1))
}
Expand Down
4 changes: 2 additions & 2 deletions themes/powerline/powerline.base.bash
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ function __powerline_left_segment() {
fi
fi

#change here to cahnge fg color
LEFT_PROMPT+="$(set_color - "${params[1]:-}")${pad_before_segment}${params[0]}${normal?}"
#change here to change fg color
LEFT_PROMPT+="$(set_color "${POWERLINE_PROMPT_FOREGROUND_COLOR:--}" "${params[1]:-}")${pad_before_segment}${params[0]}${normal?}"
#seperator char color == current bg
LAST_SEGMENT_COLOR="${params[1]:-}"
((SEGMENTS_AT_LEFT += 1))
Expand Down
Loading