New theme Atomic added and reverted the theme Brainy by default

- Brainy theme reverted to original.
- add Atomic theme based on the original brainy.
- Special thanks to @MunifTanjim and @nwinkler for such excellent job.
This commit is contained in:
Luis Felipe Sánchez
2017-05-22 14:26:13 -05:00
parent f341d1e7c5
commit 23e1bb9a7b
4 changed files with 516 additions and 105 deletions

View File

@@ -2,45 +2,6 @@
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/BrainyTheme.gif)
## 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
1. You can install the theme automatically using the `sed` command from your Linux or OSX Terminal.
2. On macOS, the ~/.bash_profile is used, not the ~/.bashrc.
3. For installation on windows you should use [`Git-Bash`](https://git-for-windows.github.io/) or make sure the terminal emulator you use (ej: cygwin, mintty, etc) has the `sed` command installed.
Command to execute For Windows and Linux:
```bash
# Set the "brainy" theme replacing the theme you are using of bash-it
sed -i 's/'"$BASH_IT_THEME"'/brainy/g' ~/.bashrc
```
Command to execute for macOS:
```bash
# Set the "brainy" theme replacing the theme you are using of bash-it
sed -i '' 's/'"$BASH_IT_THEME"'/brainy/g' ~/.bash_profile
```
## Features
### Prompt Segments
@@ -58,7 +19,7 @@ sed -i '' 's/'"$BASH_IT_THEME"'/brainy/g' ~/.bash_profile
### Others
- Indicator for cached `sudo` credential
- Indicator for abort (ctrl + C) the current task and regain user control
- Indicator for ssh login
- `brainy` command for showing/hiding various prompt segments on-the-fly
## Configuration

View File

@@ -1,30 +1,7 @@
#!/usr/bin/env bash
# Brainy Bash Prompt for Bash-it
# by MunifTanjim Edited By lfelipe
############
## Colors ##
############
IRed="\e[1;49;31m"
IGreen="\e[1;49;32m"
IYellow="\e[1;49;33m"
ICyan="\e[1;49;36m"
IWhite="\e[1;49;37m"
White="\e[0;49;37m"
BIWhite="\e[1;49;37m"
BICyan="\e[1;49;36m"
ResetColor="\e[0;49;37m"
#############
## Symbols ##
#############
Line="\342\224\200"
LineA="\342\224\214\342\224\200"
SX="\342\234\227"
LineB="\342\224\224\342\224\200\342\224\200"
Circle="\342\227\217"
Face="\342\230\273"
# by MunifTanjim
#############
## Parsers ##
@@ -42,7 +19,7 @@ ____brainy_top_left_parse() {
if [ -n "${args[4]}" ]; then
_TOP_LEFT+="${args[2]}${args[4]}"
fi
_TOP_LEFT+=""
_TOP_LEFT+=" "
}
____brainy_top_right_parse() {
@@ -82,7 +59,7 @@ ____brainy_top() {
[ -n "${info}" ] && ____brainy_top_left_parse "${info}"
done
___cursor_right="\e[500C"
___cursor_right="\033[500C"
_TOP_LEFT+="${___cursor_right}"
for seg in ${___BRAINY_TOP_RIGHT}; do
@@ -90,8 +67,8 @@ ____brainy_top() {
[ -n "${info}" ] && ____brainy_top_right_parse "${info}"
done
[ $__TOP_RIGHT_LEN -gt 0 ] && __TOP_RIGHT_LEN=$(( __TOP_RIGHT_LEN - 0 ))
___cursor_adjust="\e[${__TOP_RIGHT_LEN}D"
[ $__TOP_RIGHT_LEN -gt 0 ] && __TOP_RIGHT_LEN=$(( __TOP_RIGHT_LEN - 1 ))
___cursor_adjust="\033[${__TOP_RIGHT_LEN}D"
_TOP_LEFT+="${___cursor_adjust}"
printf "%s%s" "${_TOP_LEFT}" "${_TOP_RIGHT}"
@@ -111,16 +88,24 @@ ____brainy_bottom() {
##############
___brainy_prompt_user_info() {
color=$white
box="${normal}${LineA}\$([[ \$? != 0 ]] && echo \"${BIWhite}[${IRed}${SX}${BIWhite}]${normal}${Line}\")${Line}${BIWhite}[|${BIWhite}]${normal}${Line}"
info="${IYellow}\u${IRed}@${IGreen}\h"
printf "%s|%s|%s|%s" "${color}" "${info}" "${white}" "${box}"
color=$bold_blue
if [ "${THEME_SHOW_SUDO}" == "true" ]; then
if [ $(sudo -n id -u 2>&1 | grep 0) ]; then
color=$bold_red
fi
fi
box="[|]"
info="\u@\H"
if [ -n "${SSH_CLIENT}" ]; then
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
else
printf "%s|%s" "${color}" "${info}"
fi
}
___brainy_prompt_dir() {
color=${IRed}
box="[|]${normal}${Line}"
color=$bold_yellow
box="[|]"
info="\w"
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
}
@@ -128,7 +113,7 @@ ___brainy_prompt_dir() {
___brainy_prompt_scm() {
[ "${THEME_SHOW_SCM}" != "true" ] && return
color=$bold_green
box="[${IWhite}$(scm_char)] "
box="$(scm_char) "
info="$(scm_prompt_info)"
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
}
@@ -163,25 +148,22 @@ ___brainy_prompt_clock() {
color=$THEME_CLOCK_COLOR
box="[|]"
info="$(date +"${THEME_CLOCK_FORMAT}")"
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_purple}" "${box}"
}
___brainy_prompt_battery() {
[ ! -e "$BASH_IT"/plugins/enabled/battery.plugin.bash ] ||
[ ! -e $BASH_IT/plugins/enabled/battery.plugin.bash ] ||
[ "${THEME_SHOW_BATTERY}" != "true" ] && return
batp=$(battery_percentage)
if [ "$batp" -gt 50 ]; then
color=$bold_green
elif [ "$batp" -lt 50 ] && [ "$batp" -gt 25 ]; then
info=$(battery_percentage)
color=$bold_green
if [ "$info" -lt 50 ]; then
color=$bold_yellow
elif [ "$batp" -lt 25 ]; then
color=$IRed
elif [ "$info" -lt 25 ]; then
color=$bold_red
fi
box="[|]"
ac_adapter_disconnected && info="-"
ac_adapter_connected && info="+"
info+=$batp
[ "$info" == "+100" ] && info="AC"
ac_adapter_connected && info+="+"
[ "$info" == "100+" ] && info="AC"
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
}
@@ -192,13 +174,8 @@ ___brainy_prompt_exitcode() {
}
___brainy_prompt_char() {
color=$white
color=$bold_white
prompt_char="${__BRAINY_PROMPT_CHAR_PS1}"
if [ "${THEME_SHOW_SUDO}" == "true" ]; then
if [ $(sudo -n id -u 2>&1 | grep 0) ]; then
prompt_char="${__BRAINY_PROMPT_CHAR_PS1_SUDO}"
fi
fi
printf "%s|%s" "${color}" "${prompt_char}"
}
@@ -282,21 +259,18 @@ THEME_SHOW_RUBY=${THEME_SHOW_RUBY:-"false"}
THEME_SHOW_PYTHON=${THEME_SHOW_PYTHON:-"false"}
THEME_SHOW_CLOCK=${THEME_SHOW_CLOCK:-"true"}
THEME_SHOW_TODO=${THEME_SHOW_TODO:-"false"}
THEME_SHOW_BATTERY=${THEME_SHOW_BATTERY:-"true"}
THEME_SHOW_EXITCODE=${THEME_SHOW_EXITCODE:-"false"}
THEME_SHOW_BATTERY=${THEME_SHOW_BATTERY:-"false"}
THEME_SHOW_EXITCODE=${THEME_SHOW_EXITCODE:-"true"}
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"${BICyan}"}
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%a %b %d - %H:%M"}
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$bold_white"}
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%H:%M:%S"}
__BRAINY_PROMPT_CHAR_PS1=${THEME_PROMPT_CHAR_PS1:-"${normal}${LineB}${bold_white}${Circle}"}
__BRAINY_PROMPT_CHAR_PS2=${THEME_PROMPT_CHAR_PS2:-"${normal}${LineB}${bold_white}${Circle}"}
__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:-"${normal}${LineB}${bold_red}${Face}"}
__BRAINY_PROMPT_CHAR_PS1=${THEME_PROMPT_CHAR_PS1:-">"}
__BRAINY_PROMPT_CHAR_PS2=${THEME_PROMPT_CHAR_PS2:-"\\"}
___BRAINY_TOP_LEFT=${___BRAINY_TOP_LEFT:-"user_info dir scm"}
___BRAINY_TOP_RIGHT=${___BRAINY_TOP_RIGHT:-"exitcode python ruby todo clock battery"}
___BRAINY_BOTTOM=${___BRAINY_BOTTOM:-"char"}
___BRAINY_TOP_RIGHT=${___BRAINY_TOP_RIGHT:-"python ruby todo clock battery"}
___BRAINY_BOTTOM=${___BRAINY_BOTTOM:-"exitcode char"}
############
## Prompt ##