From 349c1df5564642b71bc92bf295e07963b166dcb2 Mon Sep 17 00:00:00 2001 From: David Farrell Date: Fri, 1 Nov 2019 10:38:34 -0700 Subject: [PATCH 1/2] Adds soft-separator suport to powerline themes --- themes/powerline-multiline/powerline-multiline.base.bash | 8 +++++++- themes/powerline-multiline/powerline-multiline.theme.bash | 2 ++ themes/powerline/powerline.base.bash | 7 ++++++- themes/powerline/powerline.theme.bash | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/themes/powerline-multiline/powerline-multiline.base.bash b/themes/powerline-multiline/powerline-multiline.base.bash index ac442f73..ea8b2624 100644 --- a/themes/powerline-multiline/powerline-multiline.base.bash +++ b/themes/powerline-multiline/powerline-multiline.base.bash @@ -9,6 +9,7 @@ function __powerline_right_segment { local params=( $1 ) IFS="${OLD_IFS}" local separator_char="${POWERLINE_RIGHT_SEPARATOR}" + local separator_char_soft="${POWERLINE_RIGHT_SEPARATOR_SOFT}" local padding="${POWERLINE_PADDING}" local separator_color="" @@ -16,7 +17,12 @@ function __powerline_right_segment { separator_char="${POWERLINE_RIGHT_END}" separator_color="$(set_color ${params[1]} -)" else - separator_color="$(set_color ${params[1]} ${LAST_SEGMENT_COLOR})" + if [[ "${LAST_SEGMENT_COLOR}" -eq "${params[1]}" ]]; then + separator_color="$(set_color - ${LAST_SEGMENT_COLOR})" + separator_char=${separator_char_soft} + else + separator_color="$(set_color ${params[1]} ${LAST_SEGMENT_COLOR})" + fi (( padding += 1 )) fi RIGHT_PROMPT+="${separator_color}${separator_char}${normal}$(set_color - ${params[1]}) ${params[0]} ${normal}$(set_color - ${COLOR})${normal}" diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index ad64fb18..5c8187eb 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -5,7 +5,9 @@ PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:="❯"} POWERLINE_LEFT_SEPARATOR=${POWERLINE_LEFT_SEPARATOR:=""} +POWERLINE_LEFT_SEPARATOR_SOFT=${POWERLINE_LEFT_SEPARATOR_SOFT:=""} POWERLINE_RIGHT_SEPARATOR=${POWERLINE_RIGHT_SEPARATOR:=""} +POWERLINE_RIGHT_SEPARATOR_SOFT=${POWERLINE_RIGHT_SEPARATOR_SOFT:=""} POWERLINE_LEFT_END=${POWERLINE_LEFT_END:=""} POWERLINE_RIGHT_END=${POWERLINE_RIGHT_END:=""} POWERLINE_PADDING=${POWERLINE_PADDING:=2} diff --git a/themes/powerline/powerline.base.bash b/themes/powerline/powerline.base.bash index 9e668a6c..d55fd60f 100644 --- a/themes/powerline/powerline.base.bash +++ b/themes/powerline/powerline.base.bash @@ -159,10 +159,15 @@ function __powerline_left_segment { local params=( $1 ) IFS="${OLD_IFS}" local separator_char="${POWERLINE_LEFT_SEPARATOR}" + local separator_char_soft="${POWERLINE_LEFT_SEPARATOR_SOFT}" local separator="" if [[ "${SEGMENTS_AT_LEFT}" -gt 0 ]]; then - separator="$(set_color ${LAST_SEGMENT_COLOR} ${params[1]})${separator_char}${normal}" + if [[ "${LAST_SEGMENT_COLOR}" -eq "${params[1]}" ]]; then + separator="$(set_color - ${LAST_SEGMENT_COLOR})${separator_char_soft}${normal}" + else + separator="$(set_color ${LAST_SEGMENT_COLOR} ${params[1]})${separator_char}${normal}" + fi fi LEFT_PROMPT+="${separator}$(set_color - ${params[1]}) ${params[0]} ${normal}" LAST_SEGMENT_COLOR=${params[1]} diff --git a/themes/powerline/powerline.theme.bash b/themes/powerline/powerline.theme.bash index 377e6f8e..bdf741cf 100644 --- a/themes/powerline/powerline.theme.bash +++ b/themes/powerline/powerline.theme.bash @@ -4,6 +4,7 @@ PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:=""} POWERLINE_LEFT_SEPARATOR=${POWERLINE_LEFT_SEPARATOR:=""} +POWERLINE_LEFT_SEPARATOR_SOFT=${POWERLINE_LEFT_SEPARATOR_SOFT:=""} USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "} USER_INFO_THEME_PROMPT_COLOR=32 From 83abf624dd762e2b86e4d26109a881fba8d3ecb8 Mon Sep 17 00:00:00 2001 From: David Farrell Date: Fri, 1 Nov 2019 17:51:22 -0700 Subject: [PATCH 2/2] Updates README files for soft separators --- themes/powerline-multiline/README.md | 4 ++++ themes/powerline/README.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/themes/powerline-multiline/README.md b/themes/powerline-multiline/README.md index ee6095dd..a2e6d121 100644 --- a/themes/powerline-multiline/README.md +++ b/themes/powerline-multiline/README.md @@ -42,6 +42,10 @@ export THEME_CLOCK_FORMAT="%H:%M:%S" The time/date is printed by the `date` command, so refer to its man page to change the format. +### Soft Separators + +Adjacent segments having the same background color will use a less-pronouced (i.e. soft) separator between them. + ### Segment Order The contents of both prompt sides can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are: diff --git a/themes/powerline/README.md b/themes/powerline/README.md index 974bcbeb..de399761 100644 --- a/themes/powerline/README.md +++ b/themes/powerline/README.md @@ -41,6 +41,10 @@ You can change the format using the following variable: The time/date is printed by the `date` command, so refer to its man page to change the format. +### Soft Separators + +Adjacent segments having the same background color will use a less-pronouced (i.e. soft) separator between them. + ### Segment Order The contents of the prompt can be "reordered", all the "segments" (every piece of information) can take any place. The currently available segments are: