Merge pull request #967 from lfelipe1501/master
New theme Atomic added and reverted the theme Brainy by defaultpull/969/head
commit
eb092f2362
|
|
@ -0,0 +1,160 @@
|
||||||
|
# Atomic theme
|
||||||
|
|
||||||
|
Simple colorful terminal prompt theme (inspired by a number of themes and it is based mainly on the theme of @MunifTanjim [`brainy`](themes/brainy/README.md)).
|
||||||
|
|
||||||
|
Supported on all operating systems.
|
||||||
|
|
||||||
|
In constant maintenance and improvement
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## 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 `atomic`.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Use the "atomic" theme
|
||||||
|
export BASH_IT_THEME="atomic"
|
||||||
|
```
|
||||||
|
|
||||||
|
### 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 "atomic" theme replacing the theme you are using of bash-it
|
||||||
|
sed -i 's/'"$BASH_IT_THEME"'/atomic/g' ~/.bashrc
|
||||||
|
```
|
||||||
|
Command to execute for macOS:
|
||||||
|
```bash
|
||||||
|
# Set the "atomic" theme replacing the theme you are using of bash-it
|
||||||
|
sed -i '' 's/'"$BASH_IT_THEME"'/atomic/g' ~/.bash_profile
|
||||||
|
```
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
### Prompt Segments
|
||||||
|
|
||||||
|
- Username & Hostname
|
||||||
|
- Current Directory
|
||||||
|
- SCM Information
|
||||||
|
- Battery Charge
|
||||||
|
- Clock
|
||||||
|
- [Todo.txt](https://github.com/ginatrapani/todo.txt-cli) status
|
||||||
|
- Ruby Environment
|
||||||
|
- Python Environment
|
||||||
|
- Exit Code
|
||||||
|
|
||||||
|
### Others
|
||||||
|
|
||||||
|
- Indicator for cached `sudo` credential
|
||||||
|
- Indicator for abort (ctrl + C) the current task and regain user control
|
||||||
|
- `atomic` command for showing/hiding various prompt segments on-the-fly
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
Various prompt segments can be shown/hidden or modified according to your choice. There are two ways for doing that:
|
||||||
|
|
||||||
|
1. On-the-fly using `atomic` command
|
||||||
|
2. Theme Environment Variables
|
||||||
|
|
||||||
|
### On-the-fly using `atomic` command
|
||||||
|
|
||||||
|
This theme provides a command for showing/hiding prompt segments.
|
||||||
|
|
||||||
|
`atomic show <segment>`
|
||||||
|
|
||||||
|
`atomic hide <segment>`
|
||||||
|
|
||||||
|
Tab-completion for this command is enabled by default.
|
||||||
|
|
||||||
|
Configuration specified by this command will only be applied to current and subsequent child shells.
|
||||||
|
|
||||||
|
### Theme Environment Variables
|
||||||
|
|
||||||
|
This is used for permanent settings that apply to all terminal sessions. You have to define the value of specific theme variables in your `bashrc` (or equivalent) file.
|
||||||
|
|
||||||
|
The name of the variables are listed below along with their default values.
|
||||||
|
|
||||||
|
#### User Information
|
||||||
|
|
||||||
|
Indicator for cached `sudo` credential (see `sudo` manpage for more information):
|
||||||
|
|
||||||
|
`THEME_SHOW_SUDO=true`
|
||||||
|
|
||||||
|
#### SCM Information
|
||||||
|
|
||||||
|
Information about SCM repository status:
|
||||||
|
|
||||||
|
`THEME_SHOW_SCM=true`
|
||||||
|
|
||||||
|
#### Ruby Environment
|
||||||
|
|
||||||
|
Ruby environment version information:
|
||||||
|
|
||||||
|
`THEME_SHOW_RUBY=false`
|
||||||
|
|
||||||
|
#### Python Environment
|
||||||
|
|
||||||
|
Python environment version information:
|
||||||
|
|
||||||
|
`THEME_SHOW_PYTHON=false`
|
||||||
|
|
||||||
|
#### ToDo.txt status
|
||||||
|
|
||||||
|
[Todo.txt](https://github.com/ginatrapani/todo.txt-cli) status:
|
||||||
|
|
||||||
|
`THEME_SHOW_TODO=false`
|
||||||
|
|
||||||
|
#### Clock
|
||||||
|
|
||||||
|
`THEME_SHOW_CLOCK=true`
|
||||||
|
|
||||||
|
`THEME_CLOCK_COLOR=$bold_cyan`
|
||||||
|
|
||||||
|
Format of the clock (see `date` manpage for more information):
|
||||||
|
|
||||||
|
`THEME_CLOCK_FORMAT="%H:%M:%S"`
|
||||||
|
|
||||||
|
#### Battery Charge
|
||||||
|
|
||||||
|
Battery charge percentage:
|
||||||
|
|
||||||
|
`THEME_SHOW_BATTERY=false`
|
||||||
|
|
||||||
|
#### Exit Code
|
||||||
|
|
||||||
|
Exit code of the last command:
|
||||||
|
|
||||||
|
`THEME_SHOW_EXITCODE=true`
|
||||||
|
|
||||||
|
## Prompt Segments Order
|
||||||
|
|
||||||
|
Currently available prompt segments are:
|
||||||
|
|
||||||
|
- battery
|
||||||
|
- char
|
||||||
|
- clock
|
||||||
|
- dir
|
||||||
|
- exitcode
|
||||||
|
- python
|
||||||
|
- ruby
|
||||||
|
- scm
|
||||||
|
- todo
|
||||||
|
- user_info
|
||||||
|
|
||||||
|
Three environment variables can be defined to rearrange the segments order. The default values are:
|
||||||
|
|
||||||
|
`___ATOMIC_TOP_LEFT="user_info dir scm"`
|
||||||
|
|
||||||
|
`___ATOMIC_TOP_RIGHT="python ruby todo clock battery"`
|
||||||
|
|
||||||
|
`___ATOMIC_BOTTOM="exitcode char"`
|
||||||
|
|
@ -0,0 +1,321 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Atomic Bash Prompt for Bash-it
|
||||||
|
# By lfelipe base on the theme brainy of MunifTanjim
|
||||||
|
|
||||||
|
############
|
||||||
|
## 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"
|
||||||
|
|
||||||
|
#############
|
||||||
|
## Parsers ##
|
||||||
|
#############
|
||||||
|
|
||||||
|
____atomic_top_left_parse() {
|
||||||
|
ifs_old="${IFS}"
|
||||||
|
IFS="|"
|
||||||
|
args=( $1 )
|
||||||
|
IFS="${ifs_old}"
|
||||||
|
if [ -n "${args[3]}" ]; then
|
||||||
|
_TOP_LEFT+="${args[2]}${args[3]}"
|
||||||
|
fi
|
||||||
|
_TOP_LEFT+="${args[0]}${args[1]}"
|
||||||
|
if [ -n "${args[4]}" ]; then
|
||||||
|
_TOP_LEFT+="${args[2]}${args[4]}"
|
||||||
|
fi
|
||||||
|
_TOP_LEFT+=""
|
||||||
|
}
|
||||||
|
|
||||||
|
____atomic_top_right_parse() {
|
||||||
|
ifs_old="${IFS}"
|
||||||
|
IFS="|"
|
||||||
|
args=( $1 )
|
||||||
|
IFS="${ifs_old}"
|
||||||
|
_TOP_RIGHT+=" "
|
||||||
|
if [ -n "${args[3]}" ]; then
|
||||||
|
_TOP_RIGHT+="${args[2]}${args[3]}"
|
||||||
|
fi
|
||||||
|
_TOP_RIGHT+="${args[0]}${args[1]}"
|
||||||
|
if [ -n "${args[4]}" ]; then
|
||||||
|
_TOP_RIGHT+="${args[2]}${args[4]}"
|
||||||
|
fi
|
||||||
|
__TOP_RIGHT_LEN=$(( __TOP_RIGHT_LEN + ${#args[1]} + ${#args[3]} + ${#args[4]} + 1 ))
|
||||||
|
(( __SEG_AT_RIGHT += 1 ))
|
||||||
|
}
|
||||||
|
|
||||||
|
____atomic_bottom_parse() {
|
||||||
|
ifs_old="${IFS}"
|
||||||
|
IFS="|"
|
||||||
|
args=( $1 )
|
||||||
|
IFS="${ifs_old}"
|
||||||
|
_BOTTOM+="${args[0]}${args[1]}"
|
||||||
|
[ ${#args[1]} -gt 0 ] && _BOTTOM+=" "
|
||||||
|
}
|
||||||
|
|
||||||
|
____atomic_top() {
|
||||||
|
_TOP_LEFT=""
|
||||||
|
_TOP_RIGHT=""
|
||||||
|
__TOP_RIGHT_LEN=0
|
||||||
|
__SEG_AT_RIGHT=0
|
||||||
|
|
||||||
|
for seg in ${___ATOMIC_TOP_LEFT}; do
|
||||||
|
info="$(___atomic_prompt_"${seg}")"
|
||||||
|
[ -n "${info}" ] && ____atomic_top_left_parse "${info}"
|
||||||
|
done
|
||||||
|
|
||||||
|
___cursor_right="\e[500C"
|
||||||
|
_TOP_LEFT+="${___cursor_right}"
|
||||||
|
|
||||||
|
for seg in ${___ATOMIC_TOP_RIGHT}; do
|
||||||
|
info="$(___atomic_prompt_"${seg}")"
|
||||||
|
[ -n "${info}" ] && ____atomic_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_LEFT+="${___cursor_adjust}"
|
||||||
|
|
||||||
|
printf "%s%s" "${_TOP_LEFT}" "${_TOP_RIGHT}"
|
||||||
|
}
|
||||||
|
|
||||||
|
____atomic_bottom() {
|
||||||
|
_BOTTOM=""
|
||||||
|
for seg in $___ATOMIC_BOTTOM; do
|
||||||
|
info="$(___atomic_prompt_"${seg}")"
|
||||||
|
[ -n "${info}" ] && ____atomic_bottom_parse "${info}"
|
||||||
|
done
|
||||||
|
printf "\n%s" "${_BOTTOM}"
|
||||||
|
}
|
||||||
|
|
||||||
|
##############
|
||||||
|
## Segments ##
|
||||||
|
##############
|
||||||
|
|
||||||
|
___atomic_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}"
|
||||||
|
}
|
||||||
|
|
||||||
|
___atomic_prompt_dir() {
|
||||||
|
color=${IRed}
|
||||||
|
box="[|]${normal}${Line}"
|
||||||
|
info="\w"
|
||||||
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
||||||
|
}
|
||||||
|
|
||||||
|
___atomic_prompt_scm() {
|
||||||
|
[ "${THEME_SHOW_SCM}" != "true" ] && return
|
||||||
|
color=$bold_green
|
||||||
|
box="[${IWhite}$(scm_char)] "
|
||||||
|
info="$(scm_prompt_info)"
|
||||||
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
||||||
|
}
|
||||||
|
|
||||||
|
___atomic_prompt_python() {
|
||||||
|
[ "${THEME_SHOW_PYTHON}" != "true" ] && return
|
||||||
|
color=$bold_yellow
|
||||||
|
box="[|]"
|
||||||
|
info="$(python_version_prompt)"
|
||||||
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_blue}" "${box}"
|
||||||
|
}
|
||||||
|
|
||||||
|
___atomic_prompt_ruby() {
|
||||||
|
[ "${THEME_SHOW_RUBY}" != "true" ] && return
|
||||||
|
color=$bold_white
|
||||||
|
box="[|]"
|
||||||
|
info="rb-$(ruby_version_prompt)"
|
||||||
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_red}" "${box}"
|
||||||
|
}
|
||||||
|
|
||||||
|
___atomic_prompt_todo() {
|
||||||
|
[ "${THEME_SHOW_TODO}" != "true" ] ||
|
||||||
|
[ -z "$(which todo.sh)" ] && return
|
||||||
|
color=$bold_white
|
||||||
|
box="[|]"
|
||||||
|
info="t:$(todo.sh ls | egrep "TODO: [0-9]+ of ([0-9]+)" | awk '{ print $4 }' )"
|
||||||
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_green}" "${box}"
|
||||||
|
}
|
||||||
|
|
||||||
|
___atomic_prompt_clock() {
|
||||||
|
[ "${THEME_SHOW_CLOCK}" != "true" ] && return
|
||||||
|
color=$THEME_CLOCK_COLOR
|
||||||
|
box="[|]"
|
||||||
|
info="$(date +"${THEME_CLOCK_FORMAT}")"
|
||||||
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
||||||
|
}
|
||||||
|
|
||||||
|
___atomic_prompt_battery() {
|
||||||
|
[ ! -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
|
||||||
|
color=$bold_yellow
|
||||||
|
elif [ "$batp" -lt 25 ]; then
|
||||||
|
color=$IRed
|
||||||
|
fi
|
||||||
|
box="[|]"
|
||||||
|
ac_adapter_disconnected && info="-"
|
||||||
|
ac_adapter_connected && info="+"
|
||||||
|
info+=$batp
|
||||||
|
[ "$info" == "+100" ] && info="AC"
|
||||||
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
||||||
|
}
|
||||||
|
|
||||||
|
___atomic_prompt_exitcode() {
|
||||||
|
[ "${THEME_SHOW_EXITCODE}" != "true" ] && return
|
||||||
|
color=$bold_purple
|
||||||
|
[ "$exitcode" -ne 0 ] && printf "%s|%s" "${color}" "${exitcode}"
|
||||||
|
}
|
||||||
|
|
||||||
|
___atomic_prompt_char() {
|
||||||
|
color=$white
|
||||||
|
prompt_char="${__ATOMIC_PROMPT_CHAR_PS1}"
|
||||||
|
if [ "${THEME_SHOW_SUDO}" == "true" ]; then
|
||||||
|
if [ $(sudo -n id -u 2>&1 | grep 0) ]; then
|
||||||
|
prompt_char="${__ATOMIC_PROMPT_CHAR_PS1_SUDO}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
printf "%s|%s" "${color}" "${prompt_char}"
|
||||||
|
}
|
||||||
|
|
||||||
|
#########
|
||||||
|
## cli ##
|
||||||
|
#########
|
||||||
|
|
||||||
|
__atomic_show() {
|
||||||
|
typeset _seg=${1:-}
|
||||||
|
shift
|
||||||
|
export THEME_SHOW_${_seg}=true
|
||||||
|
}
|
||||||
|
|
||||||
|
__atomic_hide() {
|
||||||
|
typeset _seg=${1:-}
|
||||||
|
shift
|
||||||
|
export THEME_SHOW_${_seg}=false
|
||||||
|
}
|
||||||
|
|
||||||
|
_atomic_completion() {
|
||||||
|
local cur _action actions segments
|
||||||
|
COMPREPLY=()
|
||||||
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
_action="${COMP_WORDS[1]}"
|
||||||
|
actions="show hide"
|
||||||
|
segments="battery clock exitcode python ruby scm sudo todo"
|
||||||
|
case "${_action}" in
|
||||||
|
show)
|
||||||
|
COMPREPLY=( $(compgen -W "${segments}" -- "${cur}") )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
hide)
|
||||||
|
COMPREPLY=( $(compgen -W "${segments}" -- "${cur}") )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
COMPREPLY=( $(compgen -W "${actions}" -- "${cur}") )
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
atomic() {
|
||||||
|
typeset action=${1:-}
|
||||||
|
shift
|
||||||
|
typeset segs=${*:-}
|
||||||
|
typeset func
|
||||||
|
case $action in
|
||||||
|
show)
|
||||||
|
func=__atomic_show;;
|
||||||
|
hide)
|
||||||
|
func=__atomic_hide;;
|
||||||
|
esac
|
||||||
|
for seg in ${segs}; do
|
||||||
|
seg=$(printf "%s" "${seg}" | tr '[:lower:]' '[:upper:]')
|
||||||
|
$func "${seg}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -F _atomic_completion atomic
|
||||||
|
|
||||||
|
###############
|
||||||
|
## Variables ##
|
||||||
|
###############
|
||||||
|
|
||||||
|
export SCM_THEME_PROMPT_PREFIX=""
|
||||||
|
export SCM_THEME_PROMPT_SUFFIX=""
|
||||||
|
|
||||||
|
export RBENV_THEME_PROMPT_PREFIX=""
|
||||||
|
export RBENV_THEME_PROMPT_SUFFIX=""
|
||||||
|
export RBFU_THEME_PROMPT_PREFIX=""
|
||||||
|
export RBFU_THEME_PROMPT_SUFFIX=""
|
||||||
|
export RVM_THEME_PROMPT_PREFIX=""
|
||||||
|
export RVM_THEME_PROMPT_SUFFIX=""
|
||||||
|
|
||||||
|
export SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}"
|
||||||
|
export SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓${normal}"
|
||||||
|
|
||||||
|
THEME_SHOW_SUDO=${THEME_SHOW_SUDO:-"true"}
|
||||||
|
THEME_SHOW_SCM=${THEME_SHOW_SCM:-"true"}
|
||||||
|
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_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"${BICyan}"}
|
||||||
|
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%a %b %d - %H:%M"}
|
||||||
|
|
||||||
|
__ATOMIC_PROMPT_CHAR_PS1=${THEME_PROMPT_CHAR_PS1:-"${normal}${LineB}${bold_white}${Circle}"}
|
||||||
|
__ATOMIC_PROMPT_CHAR_PS2=${THEME_PROMPT_CHAR_PS2:-"${normal}${LineB}${bold_white}${Circle}"}
|
||||||
|
|
||||||
|
__ATOMIC_PROMPT_CHAR_PS1_SUDO=${THEME_PROMPT_CHAR_PS1_SUDO:-"${normal}${LineB}${bold_red}${Face}"}
|
||||||
|
__ATOMIC_PROMPT_CHAR_PS2_SUDO=${THEME_PROMPT_CHAR_PS2_SUDO:-"${normal}${LineB}${bold_red}${Face}"}
|
||||||
|
|
||||||
|
___ATOMIC_TOP_LEFT=${___ATOMIC_TOP_LEFT:-"user_info dir scm"}
|
||||||
|
___ATOMIC_TOP_RIGHT=${___ATOMIC_TOP_RIGHT:-"exitcode python ruby todo clock battery"}
|
||||||
|
___ATOMIC_BOTTOM=${___ATOMIC_BOTTOM:-"char"}
|
||||||
|
|
||||||
|
############
|
||||||
|
## Prompt ##
|
||||||
|
############
|
||||||
|
|
||||||
|
__atomic_ps1() {
|
||||||
|
printf "%s%s%s" "$(____atomic_top)" "$(____atomic_bottom)" "${normal}"
|
||||||
|
}
|
||||||
|
|
||||||
|
__atomic_ps2() {
|
||||||
|
color=$bold_white
|
||||||
|
printf "%s%s%s" "${color}" "${__ATOMIC_PROMPT_CHAR_PS2} " "${normal}"
|
||||||
|
}
|
||||||
|
|
||||||
|
_atomic_prompt() {
|
||||||
|
exitcode="$?"
|
||||||
|
|
||||||
|
PS1="$(__atomic_ps1)"
|
||||||
|
PS2="$(__atomic_ps2)"
|
||||||
|
}
|
||||||
|
|
||||||
|
safe_append_prompt_command _atomic_prompt
|
||||||
|
|
@ -2,45 +2,6 @@
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 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
|
## Features
|
||||||
|
|
||||||
### Prompt Segments
|
### Prompt Segments
|
||||||
|
|
@ -58,7 +19,7 @@ sed -i '' 's/'"$BASH_IT_THEME"'/brainy/g' ~/.bash_profile
|
||||||
### Others
|
### Others
|
||||||
|
|
||||||
- Indicator for cached `sudo` credential
|
- 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
|
- `brainy` command for showing/hiding various prompt segments on-the-fly
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,7 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Brainy Bash Prompt for Bash-it
|
# Brainy Bash Prompt for Bash-it
|
||||||
# by MunifTanjim Edited By lfelipe
|
# by MunifTanjim
|
||||||
|
|
||||||
############
|
|
||||||
## 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"
|
|
||||||
|
|
||||||
#############
|
#############
|
||||||
## Parsers ##
|
## Parsers ##
|
||||||
|
|
@ -42,7 +19,7 @@ ____brainy_top_left_parse() {
|
||||||
if [ -n "${args[4]}" ]; then
|
if [ -n "${args[4]}" ]; then
|
||||||
_TOP_LEFT+="${args[2]}${args[4]}"
|
_TOP_LEFT+="${args[2]}${args[4]}"
|
||||||
fi
|
fi
|
||||||
_TOP_LEFT+=""
|
_TOP_LEFT+=" "
|
||||||
}
|
}
|
||||||
|
|
||||||
____brainy_top_right_parse() {
|
____brainy_top_right_parse() {
|
||||||
|
|
@ -82,7 +59,7 @@ ____brainy_top() {
|
||||||
[ -n "${info}" ] && ____brainy_top_left_parse "${info}"
|
[ -n "${info}" ] && ____brainy_top_left_parse "${info}"
|
||||||
done
|
done
|
||||||
|
|
||||||
___cursor_right="\e[500C"
|
___cursor_right="\033[500C"
|
||||||
_TOP_LEFT+="${___cursor_right}"
|
_TOP_LEFT+="${___cursor_right}"
|
||||||
|
|
||||||
for seg in ${___BRAINY_TOP_RIGHT}; do
|
for seg in ${___BRAINY_TOP_RIGHT}; do
|
||||||
|
|
@ -90,8 +67,8 @@ ____brainy_top() {
|
||||||
[ -n "${info}" ] && ____brainy_top_right_parse "${info}"
|
[ -n "${info}" ] && ____brainy_top_right_parse "${info}"
|
||||||
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 - 1 ))
|
||||||
___cursor_adjust="\e[${__TOP_RIGHT_LEN}D"
|
___cursor_adjust="\033[${__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}"
|
||||||
|
|
@ -111,16 +88,24 @@ ____brainy_bottom() {
|
||||||
##############
|
##############
|
||||||
|
|
||||||
___brainy_prompt_user_info() {
|
___brainy_prompt_user_info() {
|
||||||
color=$white
|
color=$bold_blue
|
||||||
box="${normal}${LineA}\$([[ \$? != 0 ]] && echo \"${BIWhite}[${IRed}${SX}${BIWhite}]${normal}${Line}\")${Line}${BIWhite}[|${BIWhite}]${normal}${Line}"
|
if [ "${THEME_SHOW_SUDO}" == "true" ]; then
|
||||||
info="${IYellow}\u${IRed}@${IGreen}\h"
|
if [ $(sudo -n id -u 2>&1 | grep 0) ]; then
|
||||||
|
color=$bold_red
|
||||||
printf "%s|%s|%s|%s" "${color}" "${info}" "${white}" "${box}"
|
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() {
|
___brainy_prompt_dir() {
|
||||||
color=${IRed}
|
color=$bold_yellow
|
||||||
box="[|]${normal}${Line}"
|
box="[|]"
|
||||||
info="\w"
|
info="\w"
|
||||||
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
||||||
}
|
}
|
||||||
|
|
@ -128,7 +113,7 @@ ___brainy_prompt_dir() {
|
||||||
___brainy_prompt_scm() {
|
___brainy_prompt_scm() {
|
||||||
[ "${THEME_SHOW_SCM}" != "true" ] && return
|
[ "${THEME_SHOW_SCM}" != "true" ] && return
|
||||||
color=$bold_green
|
color=$bold_green
|
||||||
box="[${IWhite}$(scm_char)] "
|
box="$(scm_char) "
|
||||||
info="$(scm_prompt_info)"
|
info="$(scm_prompt_info)"
|
||||||
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
||||||
}
|
}
|
||||||
|
|
@ -163,25 +148,22 @@ ___brainy_prompt_clock() {
|
||||||
color=$THEME_CLOCK_COLOR
|
color=$THEME_CLOCK_COLOR
|
||||||
box="[|]"
|
box="[|]"
|
||||||
info="$(date +"${THEME_CLOCK_FORMAT}")"
|
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() {
|
___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)
|
info=$(battery_percentage)
|
||||||
if [ "$batp" -gt 50 ]; then
|
|
||||||
color=$bold_green
|
color=$bold_green
|
||||||
elif [ "$batp" -lt 50 ] && [ "$batp" -gt 25 ]; then
|
if [ "$info" -lt 50 ]; then
|
||||||
color=$bold_yellow
|
color=$bold_yellow
|
||||||
elif [ "$batp" -lt 25 ]; then
|
elif [ "$info" -lt 25 ]; then
|
||||||
color=$IRed
|
color=$bold_red
|
||||||
fi
|
fi
|
||||||
box="[|]"
|
box="[|]"
|
||||||
ac_adapter_disconnected && info="-"
|
ac_adapter_connected && info+="+"
|
||||||
ac_adapter_connected && info="+"
|
[ "$info" == "100+" ] && info="AC"
|
||||||
info+=$batp
|
|
||||||
[ "$info" == "+100" ] && info="AC"
|
|
||||||
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -192,13 +174,8 @@ ___brainy_prompt_exitcode() {
|
||||||
}
|
}
|
||||||
|
|
||||||
___brainy_prompt_char() {
|
___brainy_prompt_char() {
|
||||||
color=$white
|
color=$bold_white
|
||||||
prompt_char="${__BRAINY_PROMPT_CHAR_PS1}"
|
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}"
|
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_PYTHON=${THEME_SHOW_PYTHON:-"false"}
|
||||||
THEME_SHOW_CLOCK=${THEME_SHOW_CLOCK:-"true"}
|
THEME_SHOW_CLOCK=${THEME_SHOW_CLOCK:-"true"}
|
||||||
THEME_SHOW_TODO=${THEME_SHOW_TODO:-"false"}
|
THEME_SHOW_TODO=${THEME_SHOW_TODO:-"false"}
|
||||||
THEME_SHOW_BATTERY=${THEME_SHOW_BATTERY:-"true"}
|
THEME_SHOW_BATTERY=${THEME_SHOW_BATTERY:-"false"}
|
||||||
THEME_SHOW_EXITCODE=${THEME_SHOW_EXITCODE:-"false"}
|
THEME_SHOW_EXITCODE=${THEME_SHOW_EXITCODE:-"true"}
|
||||||
|
|
||||||
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"${BICyan}"}
|
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$bold_white"}
|
||||||
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%a %b %d - %H:%M"}
|
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_PS1=${THEME_PROMPT_CHAR_PS1:-">"}
|
||||||
__BRAINY_PROMPT_CHAR_PS2=${THEME_PROMPT_CHAR_PS2:-"${normal}${LineB}${bold_white}${Circle}"}
|
__BRAINY_PROMPT_CHAR_PS2=${THEME_PROMPT_CHAR_PS2:-"\\"}
|
||||||
|
|
||||||
__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_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:-"exitcode python ruby todo clock battery"}
|
___BRAINY_TOP_RIGHT=${___BRAINY_TOP_RIGHT:-"python ruby todo clock battery"}
|
||||||
___BRAINY_BOTTOM=${___BRAINY_BOTTOM:-"char"}
|
___BRAINY_BOTTOM=${___BRAINY_BOTTOM:-"exitcode char"}
|
||||||
|
|
||||||
############
|
############
|
||||||
## Prompt ##
|
## Prompt ##
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue