Fixed and improved the theme

Corrected problem with prompt where sometimes keeped part of previous commands when scrolling history
pull/959/head
Luis Felipe Sánchez 2017-05-12 11:57:21 -05:00
parent 1022879553
commit c92d12bed1
4 changed files with 45 additions and 20 deletions

View File

@ -1,8 +1,33 @@
# Brainy theme # Brainy theme
Simple colorful terminal prompt theme (inspired by a number of themes). Simple colorful terminal prompt theme (inspired by a number of themes).
Supported on all operating systems
In constant maintenance and improvement
![alt text](https://www.lfsystems.xyz/img/brainy-Arch.png) ![alt text](img/BrainyTheme.gif "Brainy Theme")
## Install Theme
### Manually
You can install the theme manually by following these steps:
Edit your modified config `~/.bashrc` file in order to customize Bash-it, set `BASH_IT_THEME` to the theme name `brainy`.
Examples:
```bash
# Use the "brainy" theme
export BASH_IT_THEME="brainy"
### Automatically via terminal
You can install the theme automatically using the `sed` command from your terminal.
Examples:
```bash
# Set the "brainy" theme replacing the theme you are using of bash-it
sed -i 's/'"$BASH_IT_THEME"'/brainy/g' ~/.bashrc
## Features ## Features
@ -21,7 +46,7 @@ Simple colorful terminal prompt theme (inspired by a number of themes).
### Others ### Others
- Indicator for cached `sudo` credential - Indicator for cached `sudo` credential
- Indicator for ssh login - Indicator for abort (ctrl + C) the current task and regain user control
- `brainy` command for showing/hiding various prompt segments on-the-fly - `brainy` command for showing/hiding various prompt segments on-the-fly
## Configuration ## Configuration

Binary file not shown.

Before

Width:  |  Height:  |  Size: 430 KiB

View File

@ -68,7 +68,7 @@ ____brainy_bottom_parse() {
args=( $1 ) args=( $1 )
IFS="${ifs_old}" IFS="${ifs_old}"
_BOTTOM+="${args[0]}${args[1]}" _BOTTOM+="${args[0]}${args[1]}"
[ ${#args[1]} -gt 0 ] && _BOTTOM+="" [ ${#args[1]} -gt 0 ] && _BOTTOM+=" "
} }
____brainy_top() { ____brainy_top() {
@ -82,7 +82,7 @@ ____brainy_top() {
[ -n "${info}" ] && ____brainy_top_left_parse "${info}" [ -n "${info}" ] && ____brainy_top_left_parse "${info}"
done done
___cursor_right="\033[500C" ___cursor_right="\e[500C"
_TOP_LEFT+="${___cursor_right}" _TOP_LEFT+="${___cursor_right}"
for seg in ${___BRAINY_TOP_RIGHT}; do for seg in ${___BRAINY_TOP_RIGHT}; do
@ -91,7 +91,7 @@ ____brainy_top() {
done done
[ $__TOP_RIGHT_LEN -gt 0 ] && __TOP_RIGHT_LEN=$(( __TOP_RIGHT_LEN - 0 )) [ $__TOP_RIGHT_LEN -gt 0 ] && __TOP_RIGHT_LEN=$(( __TOP_RIGHT_LEN - 0 ))
___cursor_adjust="\033[${__TOP_RIGHT_LEN}D" ___cursor_adjust="\e[${__TOP_RIGHT_LEN}D"
_TOP_LEFT+="${___cursor_adjust}" _TOP_LEFT+="${___cursor_adjust}"
printf "%s%s" "${_TOP_LEFT}" "${_TOP_RIGHT}" printf "%s%s" "${_TOP_LEFT}" "${_TOP_RIGHT}"
@ -112,7 +112,7 @@ ____brainy_bottom() {
___brainy_prompt_user_info() { ___brainy_prompt_user_info() {
color=$white color=$white
box="${ResetColor}${LineA}\$([[ \$? != 0 ]] && echo \"${BIWhite}[${IRed}${SX}${BIWhite}]${ResetColor}${Line}\")${ResetColor}${Line}${BIWhite}[|${BIWhite}]${ResetColor}${Line}" box="${normal}${LineA}\$([[ \$? != 0 ]] && echo \"${BIWhite}[${IRed}${SX}${BIWhite}]${normal}${Line}\")${Line}${BIWhite}[|${BIWhite}]${normal}${Line}"
info="${IYellow}\u${IRed}@${IGreen}\h" info="${IYellow}\u${IRed}@${IGreen}\h"
printf "%s|%s|%s|%s" "${color}" "${info}" "${white}" "${box}" printf "%s|%s|%s|%s" "${color}" "${info}" "${white}" "${box}"
@ -120,17 +120,17 @@ ___brainy_prompt_user_info() {
___brainy_prompt_dir() { ___brainy_prompt_dir() {
color=${IRed} color=${IRed}
box="${BIWhite}[|${BIWhite}]" box="[|]${normal}${Line}"
info="\W" info="\w"
printf "%s|%s|%s|%s" "${color}" "${info}" "${white}" "${box}" printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
} }
___brainy_prompt_scm() { ___brainy_prompt_scm() {
[ "${THEME_SHOW_SCM}" != "true" ] && return [ "${THEME_SHOW_SCM}" != "true" ] && return
color=$bold_green color=$bold_green
box="${ResetColor}${Line}${BIWhite}[${IWhite}$(scm_char)${BIWhite}] " box="[${IWhite}$(scm_char)] "
info="$(scm_prompt_info)" info="$(scm_prompt_info)"
printf "%s|%s|%s|%s" "${color}" "${info}" "${white}" "${box}" printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
} }
___brainy_prompt_python() { ___brainy_prompt_python() {
@ -167,7 +167,7 @@ ___brainy_prompt_clock() {
} }
___brainy_prompt_battery() { ___brainy_prompt_battery() {
[ ! -e $BASH_IT/plugins/enabled/battery.plugin.bash ] || [ ! -e "$BASH_IT"/plugins/enabled/battery.plugin.bash ] ||
[ "${THEME_SHOW_BATTERY}" != "true" ] && return [ "${THEME_SHOW_BATTERY}" != "true" ] && return
batp=$(battery_percentage) batp=$(battery_percentage)
if [ "$batp" -gt 50 ]; then if [ "$batp" -gt 50 ]; then
@ -175,7 +175,7 @@ ___brainy_prompt_battery() {
elif [ "$batp" -lt 50 ] && [ "$batp" -gt 25 ]; then elif [ "$batp" -lt 50 ] && [ "$batp" -gt 25 ]; then
color=$bold_yellow color=$bold_yellow
elif [ "$batp" -lt 25 ]; then elif [ "$batp" -lt 25 ]; then
color=$ColorRed color=$IRed
fi fi
box="[|]" box="[|]"
ac_adapter_disconnected && info="-" ac_adapter_disconnected && info="-"
@ -192,7 +192,7 @@ ___brainy_prompt_exitcode() {
} }
___brainy_prompt_char() { ___brainy_prompt_char() {
color=$bold_red color=$white
prompt_char="${__BRAINY_PROMPT_CHAR_PS1}" prompt_char="${__BRAINY_PROMPT_CHAR_PS1}"
if [ "${THEME_SHOW_SUDO}" == "true" ]; then if [ "${THEME_SHOW_SUDO}" == "true" ]; then
if [ $(sudo -n id -u 2>&1 | grep 0) ]; then if [ $(sudo -n id -u 2>&1 | grep 0) ]; then
@ -288,15 +288,15 @@ THEME_SHOW_EXITCODE=${THEME_SHOW_EXITCODE:-"false"}
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"${BICyan}"} THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"${BICyan}"}
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%a %b %d - %H:%M"} THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%a %b %d - %H:%M"}
__BRAINY_PROMPT_CHAR_PS1=${THEME_PROMPT_CHAR_PS1:-"${ResetColor}${LineB}${BIWhite}${Circle} ${ResetColor}"} __BRAINY_PROMPT_CHAR_PS1=${THEME_PROMPT_CHAR_PS1:-"${normal}${LineB}${bold_white}${Circle}"}
__BRAINY_PROMPT_CHAR_PS2=${THEME_PROMPT_CHAR_PS2:-"${ResetColor}${LineB}${BIWhite}${Circle} ${ResetColor}"} __BRAINY_PROMPT_CHAR_PS2=${THEME_PROMPT_CHAR_PS2:-"${normal}${LineB}${bold_white}${Circle}"}
__BRAINY_PROMPT_CHAR_PS1_SUDO=${THEME_PROMPT_CHAR_PS1_SUDO:-"${ResetColor}${LineB}${IRed}${Face} ${ResetColor}"} __BRAINY_PROMPT_CHAR_PS1_SUDO=${THEME_PROMPT_CHAR_PS1_SUDO:-"${normal}${LineB}${bold_red}${Face}"}
__BRAINY_PROMPT_CHAR_PS2_SUDO=${THEME_PROMPT_CHAR_PS2_SUDO:-"${ResetColor}${LineB}${IRed}${Face} ${ResetColor}"} __BRAINY_PROMPT_CHAR_PS2_SUDO=${THEME_PROMPT_CHAR_PS2_SUDO:-"${normal}${LineB}${bold_red}${Face}"}
___BRAINY_TOP_LEFT=${___BRAINY_TOP_LEFT:-"user_info dir scm"} ___BRAINY_TOP_LEFT=${___BRAINY_TOP_LEFT:-"user_info dir scm"}
___BRAINY_TOP_RIGHT=${___BRAINY_TOP_RIGHT:-"python ruby todo clock battery"} ___BRAINY_TOP_RIGHT=${___BRAINY_TOP_RIGHT:-"exitcode python ruby todo clock battery"}
___BRAINY_BOTTOM=${___BRAINY_BOTTOM:-"exitcode char"} ___BRAINY_BOTTOM=${___BRAINY_BOTTOM:-"char"}
############ ############
## Prompt ## ## Prompt ##

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB