From 1d0ea0fa1ecb5cb3d3485ebbc13eafb2f9a71ee6 Mon Sep 17 00:00:00 2001 From: Erwan Le Gall Date: Wed, 4 Sep 2024 14:33:53 +0200 Subject: [PATCH 1/7] feat(themes/powerline-icon): support THEME_CLOCK_FORMAT in .bashrc --- themes/powerline-icon/powerline-icon.base.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/powerline-icon/powerline-icon.base.sh b/themes/powerline-icon/powerline-icon.base.sh index dd15122d5..a95481abb 100644 --- a/themes/powerline-icon/powerline-icon.base.sh +++ b/themes/powerline-icon/powerline-icon.base.sh @@ -32,7 +32,7 @@ function __powerline_user_info_prompt { fi ;; esac - [[ -n "${user_info}" ]] && _omb_util_print "$OMB_THEME_POWERLINE_ICON_USER ${user_info} `date +%X\ %D`|${color}|${secondary_color}" + [[ -n "${user_info}" ]] && _omb_util_print "$OMB_THEME_POWERLINE_ICON_USER ${user_info} `date +${THEME_CLOCK_FORMAT}`|${color}|${secondary_color}" } function __powerline_cwd_prompt { From f8895234f3f3bebac3086ac4eaf2dd9cee67e410 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Tue, 10 Sep 2024 10:31:10 +0900 Subject: [PATCH 2/7] fix(themes/powerline-icon): use OMB_THEME_POWERLINE_ICON_CLOCK for time format --- themes/powerline-icon/powerline-icon.base.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/themes/powerline-icon/powerline-icon.base.sh b/themes/powerline-icon/powerline-icon.base.sh index a95481abb..dd494c593 100644 --- a/themes/powerline-icon/powerline-icon.base.sh +++ b/themes/powerline-icon/powerline-icon.base.sh @@ -32,7 +32,10 @@ function __powerline_user_info_prompt { fi ;; esac - [[ -n "${user_info}" ]] && _omb_util_print "$OMB_THEME_POWERLINE_ICON_USER ${user_info} `date +${THEME_CLOCK_FORMAT}`|${color}|${secondary_color}" + if [[ -n "${user_info}" ]]; then + local clock=$(date +"${OMB_THEME_POWERLINE_ICON_CLOCK-%X %D}") + _omb_util_print "$OMB_THEME_POWERLINE_ICON_USER ${user_info}${clock:+ $clock}|${color}|${secondary_color}" + fi } function __powerline_cwd_prompt { From 9f0576593584b106ade582afb6eb9f2cf88c70a6 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Tue, 10 Sep 2024 10:32:17 +0900 Subject: [PATCH 3/7] fix(themes/powerline-wizard): fix the permission of README.md --- themes/powerline-wizard/README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 themes/powerline-wizard/README.md diff --git a/themes/powerline-wizard/README.md b/themes/powerline-wizard/README.md old mode 100755 new mode 100644 From 154157c3e9860e264f6aee13e1dc927a43eb8458 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Tue, 10 Sep 2024 10:51:54 +0900 Subject: [PATCH 4/7] docs(themes/powerline-icon): add README.md --- themes/powerline-icon/README.md | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 themes/powerline-icon/README.md diff --git a/themes/powerline-icon/README.md b/themes/powerline-icon/README.md new file mode 100644 index 000000000..30ee6b7ce --- /dev/null +++ b/themes/powerline-icon/README.md @@ -0,0 +1,34 @@ +# Powerline Icon Theme + +A theme derived from Powerline with emoji icons. + +This is based on the Powerline theme. Please see also [the documentation of the +powerline theme](../powerline/README.md). + +![Screenshot](./powerline-icon-dark.png?raw=true) + +## Segments + +The `powerline-icon` theme modifies the segments `user_info` and `cwd` of the +original Powerline theme so that they include icons. This theme also inserts a +date string in `user_info`. + +## Configuration + +Icons can be configured by setting values to the following shell variables. + +``` +OMB_THEME_POWERLINE_ICON_USER +OMB_THEME_POWERLINE_ICON_HOME +OMB_THEME_POWERLINE_ICON_EXIT_FAILURE +OMB_THEME_POWERLINE_ICON_EXIT_SUCCESS +``` + +The time format shown in the `user_info` segment can be configured by the +following shell variable: + +``` +OMB_THEME_POWERLINE_ICON_CLOCK +``` + +The default value is `%X %D`. From 45673a8be53d0dbb3a134ead6cdcc438e39ec5ad Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Tue, 10 Sep 2024 11:02:12 +0900 Subject: [PATCH 5/7] docs(themes/powerline-*): remove duplicate desc of powerline themes --- themes/powerline-light/README.md | 58 ++---------------------------- themes/powerline-naked/README.md | 60 +++----------------------------- themes/powerline-plain/README.md | 59 ++++--------------------------- 3 files changed, 14 insertions(+), 163 deletions(-) diff --git a/themes/powerline-light/README.md b/themes/powerline-light/README.md index 05c387476..820dcd318 100644 --- a/themes/powerline-light/README.md +++ b/themes/powerline-light/README.md @@ -4,59 +4,7 @@ A Powerline-derived theme for light backgrounds aiming to balance bling and util The colours were set using some experimentation and consulting an xterm 256 colour chart like [this](https://github.com/gawin/bash-colors-256) -**IMPORTANT:** This theme requires that [a font with the Powerline symbols](https://github.com/powerline/fonts) needs to be used in your terminal emulator, otherwise the prompt won't be displayed correctly, i.e. some of the additional icons and characters will be missing. Please follow your operating system's instructions to install one of the fonts from the above link and select it in your terminal emulator. +This is based on the Powerline theme. Please see also [the documentation of the +powerline theme](../powerline/README.md). -**NOTICE:** The default behavior of this theme assumes that you have sudo privileges on your workstation. If that is not the case (e.g. if you are running on a corporate network where `sudo` usage is tracked), you can set the flag 'export THEME_CHECK_SUDO=false' in your `~/.bashrc` or `~/.bash_profile` to disable the Powerline theme's `sudo` check. This will apply to all `powerline*` themes. - -## Provided Information - -* Current path -* Current username and hostname -* Current time -* An indicator when connected by SSH -* An indicator when `sudo` has the credentials cached (see the `sudo` manpage for more info about this) -* An indicator when the current shell is inside the Vim editor -* Battery charging status (depends on the [../../plugins/battery/battery.plugin.sh](battery plugin)) -* SCM Repository status (e.g. Git, SVN) -* The current Python environment (Virtualenv, venv, and Conda are supported) in use -* The current Ruby environment (rvm and rbenv are supported) in use -* Last command exit code (only shown when the exit code is greater than 0) - -## Configuration - -This theme is pretty configurable, all the configuration is done by setting environment variables. - -### User Information - -By default, the username and hostname are shown, but you can change this behavior by setting the value of the following variable: - - POWERLINE_PROMPT_USER_INFO_MODE="sudo" - -For now, the only supported value is `sudo`, which hides the username and hostname, and shows an indicator when `sudo` has the credentials cached. Other values have no effect at this time. - -### Clock Format - -You can change the format using the following variable: - - 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. - -### 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: - -* battery -* clock -* cwd -* in_vim -* python_venv -* ruby -* scm -* user_info - -A variables can be defined to set the order of the prompt segments: - - POWERLINE_PROMPT="user_info scm python_venv ruby cwd" - -The example values above are the current default values, but if you want to remove anything from the prompt, simply remove the "string" that represents the segment from the variable. +![Screenshot](./powerline-light.png?raw=true) diff --git a/themes/powerline-naked/README.md b/themes/powerline-naked/README.md index 7a4445372..e33116461 100644 --- a/themes/powerline-naked/README.md +++ b/themes/powerline-naked/README.md @@ -1,58 +1,8 @@ -# Powerline Theme +# Powerline Naked Theme -A colorful theme, where shows a lot information about your shell session. +A simple theme derived from the Powerline theme. -**IMPORTANT:** This theme requires that [a font with the Powerline symbols](https://github.com/powerline/fonts) needs to be used in your terminal emulator, otherwise the prompt won't be displayed correctly, i.e. some of the additional icons and characters will be missing. Please follow your operating system's instructions to install one of the fonts from the above link and select it in your terminal emulator. +This is based on the Powerline theme. Please see also [the documentation of the +powerline theme](../powerline/README.md). -## Provided Information - -* Current path -* Current username and hostname -* Current time -* An indicator when connected by SSH -* An indicator when `sudo` has the credentials cached (see the `sudo` manpage for more info about this) -* An indicator when the current shell is inside the Vim editor -* Battery charging status (depends on the [../../plugins/battery/battery.plugin.sh](battery plugin)) -* SCM Repository status (e.g. Git, SVN) -* The current Python environment (Virtualenv, venv, and Conda are supported) in use -* The current Ruby environment (rvm and rbenv are supported) in use -* Last command exit code (only shown when the exit code is greater than 0) - -## Configuration - -This theme is pretty configurable, all the configuration is done by setting environment variables. - -### User Information - -By default, the username and hostname are shown, but you can change this behavior by setting the value of the following variable: - - POWERLINE_PROMPT_USER_INFO_MODE="sudo" - -For now, the only supported value is `sudo`, which hides the username and hostname, and shows an indicator when `sudo` has the credentials cached. Other values have no effect at this time. - -### Clock Format - -You can change the format using the following variable: - - 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. - -### 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: - -* battery -* clock -* cwd -* in_vim -* python_venv -* ruby -* scm -* user_info - -A variables can be defined to set the order of the prompt segments: - - POWERLINE_PROMPT="user_info scm python_venv ruby cwd" - -The example values above are the current default values, but if you want to remove anything from the prompt, simply remove the "string" that represents the segment from the variable. +![Screenshot](./powerline-naked-dark.png?raw=true) diff --git a/themes/powerline-plain/README.md b/themes/powerline-plain/README.md index d880b7bd8..12eb92ae8 100644 --- a/themes/powerline-plain/README.md +++ b/themes/powerline-plain/README.md @@ -1,56 +1,9 @@ -# Powerline Theme +# Powerline Plain Theme -A colorful theme, where shows a lot information about your shell session. +A simplified version of the Powerline theme. -## Provided Information +This is based on the Powerline theme. Please see also [the documentation of the +powerline theme](../powerline/README.md). This theme does not require a font +with the Powerline symbols as required in the original Powerline theme. -* Current path -* Current username and hostname -* Current time -* An indicator when connected by SSH -* An indicator when `sudo` has the credentials cached (see the `sudo` manpage for more info about this) -* An indicator when the current shell is inside the Vim editor -* Battery charging status (depends on the [../../plugins/battery/battery.plugin.sh](battery plugin)) -* SCM Repository status (e.g. Git, SVN) -* The current Python environment (Virtualenv, venv, and Conda are supported) in use -* The current Ruby environment (rvm and rbenv are supported) in use -* Last command exit code (only shown when the exit code is greater than 0) - -## Configuration - -This theme is pretty configurable, all the configuration is done by setting environment variables. - -### User Information - -By default, the username and hostname are shown, but you can change this behavior by setting the value of the following variable: - - POWERLINE_PROMPT_USER_INFO_MODE="sudo" - -For now, the only supported value is `sudo`, which hides the username and hostname, and shows an indicator when `sudo` has the credentials cached. Other values have no effect at this time. - -### Clock Format - -You can change the format using the following variable: - - 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. - -### 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: - -* battery -* clock -* cwd -* in_vim -* python_venv -* ruby -* scm -* user_info - -A variables can be defined to set the order of the prompt segments: - - POWERLINE_PROMPT="user_info scm python_venv ruby cwd" - -The example values above are the current default values, but if you want to remove anything from the prompt, simply remove the "string" that represents the segment from the variable. +![Screenshot](./powerline-plain-dark.png?raw=true) From 2428b27143f66b1cbc8329119667f591751c943f Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Tue, 10 Sep 2024 11:04:02 +0900 Subject: [PATCH 6/7] style(themes/powerline-icon): fix indentation --- themes/powerline-icon/powerline-icon.base.sh | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/themes/powerline-icon/powerline-icon.base.sh b/themes/powerline-icon/powerline-icon.base.sh index dd494c593..c94c6b975 100644 --- a/themes/powerline-icon/powerline-icon.base.sh +++ b/themes/powerline-icon/powerline-icon.base.sh @@ -19,18 +19,18 @@ function __powerline_user_info_prompt { fi fi case "${POWERLINE_PROMPT_USER_INFO_MODE}" in - "sudo") - if [[ "${color}" == "${USER_INFO_THEME_PROMPT_COLOR_SUDO}" ]]; then - user_info="!" - fi - ;; - *) - if [[ -n "${SSH_CLIENT}" ]]; then - user_info="${USER_INFO_SSH_CHAR}${USER}@${HOSTNAME}" - else - user_info="${USER}" - fi - ;; + "sudo") + if [[ "${color}" == "${USER_INFO_THEME_PROMPT_COLOR_SUDO}" ]]; then + user_info="!" + fi + ;; + *) + if [[ -n "${SSH_CLIENT}" ]]; then + user_info="${USER_INFO_SSH_CHAR}${USER}@${HOSTNAME}" + else + user_info="${USER}" + fi + ;; esac if [[ -n "${user_info}" ]]; then local clock=$(date +"${OMB_THEME_POWERLINE_ICON_CLOCK-%X %D}") From 275b606aa9bb2bef6c332e296c3521b3ed2ba04c Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Tue, 10 Sep 2024 11:05:42 +0900 Subject: [PATCH 7/7] style(themes/powerline-*): adjust styles --- themes/powerline-icon/powerline-icon.base.sh | 24 +++---- .../powerline-multiline.base.sh | 63 +++++++++---------- .../powerline-naked/powerline-naked.base.sh | 12 ++-- .../powerline-plain/powerline-plain.base.sh | 25 ++++---- 4 files changed, 58 insertions(+), 66 deletions(-) diff --git a/themes/powerline-icon/powerline-icon.base.sh b/themes/powerline-icon/powerline-icon.base.sh index c94c6b975..7890cb2b9 100644 --- a/themes/powerline-icon/powerline-icon.base.sh +++ b/themes/powerline-icon/powerline-icon.base.sh @@ -9,41 +9,41 @@ source "$OSH/themes/powerline/powerline.base.sh" function __powerline_user_info_prompt { local user_info="" - local color=${USER_INFO_THEME_PROMPT_COLOR} - local secondary_color="${USER_INFO_THEME_PROMPT_SECONDARY_COLOR}" + local color=$USER_INFO_THEME_PROMPT_COLOR + local secondary_color=$USER_INFO_THEME_PROMPT_SECONDARY_COLOR - if [[ "${THEME_CHECK_SUDO}" = true ]]; then + if [[ $THEME_CHECK_SUDO == true ]]; then # check whether sudo is active for no-password executions if sudo -n cat <<< c3bcc5c 2>&1 | grep -q c3bcc5c; then color=${USER_INFO_THEME_PROMPT_COLOR_SUDO} fi fi - case "${POWERLINE_PROMPT_USER_INFO_MODE}" in + case $POWERLINE_PROMPT_USER_INFO_MODE in "sudo") - if [[ "${color}" == "${USER_INFO_THEME_PROMPT_COLOR_SUDO}" ]]; then + if [[ $color == "$USER_INFO_THEME_PROMPT_COLOR_SUDO" ]]; then user_info="!" fi ;; *) - if [[ -n "${SSH_CLIENT}" ]]; then - user_info="${USER_INFO_SSH_CHAR}${USER}@${HOSTNAME}" + if [[ $SSH_CLIENT ]]; then + user_info=$USER_INFO_SSH_CHAR$USER@$HOSTNAME else - user_info="${USER}" + user_info=$USER fi ;; esac - if [[ -n "${user_info}" ]]; then + if [[ $user_info ]]; then local clock=$(date +"${OMB_THEME_POWERLINE_ICON_CLOCK-%X %D}") - _omb_util_print "$OMB_THEME_POWERLINE_ICON_USER ${user_info}${clock:+ $clock}|${color}|${secondary_color}" + _omb_util_print "$OMB_THEME_POWERLINE_ICON_USER $user_info${clock:+ $clock}|$color|$secondary_color" fi } function __powerline_cwd_prompt { - _omb_util_print "$(pwd | sed "s|^${HOME}|$OMB_THEME_POWERLINE_ICON_HOME|")|${CWD_THEME_PROMPT_COLOR}" + _omb_util_print "$(pwd | sed "s|^$HOME|$OMB_THEME_POWERLINE_ICON_HOME|")|$CWD_THEME_PROMPT_COLOR" } function __powerline_last_status_prompt { - if [[ "$1" -ne 0 ]]; then + if (($1 != 0)); then _omb_util_print "$OMB_THEME_POWERLINE_ICON_EXIT_FAILURE${1}|${LAST_STATUS_THEME_PROMPT_COLOR}" else _omb_util_print "$OMB_THEME_POWERLINE_ICON_EXIT_SUCCESS|${LAST_STATUS_THEME_PROMPT_COLOR_SUCCESS}" diff --git a/themes/powerline-multiline/powerline-multiline.base.sh b/themes/powerline-multiline/powerline-multiline.base.sh index 1fcee6171..a5924a180 100644 --- a/themes/powerline-multiline/powerline-multiline.base.sh +++ b/themes/powerline-multiline/powerline-multiline.base.sh @@ -3,63 +3,58 @@ source "$OSH/themes/powerline/powerline.base.sh" function __powerline_last_status_prompt { - [[ "$1" -ne 0 ]] && _omb_util_print "$(set_color ${LAST_STATUS_THEME_PROMPT_COLOR} -) ${1} ${_omb_prompt_normal}" + (($1 != 0)) && _omb_util_print "$(set_color $LAST_STATUS_THEME_PROMPT_COLOR -) $1 $_omb_prompt_normal" } function __powerline_right_segment { - local OLD_IFS="${IFS}"; IFS="|" + local OLD_IFS=$IFS; IFS='|' local params=( $1 ) - IFS="${OLD_IFS}" - local separator_char="${POWERLINE_RIGHT_SEPARATOR}" + IFS=$OLD_IFS + local separator_char=$POWERLINE_RIGHT_SEPARATOR local padding=2 local separator_color="" - local text_color=${params[2]:-"-"} + local text_color=${params[2]:-'-'} - if [[ "${SEGMENTS_AT_RIGHT}" -eq 0 ]]; then - separator_color="$(set_color ${params[1]} -)" + if ((SEGMENTS_AT_RIGHT == 0)); then + separator_color=$(set_color ${params[1]} -) else - separator_color="$(set_color ${params[1]} ${LAST_SEGMENT_COLOR})" - (( padding += 1 )) + separator_color=$(set_color ${params[1]} $LAST_SEGMENT_COLOR) + ((padding += 1)) fi - RIGHT_PROMPT+="${separator_color}${separator_char}${_omb_prompt_normal}$(set_color ${text_color} ${params[1]}) ${params[0]} ${_omb_prompt_normal}$(set_color - ${COLOR})${_omb_prompt_normal}" - RIGHT_PROMPT_LENGTH=$(( ${#params[0]} + RIGHT_PROMPT_LENGTH + padding )) - LAST_SEGMENT_COLOR="${params[1]}" - (( SEGMENTS_AT_RIGHT += 1 )) + RIGHT_PROMPT+="$separator_color$separator_char$_omb_prompt_normal$(set_color $text_color ${params[1]}) ${params[0]} $_omb_prompt_normal$(set_color - $COLOR)$_omb_prompt_normal" + RIGHT_PROMPT_LENGTH=$((${#params[0]} + RIGHT_PROMPT_LENGTH + padding)) + LAST_SEGMENT_COLOR=${params[1]} + ((SEGMENTS_AT_RIGHT += 1)) } function __powerline_prompt_command { - local last_status="$?" ## always the first - local separator_char="${POWERLINE_LEFT_SEPARATOR}" + local last_status=$? ## always the first + local separator_char=$POWERLINE_LEFT_SEPARATOR local move_cursor_rightmost='\033[500C' - LEFT_PROMPT="" - RIGHT_PROMPT="" - RIGHT_PROMPT_LENGTH=0 - SEGMENTS_AT_LEFT=0 - SEGMENTS_AT_RIGHT=0 - LAST_SEGMENT_COLOR="" + local LEFT_PROMPT="" + local RIGHT_PROMPT="" + local RIGHT_PROMPT_LENGTH=0 + local SEGMENTS_AT_LEFT=0 + local SEGMENTS_AT_RIGHT=0 + local LAST_SEGMENT_COLOR="" ## left prompt ## for segment in $POWERLINE_LEFT_PROMPT; do - local info="$(__powerline_${segment}_prompt)" - [[ -n "${info}" ]] && __powerline_left_segment "${info}" + local info=$(__powerline_"$segment"_prompt) + [[ $info ]] && __powerline_left_segment "$info" done - [[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_color ${LAST_SEGMENT_COLOR} -)${separator_char}${_omb_prompt_normal}" + [[ $LEFT_PROMPT ]] && LEFT_PROMPT+=$(set_color ${LAST_SEGMENT_COLOR} -)${separator_char}${_omb_prompt_normal} ## right prompt ## - if [[ -n "${POWERLINE_RIGHT_PROMPT}" ]]; then - LEFT_PROMPT+="${move_cursor_rightmost}" + if [[ $POWERLINE_RIGHT_PROMPT ]]; then + LEFT_PROMPT+=$move_cursor_rightmost for segment in $POWERLINE_RIGHT_PROMPT; do - local info="$(__powerline_${segment}_prompt)" - [[ -n "${info}" ]] && __powerline_right_segment "${info}" + local info=$(__powerline_"$segment"_prompt) + [[ $info ]] && __powerline_right_segment "$info" done LEFT_PROMPT+="\033[${RIGHT_PROMPT_LENGTH}D" fi - PS1="${LEFT_PROMPT}${RIGHT_PROMPT}\n$(__powerline_last_status_prompt ${last_status})${PROMPT_CHAR} " - - ## cleanup ## - unset LAST_SEGMENT_COLOR \ - LEFT_PROMPT RIGHT_PROMPT RIGHT_PROMPT_LENGTH \ - SEGMENTS_AT_LEFT SEGMENTS_AT_RIGHT + PS1="$LEFT_PROMPT$RIGHT_PROMPT\n$(__powerline_last_status_prompt $last_status)$PROMPT_CHAR " } diff --git a/themes/powerline-naked/powerline-naked.base.sh b/themes/powerline-naked/powerline-naked.base.sh index accb0948f..6e6887db3 100644 --- a/themes/powerline-naked/powerline-naked.base.sh +++ b/themes/powerline-naked/powerline-naked.base.sh @@ -3,16 +3,16 @@ source "$OSH/themes/powerline/powerline.base.sh" function __powerline_left_segment { - local OLD_IFS="${IFS}"; IFS="|" + local OLD_IFS=$IFS; IFS='|' local params=( $1 ) - IFS="${OLD_IFS}" + IFS=$OLD_IFS local separator_char="" local separator="" - local background_color=${params[2]:-"-"} + local background_color=${params[2]:-'-'} - if [[ "${SEGMENTS_AT_LEFT}" -gt 0 ]]; then - separator="${separator_char}" + if ((SEGMENTS_AT_LEFT > 0)); then + separator=$separator_char fi LEFT_PROMPT+="${separator}$(set_color ${params[1]} ${background_color}) ${params[0]} ${_omb_prompt_normal}" - (( SEGMENTS_AT_LEFT += 1 )) + ((SEGMENTS_AT_LEFT += 1)) } diff --git a/themes/powerline-plain/powerline-plain.base.sh b/themes/powerline-plain/powerline-plain.base.sh index f35ee8823..3a643de26 100644 --- a/themes/powerline-plain/powerline-plain.base.sh +++ b/themes/powerline-plain/powerline-plain.base.sh @@ -3,30 +3,27 @@ source "$OSH/themes/powerline/powerline.base.sh" function __powerline_left_segment { - local OLD_IFS="${IFS}"; IFS="|" + local OLD_IFS=$IFS; IFS='|' local params=( $1 ) - IFS="${OLD_IFS}" - local text_color=${params[2]:-"-"} + IFS=$OLD_IFS + local text_color=${params[2]:-'-'} - LEFT_PROMPT+="${separator}$(set_color ${text_color} ${params[1]}) ${params[0]} ${_omb_prompt_normal}" + LEFT_PROMPT+="$separator$(set_color $text_color ${params[1]}) ${params[0]} $_omb_prompt_normal" LAST_SEGMENT_COLOR=${params[1]} } function __powerline_prompt_command { - local last_status="$?" ## always the first + local last_status=$? ## always the first - LEFT_PROMPT="" + local LEFT_PROMPT="" ## left prompt ## for segment in $POWERLINE_PROMPT; do - local info="$(__powerline_${segment}_prompt)" - [[ -n "${info}" ]] && __powerline_left_segment "${info}" + local info=$(__powerline_"$segment"_prompt) + [[ $info ]] && __powerline_left_segment "$info" done - [[ "${last_status}" -ne 0 ]] && __powerline_left_segment $(__powerline_last_status_prompt ${last_status}) - [[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_color ${LAST_SEGMENT_COLOR} -) ${_omb_prompt_normal}" + ((last_status != 0)) && __powerline_left_segment $(__powerline_last_status_prompt $last_status) + [[ $LEFT_PROMPT ]] && LEFT_PROMPT+="$(set_color $LAST_SEGMENT_COLOR -) $_omb_prompt_normal" - PS1="${LEFT_PROMPT} " - - ## cleanup ## - unset LEFT_PROMPT + PS1="$LEFT_PROMPT " }