Merge branch 'master' of https://github.com/Bash-it/bash-it
This commit is contained in:
17
themes/90210/90210.theme.bash
Normal file
17
themes/90210/90210.theme.bash
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
SCM_THEME_PROMPT_DIRTY=" ${red}✗"
|
||||
SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓"
|
||||
SCM_THEME_PROMPT_PREFIX=" |"
|
||||
SCM_THEME_PROMPT_SUFFIX="${green}|"
|
||||
|
||||
GIT_THEME_PROMPT_DIRTY=" ${red}✗"
|
||||
GIT_THEME_PROMPT_CLEAN=" ${bold_green}✓"
|
||||
GIT_THEME_PROMPT_PREFIX=" ${green}|"
|
||||
GIT_THEME_PROMPT_SUFFIX="${green}|"
|
||||
|
||||
# Nicely formatted terminal prompt
|
||||
function prompt_command(){
|
||||
export PS1="\n${bold_black}[${blue}\@${bold_black}]-${bold_black}[${green}\u${yellow}@${green}\h${bold_black}]-${bold_black}[${purple}\w${bold_black}]-$(scm_prompt_info)\n${reset_color}\$ "
|
||||
}
|
||||
|
||||
safe_append_prompt_command prompt_command
|
||||
166
themes/atomic/README.md
Normal file
166
themes/atomic/README.md
Normal file
@@ -0,0 +1,166 @@
|
||||
# Atomic theme
|
||||
|
||||
The Best ColorFull terminal prompt theme inspired by a number of themes and based on the theme of @MunifTanjim [`brainy`](../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="exitcode python ruby todo clock battery"`
|
||||
|
||||
`___ATOMIC_BOTTOM="char"`
|
||||
|
||||
### Development by
|
||||
|
||||
Developer / Author: [Luis Felipe Sánchez](https://github.com/lfelipe1501)
|
||||
|
||||
This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
|
||||
320
themes/atomic/atomic.theme.bash
Normal file
320
themes/atomic/atomic.theme.bash
Normal file
@@ -0,0 +1,320 @@
|
||||
#!/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"
|
||||
IWhite="\e[1;49;37m"
|
||||
BIWhite="\e[1;49;37m"
|
||||
BICyan="\e[1;49;36m"
|
||||
|
||||
#############
|
||||
## 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() {
|
||||
! _command_exists battery_percentage ||
|
||||
[ "${THEME_SHOW_BATTERY}" != "true" ] ||
|
||||
[ "$(battery_percentage)" = "no" ] && return
|
||||
|
||||
batp=$(battery_percentage)
|
||||
if [ "$batp" -eq 50 ] || [ "$batp" -gt 50 ]; then
|
||||
color=$bold_green
|
||||
elif [ "$batp" -lt 50 ] && [ "$batp" -gt 25 ]; then
|
||||
color=$bold_yellow
|
||||
elif [ "$batp" -eq 25 ] || [ "$batp" -lt 25 ]; then
|
||||
color=$IRed
|
||||
fi
|
||||
box="[|]"
|
||||
ac_adapter_connected && info="+"
|
||||
ac_adapter_disconnected && info="-"
|
||||
info+=$batp
|
||||
[ "$batp" -eq 100 ] || [ "$batp" -gt 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
|
||||
@@ -3,10 +3,6 @@
|
||||
# Axin Bash Prompt, inspired by theme "Sexy" and "Bobby"
|
||||
# thanks to them
|
||||
|
||||
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then export TERM=gnome-256color
|
||||
elif [[ $TERM != dumb ]] && infocmp xterm-256color >/dev/null 2>&1; then export TERM=xterm-256color
|
||||
fi
|
||||
|
||||
if tput setaf 1 &> /dev/null; then
|
||||
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
|
||||
MAGENTA=$(tput setaf 9)
|
||||
|
||||
@@ -16,7 +16,7 @@ function prompt_command() {
|
||||
#PS1="${bold_cyan}$(scm_char)${green}$(scm_prompt_info)${purple}$(ruby_version_prompt) ${yellow}\h ${reset_color}in ${green}\w ${reset_color}\n${green}→${reset_color} "
|
||||
#PS1="\n${purple}\h: ${reset_color} ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}→${reset_color} "
|
||||
#PS1="\n${cyan}\h: ${reset_color} ${yellow}\w\n${red}$(scm_char)${red}$(scm_prompt_info) ${green}→${reset_color} "
|
||||
PS1="\n${cyan}\h: ${reset_color} ${yellow}\w ${green}$(scm_prompt_info)\n${reset_color}→ "
|
||||
PS1="\n${cyan}\h:$(virtualenv_prompt) ${reset_color} ${yellow}\w ${green}$(scm_prompt_info)\n${reset_color}→ "
|
||||
}
|
||||
|
||||
safe_append_prompt_command prompt_command
|
||||
|
||||
@@ -20,6 +20,8 @@ SCM_THEME_BRANCH_TRACK_PREFIX=' → '
|
||||
SCM_THEME_BRANCH_GONE_PREFIX=' ⇢ '
|
||||
SCM_THEME_CURRENT_USER_PREFFIX=' ☺︎ '
|
||||
SCM_THEME_CURRENT_USER_SUFFIX=''
|
||||
SCM_THEME_CHAR_PREFIX=''
|
||||
SCM_THEME_CHAR_SUFFIX=''
|
||||
|
||||
THEME_BATTERY_PERCENTAGE_CHECK=${THEME_BATTERY_PERCENTAGE_CHECK:=true}
|
||||
|
||||
@@ -37,6 +39,8 @@ SCM_GIT_BEHIND_CHAR="↓"
|
||||
SCM_GIT_UNTRACKED_CHAR="?:"
|
||||
SCM_GIT_UNSTAGED_CHAR="U:"
|
||||
SCM_GIT_STAGED_CHAR="S:"
|
||||
SCM_GIT_STASH_CHAR_PREFIX="{"
|
||||
SCM_GIT_STASH_CHAR_SUFFIX="}"
|
||||
|
||||
SCM_HG='hg'
|
||||
SCM_HG_CHAR='☿'
|
||||
@@ -50,6 +54,10 @@ SCM_NONE_CHAR='○'
|
||||
RVM_THEME_PROMPT_PREFIX=' |'
|
||||
RVM_THEME_PROMPT_SUFFIX='|'
|
||||
|
||||
THEME_SHOW_USER_HOST=${THEME_SHOW_USER_HOST:=false}
|
||||
USER_HOST_THEME_PROMPT_PREFIX=''
|
||||
USER_HOST_THEME_PROMPT_SUFFIX=''
|
||||
|
||||
VIRTUALENV_THEME_PROMPT_PREFIX=' |'
|
||||
VIRTUALENV_THEME_PROMPT_SUFFIX='|'
|
||||
|
||||
@@ -92,6 +100,16 @@ function scm_prompt_vars {
|
||||
function scm_prompt_info {
|
||||
scm
|
||||
scm_prompt_char
|
||||
scm_prompt_info_common
|
||||
}
|
||||
|
||||
function scm_prompt_char_info {
|
||||
scm_prompt_char
|
||||
echo -ne "${SCM_THEME_CHAR_PREFIX}${SCM_CHAR}${SCM_THEME_CHAR_SUFFIX}"
|
||||
scm_prompt_info_common
|
||||
}
|
||||
|
||||
function scm_prompt_info_common {
|
||||
SCM_DIRTY=0
|
||||
SCM_STATE=''
|
||||
|
||||
@@ -111,6 +129,15 @@ function scm_prompt_info {
|
||||
[[ ${SCM} == ${SCM_SVN} ]] && svn_prompt_info && return
|
||||
}
|
||||
|
||||
# This is added to address bash shell interpolation vulnerability described
|
||||
# here: https://github.com/njhartwell/pw3nage
|
||||
function git_clean_branch {
|
||||
local unsafe_ref=$(command git symbolic-ref -q HEAD 2> /dev/null)
|
||||
local stripped_ref=${unsafe_ref##refs/heads/}
|
||||
local clean_ref=${stripped_ref//[^a-zA-Z0-9\/]/-}
|
||||
echo $clean_ref
|
||||
}
|
||||
|
||||
function git_prompt_minimal_info {
|
||||
local ref
|
||||
local status
|
||||
@@ -119,9 +146,9 @@ function git_prompt_minimal_info {
|
||||
|
||||
if [[ "$(command git config --get bash-it.hide-status)" != "1" ]]; then
|
||||
# Get the branch reference
|
||||
ref=$(command git symbolic-ref -q HEAD 2> /dev/null) || \
|
||||
ref=$(git_clean_branch) || \
|
||||
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0
|
||||
SCM_BRANCH=${SCM_THEME_BRANCH_PREFIX}${ref#refs/heads/}
|
||||
SCM_BRANCH=${SCM_THEME_BRANCH_PREFIX}${ref}
|
||||
|
||||
# Get the status
|
||||
[[ "${SCM_GIT_IGNORE_UNTRACKED}" = "true" ]] && git_status_flags+='-untracked-files=no'
|
||||
@@ -195,10 +222,11 @@ function git_prompt_vars {
|
||||
|
||||
SCM_CHANGE=$(git rev-parse --short HEAD 2>/dev/null)
|
||||
|
||||
local ref=$(git symbolic-ref -q HEAD 2> /dev/null)
|
||||
local ref=$(git_clean_branch)
|
||||
|
||||
if [[ -n "$ref" ]]; then
|
||||
SCM_BRANCH=${SCM_THEME_BRANCH_PREFIX}${ref#refs/heads/}
|
||||
local tracking_info="$(grep "${SCM_BRANCH}\.\.\." <<< "${status}")"
|
||||
SCM_BRANCH="${SCM_THEME_BRANCH_PREFIX}${ref}"
|
||||
local tracking_info="$(grep -- "${SCM_BRANCH}\.\.\." <<< "${status}")"
|
||||
if [[ -n "${tracking_info}" ]]; then
|
||||
[[ "${tracking_info}" =~ .+\[gone\]$ ]] && local branch_gone="true"
|
||||
tracking_info=${tracking_info#\#\# ${SCM_BRANCH}...}
|
||||
@@ -245,7 +273,7 @@ function git_prompt_vars {
|
||||
[[ "${status}" =~ ${behind_re} ]] && SCM_BRANCH+=" ${SCM_GIT_BEHIND_CHAR}${BASH_REMATCH[1]}"
|
||||
|
||||
local stash_count="$(git stash list 2> /dev/null | wc -l | tr -d ' ')"
|
||||
[[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" {${stash_count}}"
|
||||
[[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_STASH_CHAR_PREFIX}${stash_count}${SCM_GIT_STASH_CHAR_SUFFIX}"
|
||||
|
||||
SCM_BRANCH+=${details}
|
||||
|
||||
@@ -348,7 +376,7 @@ function chruby_version_prompt {
|
||||
|
||||
ruby_version=$(ruby --version | awk '{print $1, $2;}') || return
|
||||
|
||||
if [[ ! $(chruby | grep '*') ]]; then
|
||||
if [[ ! $(chruby | grep '\*') ]]; then
|
||||
ruby_version="${ruby_version} (system)"
|
||||
fi
|
||||
echo -e "${CHRUBY_THEME_PROMPT_PREFIX}${ruby_version}${CHRUBY_THEME_PROMPT_SUFFIX}"
|
||||
@@ -411,25 +439,31 @@ function clock_prompt {
|
||||
fi
|
||||
}
|
||||
|
||||
function user_host_prompt {
|
||||
if [[ "${THEME_SHOW_USER_HOST}" = "true" ]]; then
|
||||
echo -e "${USER_HOST_THEME_PROMPT_PREFIX}\u@\h${USER_HOST_THEME_PROMPT_SUFFIX}"
|
||||
fi
|
||||
}
|
||||
|
||||
# backwards-compatibility
|
||||
function git_prompt_info {
|
||||
git_prompt_vars
|
||||
echo -e "$SCM_PREFIX$SCM_BRANCH$SCM_STATE$SCM_SUFFIX"
|
||||
echo -e "${SCM_PREFIX}${SCM_BRANCH}${SCM_STATE}${SCM_SUFFIX}"
|
||||
}
|
||||
|
||||
function svn_prompt_info {
|
||||
svn_prompt_vars
|
||||
echo -e "$SCM_PREFIX$SCM_BRANCH$SCM_STATE$SCM_SUFFIX"
|
||||
echo -e "${SCM_PREFIX}${SCM_BRANCH}${SCM_STATE}${SCM_SUFFIX}"
|
||||
}
|
||||
|
||||
function hg_prompt_info() {
|
||||
hg_prompt_vars
|
||||
echo -e "$SCM_PREFIX$SCM_BRANCH:${SCM_CHANGE#*:}$SCM_STATE$SCM_SUFFIX"
|
||||
echo -e "${SCM_PREFIX}${SCM_BRANCH}:${SCM_CHANGE#*:}${SCM_STATE}${SCM_SUFFIX}"
|
||||
}
|
||||
|
||||
function scm_char {
|
||||
scm_prompt_char
|
||||
echo -e "$SCM_CHAR"
|
||||
echo -e "${SCM_THEME_CHAR_PREFIX}${SCM_CHAR}${SCM_THEME_CHAR_SUFFIX}"
|
||||
}
|
||||
|
||||
function prompt_char {
|
||||
@@ -442,13 +476,17 @@ function battery_char {
|
||||
fi
|
||||
}
|
||||
|
||||
if [ ! -e $BASH_IT/plugins/enabled/battery.plugin.bash ]; then
|
||||
if ! _command_exists battery_charge ; then
|
||||
# if user has installed battery plugin, skip this...
|
||||
function battery_charge (){
|
||||
# no op
|
||||
echo -n
|
||||
}
|
||||
fi
|
||||
|
||||
# The battery_char function depends on the presence of the battery_percentage function.
|
||||
# If battery_percentage is not defined, then define battery_char as a no-op.
|
||||
if ! _command_exists battery_percentage ; then
|
||||
function battery_char (){
|
||||
# no op
|
||||
echo -n
|
||||
@@ -463,12 +501,40 @@ function aws_profile {
|
||||
fi
|
||||
}
|
||||
|
||||
function __check_precmd_conflict() {
|
||||
local f
|
||||
for f in "${precmd_functions[@]}"; do
|
||||
if [[ "${f}" == "${1}" ]]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
function safe_append_prompt_command {
|
||||
if [[ -n $1 ]] ; then
|
||||
case $PROMPT_COMMAND in
|
||||
*$1*) ;;
|
||||
"") PROMPT_COMMAND="$1";;
|
||||
*) PROMPT_COMMAND="$1;$PROMPT_COMMAND";;
|
||||
esac
|
||||
local prompt_re
|
||||
|
||||
if [ "${__bp_imported}" == "defined" ]; then
|
||||
# We are using bash-preexec
|
||||
if ! __check_precmd_conflict "${1}" ; then
|
||||
precmd_functions+=("${1}")
|
||||
fi
|
||||
else
|
||||
# Set OS dependent exact match regular expression
|
||||
if [[ ${OSTYPE} == darwin* ]]; then
|
||||
# macOS
|
||||
prompt_re="[[:<:]]${1}[[:>:]]"
|
||||
else
|
||||
# Linux, FreeBSD, etc.
|
||||
prompt_re="\<${1}\>"
|
||||
fi
|
||||
|
||||
if [[ ${PROMPT_COMMAND} =~ ${prompt_re} ]]; then
|
||||
return
|
||||
elif [[ -z ${PROMPT_COMMAND} ]]; then
|
||||
PROMPT_COMMAND="${1}"
|
||||
else
|
||||
PROMPT_COMMAND="${1};${PROMPT_COMMAND}"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Set term to 256color mode, if 256color is not supported, colors won't work properly
|
||||
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
|
||||
export TERM=gnome-256color
|
||||
elif infocmp xterm-256color >/dev/null 2>&1; then
|
||||
export TERM=xterm-256color
|
||||
fi
|
||||
|
||||
# Detect whether a rebbot is required
|
||||
# Detect whether a reboot is required
|
||||
function show_reboot_required() {
|
||||
if [ ! -z "$_bf_prompt_reboot_info" ]; then
|
||||
if [ -f /var/run/reboot-required ]; then
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
SCM_THEME_PROMPT_DIRTY=" ${red}✗"
|
||||
SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓"
|
||||
SCM_THEME_PROMPT_PREFIX=" |"
|
||||
SCM_THEME_PROMPT_PREFIX=" ${green}|"
|
||||
SCM_THEME_PROMPT_SUFFIX="${green}|"
|
||||
|
||||
GIT_THEME_PROMPT_DIRTY=" ${red}✗"
|
||||
@@ -23,7 +23,7 @@ __bobby_clock() {
|
||||
|
||||
function prompt_command() {
|
||||
#PS1="${bold_cyan}$(scm_char)${green}$(scm_prompt_info)${purple}$(ruby_version_prompt) ${yellow}\h ${reset_color}in ${green}\w ${reset_color}\n${green}→${reset_color} "
|
||||
PS1="\n$(battery_char) $(__bobby_clock)${yellow}$(ruby_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}→${reset_color} "
|
||||
PS1="\n$(battery_char) $(__bobby_clock)${yellow}$(ruby_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_prompt_char_info) ${green}→${reset_color} "
|
||||
}
|
||||
|
||||
THEME_SHOW_CLOCK_CHAR=${THEME_SHOW_CLOCK_CHAR:-"true"}
|
||||
|
||||
@@ -152,8 +152,10 @@ ___brainy_prompt_clock() {
|
||||
}
|
||||
|
||||
___brainy_prompt_battery() {
|
||||
[ ! -e $BASH_IT/plugins/enabled/battery.plugin.bash ] ||
|
||||
[ "${THEME_SHOW_BATTERY}" != "true" ] && return
|
||||
! _command_exists battery_percentage ||
|
||||
[ "${THEME_SHOW_BATTERY}" != "true" ] ||
|
||||
[ "$(battery_percentage)" = "no" ] && return
|
||||
|
||||
info=$(battery_percentage)
|
||||
color=$bold_green
|
||||
if [ "$info" -lt 50 ]; then
|
||||
@@ -162,7 +164,9 @@ ___brainy_prompt_battery() {
|
||||
color=$bold_red
|
||||
fi
|
||||
box="[|]"
|
||||
ac_adapter_connected && info+="+"
|
||||
ac_adapter_connected && charging="+"
|
||||
ac_adapter_disconnected && charging="-"
|
||||
info+=$charging
|
||||
[ "$info" == "100+" ] && info="AC"
|
||||
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
||||
}
|
||||
@@ -249,6 +253,8 @@ export RBFU_THEME_PROMPT_PREFIX=""
|
||||
export RBFU_THEME_PROMPT_SUFFIX=""
|
||||
export RVM_THEME_PROMPT_PREFIX=""
|
||||
export RVM_THEME_PROMPT_SUFFIX=""
|
||||
export VIRTUALENV_THEME_PROMPT_PREFIX=""
|
||||
export VIRTUALENV_THEME_PROMPT_SUFFIX=""
|
||||
|
||||
export SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}"
|
||||
export SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓${normal}"
|
||||
|
||||
@@ -189,7 +189,7 @@ yellow="\[\e[0;33m\]"
|
||||
blue="\[\e[0;34m\]"
|
||||
purple="\[\e[0;35m\]"
|
||||
cyan="\[\e[0;36m\]"
|
||||
white="\[\e[0;37;1m\]"
|
||||
white="\[\e[0;37m\]"
|
||||
orange="\[\e[0;91m\]"
|
||||
|
||||
bold_black="\[\e[30;1m\]"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Theme inspired on:
|
||||
# - Ronacher's dotfiles (mitsuhikos) - http://github.com/mitsuhiko/dotfiles/tree/master/bash/
|
||||
@@ -10,7 +10,7 @@
|
||||
# Screenshot: http://goo.gl/VCmX5
|
||||
# by Jesus de Mula <jesus@demula.name>
|
||||
|
||||
# For the real Monokai colors you should add these to your .XDefaults or
|
||||
# For the real Monokai colors you should add these to your .XDefaults or
|
||||
# terminal configuration:
|
||||
#! ----------------------------------------------------------- TERMINAL COLORS
|
||||
#! monokai - http://www.monokai.nl/blog/2006/07/15/textmate-color-theme/
|
||||
@@ -68,7 +68,7 @@ mitsuhikos_lastcommandfailed() {
|
||||
if [ $code != 0 ];
|
||||
then
|
||||
echo "${D_INTERMEDIATE_COLOR}exited ${D_CMDFAIL_COLOR}\
|
||||
$code ${D_DEFAULT_COLOR}"
|
||||
$code ${D_DEFAULT_COLOR}"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -78,13 +78,13 @@ demula_vcprompt() {
|
||||
then
|
||||
local D_VCPROMPT_FORMAT="on ${D_SCM_COLOR}%s${D_INTERMEDIATE_COLOR}:\
|
||||
${D_BRANCH_COLOR}%b %r ${D_CHANGES_COLOR}%m%u ${D_DEFAULT_COLOR}"
|
||||
$VCPROMPT_EXECUTABLE -f "$D_VCPROMPT_FORMAT"
|
||||
$VCPROMPT_EXECUTABLE -f "$D_VCPROMPT_FORMAT"
|
||||
fi
|
||||
}
|
||||
|
||||
# checks if the plugin is installed before calling battery_charge
|
||||
safe_battery_charge() {
|
||||
if [ -e "${BASH_IT}/plugins/enabled/battery.plugin.bash" ];
|
||||
if _command_exists battery_charge ;
|
||||
then
|
||||
battery_charge
|
||||
fi
|
||||
@@ -127,4 +127,3 @@ ${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}"
|
||||
|
||||
# Runs prompt (this bypasses bash_it $PROMPT setting)
|
||||
safe_append_prompt_command prompt
|
||||
|
||||
|
||||
64
themes/font/font.theme.bash
Normal file
64
themes/font/font.theme.bash
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# One line prompt showing the following configurable information
|
||||
# for git:
|
||||
# time (virtual_env) username@hostname pwd git_char|git_branch git_dirty_status|→
|
||||
#
|
||||
# The → arrow shows the exit status of the last command:
|
||||
# - bold green: 0 exit status
|
||||
# - bold red: non-zero exit status
|
||||
#
|
||||
# Example outside git repo:
|
||||
# 07:45:05 user@host ~ →
|
||||
#
|
||||
# Example inside clean git repo:
|
||||
# 07:45:05 user@host .bash_it ±|master|→
|
||||
#
|
||||
# Example inside dirty git repo:
|
||||
# 07:45:05 user@host .bash_it ±|master ✗|→
|
||||
#
|
||||
# Example with virtual environment:
|
||||
# 07:45:05 (venv) user@host ~ →
|
||||
#
|
||||
|
||||
SCM_NONE_CHAR=''
|
||||
SCM_THEME_PROMPT_DIRTY=" ${red}✗"
|
||||
SCM_THEME_PROMPT_CLEAN=""
|
||||
SCM_THEME_PROMPT_PREFIX="${green}|"
|
||||
SCM_THEME_PROMPT_SUFFIX="${green}|"
|
||||
SCM_GIT_SHOW_MINIMAL_INFO=true
|
||||
|
||||
CLOCK_THEME_PROMPT_PREFIX=''
|
||||
CLOCK_THEME_PROMPT_SUFFIX=' '
|
||||
THEME_SHOW_CLOCK=false
|
||||
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$bold_blue"}
|
||||
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%I:%M:%S"}
|
||||
|
||||
THEME_SHOW_USER_HOST=true
|
||||
USER_HOST_THEME_PROMPT_PREFIX="${bold_black}"
|
||||
USER_HOST_THEME_PROMPT_SUFFIX=" "
|
||||
|
||||
VIRTUALENV_THEME_PROMPT_PREFIX='('
|
||||
VIRTUALENV_THEME_PROMPT_SUFFIX=') '
|
||||
|
||||
function prompt_command() {
|
||||
# This needs to be first to save last command return code
|
||||
local RC="$?"
|
||||
|
||||
hostname="${bold_black}\u@\h"
|
||||
virtualenv="${white}$(virtualenv_prompt)"
|
||||
|
||||
# Set return status color
|
||||
if [[ ${RC} == 0 ]]; then
|
||||
ret_status="${bold_green}"
|
||||
else
|
||||
ret_status="${bold_red}"
|
||||
fi
|
||||
|
||||
# Append new history lines to history file
|
||||
history -a
|
||||
|
||||
PS1="$(clock_prompt)${virtualenv}$(user_host_prompt)${bold_cyan}\W $(scm_prompt_char_info)${ret_status}→ ${normal}"
|
||||
}
|
||||
|
||||
safe_append_prompt_command prompt_command
|
||||
@@ -52,7 +52,7 @@ function prompt_command() {
|
||||
fi
|
||||
|
||||
local wrap_char=""
|
||||
[[ ${#new_PS1} -gt $(($COLUMNS/1)) ]] && wrap_char="\n"
|
||||
[[ $COLUMNS && ${#new_PS1} > $(($COLUMNS/1)) ]] && wrap_char="\n"
|
||||
PS1="${new_PS1}${green}${wrap_char}→${reset_color} "
|
||||
}
|
||||
|
||||
|
||||
2
themes/liquidprompt/.gitignore
vendored
Normal file
2
themes/liquidprompt/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
liquidprompt
|
||||
|
||||
76
themes/liquidprompt/liquidprompt.theme.bash
Executable file
76
themes/liquidprompt/liquidprompt.theme.bash
Executable file
@@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env bash
|
||||
# Wrapper to use liquidprompt with bashit
|
||||
|
||||
targetdir="$BASH_IT/themes/liquidprompt/liquidprompt"
|
||||
gray="\[\e[1;90m\]"
|
||||
|
||||
cwd="$PWD"
|
||||
if cd "$targetdir" &>/dev/null && git rev-parse --is-inside-work-tree &>/dev/null; then
|
||||
true
|
||||
else
|
||||
git clone https://github.com/nojhan/liquidprompt.git "$targetdir" && \
|
||||
echo -e "Successfully cloned liquidprompt!\n More configuration in '$targetdir/liquid.theme'."
|
||||
fi
|
||||
cd "$cwd"
|
||||
|
||||
export LP_ENABLE_TIME=1
|
||||
export LP_HOSTNAME_ALWAYS=1
|
||||
export LP_USER_ALWAYS=1
|
||||
export LP_MARK_LOAD="📈 "
|
||||
export LP_BATTERY_THRESHOLD=${LP_BATTERY_THRESHOLD:-75}
|
||||
export LP_LOAD_THRESHOLD=${LP_LOAD_THRESHOLD:-60}
|
||||
export LP_TEMP_THRESHOLD=${LP_TEMP_THRESHOLD:-80}
|
||||
|
||||
|
||||
source "$targetdir/liquidprompt"
|
||||
prompt() { true; }
|
||||
export PS2=" ┃ "
|
||||
export LP_PS1_PREFIX="┌─"
|
||||
export LP_PS1_POSTFIX="\n└▪ "
|
||||
export LP_ENABLE_RUNTIME=0
|
||||
|
||||
_lp_git_branch()
|
||||
{
|
||||
(( LP_ENABLE_GIT )) || return
|
||||
|
||||
\git rev-parse --is-inside-work-tree >/dev/null 2>&1 || return
|
||||
|
||||
local branch
|
||||
# Recent versions of Git support the --short option for symbolic-ref, but
|
||||
# not 1.7.9 (Ubuntu 12.04)
|
||||
if branch="$(\git symbolic-ref -q HEAD)"; then
|
||||
_lp_escape "$(\git rev-parse --short=5 -q HEAD 2>/dev/null):${branch#refs/heads/}"
|
||||
else
|
||||
# In detached head state, use commit instead
|
||||
# No escape needed
|
||||
\git rev-parse --short -q HEAD 2>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
_lp_time() {
|
||||
if (( LP_ENABLE_TIME )) && (( ! LP_TIME_ANALOG )); then
|
||||
LP_TIME="${gray}$(date +%d-%H:%M)${normal}"
|
||||
else
|
||||
LP_TIME=""
|
||||
fi
|
||||
}
|
||||
|
||||
# Implementation using lm-sensors
|
||||
_lp_temp_sensors()
|
||||
{
|
||||
local -i i
|
||||
for i in $(sensors -u |
|
||||
sed -n 's/^ temp[0-9][0-9]*_input: \([0-9]*\)\..*$/\1/p'); do
|
||||
(( $i > ${temperature:-0} )) && (( $i != 127 )) && temperature=i
|
||||
done
|
||||
}
|
||||
|
||||
# Implementation using 'acpi -t'
|
||||
_lp_temp_acpi()
|
||||
{
|
||||
local -i i
|
||||
for i in $(LANG=C acpi -t |
|
||||
sed 's/.* \(-\?[0-9]*\)\.[0-9]* degrees C$/\1/p'); do
|
||||
(( $i > ${temperature:-0} )) && (( $i != 127 )) && temperature=i
|
||||
done
|
||||
}
|
||||
@@ -4,6 +4,8 @@ A colorful theme, where shows a lot information about your shell session.
|
||||
|
||||
**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.
|
||||
|
||||
**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
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
# Define this here so it can be used by all of the Powerline themes
|
||||
THEME_CHECK_SUDO=${THEME_CHECK_SUDO:=true}
|
||||
|
||||
function set_color {
|
||||
set +u
|
||||
if [[ "${1}" != "-" ]]; then
|
||||
fg="38;5;${1}"
|
||||
fi
|
||||
@@ -10,9 +14,16 @@ function set_color {
|
||||
}
|
||||
|
||||
function __powerline_user_info_prompt {
|
||||
local user_info=${USER}
|
||||
set +u
|
||||
local user_info=""
|
||||
local color=${USER_INFO_THEME_PROMPT_COLOR}
|
||||
|
||||
if [[ "${THEME_CHECK_SUDO}" = true ]]; then
|
||||
if sudo -n uptime 2>&1 | grep -q "load"; then
|
||||
color=${USER_INFO_THEME_PROMPT_COLOR_SUDO}
|
||||
fi
|
||||
fi
|
||||
|
||||
case "${POWERLINE_PROMPT_USER_INFO_MODE}" in
|
||||
"sudo")
|
||||
if sudo -n true >/dev/null 2>&1; then
|
||||
@@ -22,7 +33,7 @@ function __powerline_user_info_prompt {
|
||||
;;
|
||||
*)
|
||||
if [[ -n "${SSH_CLIENT}" ]]; then
|
||||
user_info="${USER_INFO_SSH_CHAR}${USER}"
|
||||
user_info="${USER_INFO_SSH_CHAR}${USER}@${SHORT_HOSTNAME:=$HOSTNAME}"
|
||||
else
|
||||
user_info="${USER}"
|
||||
fi
|
||||
@@ -34,9 +45,9 @@ function __powerline_user_info_prompt {
|
||||
function __powerline_ruby_prompt {
|
||||
local ruby_version=""
|
||||
|
||||
if command_exists rvm; then
|
||||
if _command_exists rvm; then
|
||||
ruby_version="$(rvm_version_prompt)"
|
||||
elif command_exists rbenv; then
|
||||
elif _command_exists rbenv; then
|
||||
ruby_version=$(rbenv_version_prompt)
|
||||
fi
|
||||
|
||||
@@ -44,6 +55,7 @@ function __powerline_ruby_prompt {
|
||||
}
|
||||
|
||||
function __powerline_python_venv_prompt {
|
||||
set +u
|
||||
local python_venv=""
|
||||
|
||||
if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then
|
||||
@@ -93,6 +105,10 @@ function __powerline_hostname_prompt {
|
||||
echo "$(hostname -s)|${HOST_THEME_PROMPT_COLOR}"
|
||||
}
|
||||
|
||||
function __powerline_wd_prompt {
|
||||
echo "\W|${CWD_THEME_PROMPT_COLOR}"
|
||||
}
|
||||
|
||||
function __powerline_clock_prompt {
|
||||
echo "$(date +"${THEME_CLOCK_FORMAT}")|${CLOCK_THEME_PROMPT_COLOR}"
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@ SCM_GIT_CHAR="${green}±${normal}"
|
||||
SCM_SVN_CHAR="${bold_cyan}⑆${normal}"
|
||||
SCM_HG_CHAR="${bold_red}☿${normal}"
|
||||
|
||||
VIRTUALENV_THEME_PROMPT_PREFIX="("
|
||||
VIRTUALENV_THEME_PROMPT_SUFFIX=")"
|
||||
|
||||
### TODO: openSUSE has already colors enabled, check if those differs from stock
|
||||
# LS colors, made with http://geoff.greer.fm/lscolors/
|
||||
# export LSCOLORS="Gxfxcxdxbxegedabagacad"
|
||||
@@ -33,9 +36,9 @@ pure_prompt() {
|
||||
|
||||
# make it work
|
||||
case $(id -u) in
|
||||
0) PS1="$ps_root@$ps_host$(scm_prompt):$ps_path$ps_root_mark"
|
||||
0) PS1="$(virtualenv_prompt)$ps_root@$ps_host$(scm_prompt):$ps_path$ps_root_mark"
|
||||
;;
|
||||
*) PS1="$ps_user@$ps_host$(scm_prompt):$ps_path$ps_user_mark"
|
||||
*) PS1="$(virtualenv_prompt)$ps_user@$ps_host$(scm_prompt):$ps_path$ps_user_mark"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
@@ -12,10 +12,11 @@ GIT_THEME_PROMPT_SUFFIX=" ${reset_color})"
|
||||
|
||||
STATUS_THEME_PROMPT_BAD="${bold_red}❯${reset_color}${normal} "
|
||||
STATUS_THEME_PROMPT_OK="${bold_green}❯${reset_color}${normal} "
|
||||
PURITY_THEME_PROMPT_COLOR="${PURITY_THEME_PROMPT_COLOR:=$blue}"
|
||||
|
||||
function prompt_command() {
|
||||
local ret_status="$( [ $? -eq 0 ] && echo -e "$STATUS_THEME_PROMPT_OK" || echo -e "$STATUS_THEME_PROMPT_BAD")"
|
||||
PS1="\n${blue}\w $(scm_prompt_info)\n${ret_status} "
|
||||
PS1="\n${PURITY_THEME_PROMPT_COLOR}\w $(scm_prompt_info)\n${ret_status} "
|
||||
}
|
||||
|
||||
safe_append_prompt_command prompt_command
|
||||
|
||||
@@ -117,7 +117,7 @@ ${D_BRANCH_COLOR}%b %r ${D_CHANGES_COLOR}%m%u ${D_DEFAULT_COLOR}"
|
||||
|
||||
# checks if the plugin is installed before calling battery_charge
|
||||
safe_battery_charge() {
|
||||
if [ -e "${BASH_IT}/plugins/enabled/battery.plugin.bash" ];
|
||||
if _command_exists battery_charge ;
|
||||
then
|
||||
battery_charge
|
||||
fi
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
# Screenshot: http://cloud.gf3.ca/M5rG
|
||||
# A big thanks to \amethyst on Freenode
|
||||
|
||||
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then export TERM=gnome-256color
|
||||
elif [[ $TERM != dumb ]] && infocmp xterm-256color >/dev/null 2>&1; then export TERM=xterm-256color
|
||||
fi
|
||||
|
||||
if tput setaf 1 &> /dev/null; then
|
||||
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
|
||||
MAGENTA=$(tput setaf 9)
|
||||
|
||||
Reference in New Issue
Block a user