add bash-it

This commit is contained in:
2022-05-05 22:20:02 +02:00
parent 6a62a35d0d
commit 43701f0590
490 changed files with 33047 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
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() {
local scm_prompt_info
scm_prompt_info="$(scm_prompt_info)"
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
@@ -0,0 +1,423 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# vim: ft=bash ts=2 sw=2 sts=2
#
# agnoster's Theme - https://gist.github.com/3712874
# A Powerline-inspired theme for BASH
#
# (Converted from ZSH theme by Kenny Root)
# https://gist.github.com/kruton/8345450
#
# Updated & fixed by Erik Selberg erik@selberg.org 1/14/17
# Tested on MacOSX, Ubuntu, Amazon Linux
# Bash v3 and v4
#
# # README
#
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://gist.github.com/1595572).
# I recommend: https://github.com/powerline/fonts.git
# > git clone https://github.com/powerline/fonts.git fonts
# > cd fonts
# > install.sh
# In addition, I recommend the
# [Solarized theme](https://github.com/altercation/solarized/) and, if you're
# using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app -
# it has significantly better color fidelity.
# Install:
# I recommend the following:
# $ cd home
# $ mkdir -p .bash/themes/agnoster-bash
# $ git clone https://github.com/speedenator/agnoster-bash.git .bash/themes/agnoster-bash
# then add the following to your .bashrc:
# export THEME=$HOME/.bash/themes/agnoster-bash/agnoster.bash
# if [[ -f $THEME ]]; then
# export DEFAULT_USER=`whoami`
# source $THEME
# fi
#
# # Goals
#
# The aim of this theme is to only show you *relevant* information. Like most
# prompts, it will only show git information when in a git working directory.
# However, it goes a step further: everything from the current user and
# hostname to whether the last call exited with an error to whether background
# jobs are running in this shell will all be displayed automatically when
# appropriate.
# Generally speaking, this script has limited support for right
# prompts (ala powerlevel9k on zsh), but it's pretty problematic in Bash.
# The general pattern is to write out the right prompt, hit \r, then
# write the left. This is problematic for the following reasons:
# - Doesn't properly resize dynamically when you resize the terminal
# - Changes to the prompt (like clearing and re-typing, super common) deletes the prompt
# - Getting the right alignment via columns / tput cols is pretty problematic (and is a bug in this version)
# - Bash prompt escapes (like \h or \w) don't get interpolated
#
# all in all, if you really, really want right-side prompts without a
# ton of work, recommend going to zsh for now. If you know how to fix this,
# would appreciate it!
# note: requires bash v4+... Mac users - you often have bash3.
# 'brew install bash' will set you free
PROMPT_DIRTRIM=2 # bash4 and above
######################################################################
DEBUG=0
debug() {
if [[ ${DEBUG} -ne 0 ]]; then
echo >&2 -e "$@"
fi
}
######################################################################
### Segment drawing
# A few utility functions to make it easy and re-usable to draw segmented prompts
CURRENT_BG='NONE'
CURRENT_RBG='NONE'
SEGMENT_SEPARATOR=''
RIGHT_SEPARATOR=''
LEFT_SUBSEG=''
RIGHT_SUBSEG=''
text_effect() {
case "$1" in
reset) echo 0 ;;
bold) echo 1 ;;
underline) echo 4 ;;
esac
}
# to add colors, see
# http://bitmote.com/index.php?post/2012/11/19/Using-ANSI-Color-Codes-to-Colorize-Your-Bash-Prompt-on-Linux
# under the "256 (8-bit) Colors" section, and follow the example for orange below
fg_color() {
case "$1" in
black) echo 30 ;;
red) echo 31 ;;
green) echo 32 ;;
yellow) echo 33 ;;
blue) echo 34 ;;
magenta) echo 35 ;;
cyan) echo 36 ;;
white) echo 37 ;;
orange) echo 38\;5\;166 ;;
esac
}
bg_color() {
case "$1" in
black) echo 40 ;;
red) echo 41 ;;
green) echo 42 ;;
yellow) echo 43 ;;
blue) echo 44 ;;
magenta) echo 45 ;;
cyan) echo 46 ;;
white) echo 47 ;;
orange) echo 48\;5\;166 ;;
esac
}
# TIL: declare is global not local, so best use a different name
# for codes (mycodes) as otherwise it'll clobber the original.
# this changes from BASH v3 to BASH v4.
ansi() {
local seq
declare -a mycodes=("${!1}")
debug "ansi: ${!1} all: $* aka " "${mycodes[@]}"
seq=""
for ((i = 0; i < ${#mycodes[@]}; i++)); do
if [[ -n $seq ]]; then
seq="${seq};"
fi
seq="${seq}${mycodes[$i]}"
done
debug "ansi debug:" '\\[\\033['"${seq}"'m\\]'
echo -ne '\[\033['"${seq}"'m\]'
# PR="$PR\[\033[${seq}m\]"
}
ansi_single() {
echo -ne '\[\033['"$1"'m\]'
}
# Begin a segment
# Takes two arguments, background and foreground. Both can be omitted,
# rendering default background/foreground.
prompt_segment() {
local bg fg
declare -a codes
debug "Prompting $1 $2 $3"
# if commented out from kruton's original... I'm not clear
# if it did anything, but it messed up things like
# prompt_status - Erik 1/14/17
# if [[ -z $1 || ( -z $2 && $2 != default ) ]]; then
codes=("${codes[@]}" "$(text_effect reset)")
# fi
if [[ -n $1 ]]; then
bg=$(bg_color "$1")
codes=("${codes[@]}" "$bg")
debug "Added $bg as background to codes"
fi
if [[ -n $2 ]]; then
fg=$(fg_color "$2")
codes=("${codes[@]}" "$fg")
debug "Added $fg as foreground to codes"
fi
debug "Codes: "
# declare -p codes
if [[ $CURRENT_BG != NONE && $1 != "$CURRENT_BG" ]]; then
declare -a intermediate=("$(fg_color $CURRENT_BG)" "$(bg_color "$1")")
debug "pre prompt " "$(ansi intermediate[@])"
PR="$PR $(ansi intermediate[@])$SEGMENT_SEPARATOR"
debug "post prompt " "$(ansi codes[@])"
PR="$PR$(ansi codes[@]) "
else
debug "no current BG, codes is " "${codes[@]}"
PR="$PR$(ansi codes[@]) "
fi
CURRENT_BG=$1
[[ -n $3 ]] && PR="$PR$3"
}
# End the prompt, closing any open segments
prompt_end() {
if [[ -n $CURRENT_BG ]]; then
declare -a codes=("$(text_effect reset)" "$(fg_color "$CURRENT_BG")")
PR="$PR $(ansi codes[@])$SEGMENT_SEPARATOR"
fi
declare -a reset=("$(text_effect reset)")
PR="$PR $(ansi reset[@])"
CURRENT_BG=''
}
### virtualenv prompt
prompt_virtualenv() {
if [[ -n $VIRTUAL_ENV ]]; then
color=cyan
prompt_segment $color "$PRIMARY_FG"
ve=$(basename "$VIRTUAL_ENV")
prompt_segment $color white "$ve"
fi
}
### Prompt components
# Each component will draw itself, and hide itself if no information needs to be shown
# Context: user@hostname (who am I and where am I)
prompt_context() {
local user="${USER:-${LOGNAME:?}}"
if [[ $user != "$DEFAULT_USER" || -n $SSH_CLIENT ]]; then
prompt_segment black default "$user@\h"
fi
}
# prints history followed by HH:MM, useful for remembering what
# we did previously
prompt_histdt() {
prompt_segment black default "\! [\A]"
}
git_status_dirty() {
dirty=$(git status -s 2> /dev/null | tail -n 1)
[[ -n $dirty ]] && echo " ●"
}
# Git: branch/detached head, dirty status
prompt_git() {
local ref dirty
if git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
ZSH_THEME_GIT_PROMPT_DIRTY='±'
dirty=$(git_status_dirty)
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="$(git show-ref --head -s --abbrev | head -n1 2> /dev/null)"
if [[ -n $dirty ]]; then
prompt_segment yellow black
else
prompt_segment green black
fi
PR="$PR${ref/refs\/heads\// }$dirty"
fi
}
# Dir: current working directory
prompt_dir() {
prompt_segment blue black '\w'
}
# Status:
# - was there an error
# - am I root
# - are there background jobs?
prompt_status() {
local symbols
symbols=()
[[ $RETVAL -ne 0 ]] && symbols+=("$(ansi_single "$(fg_color red)")")
[[ $UID -eq 0 ]] && symbols+=("$(ansi_single "$(fg_color yellow)")")
[[ $(jobs -l | wc -l) -gt 0 ]] && symbols+=("$(ansi_single "$(fg_color cyan)")")
[[ -n "${symbols[*]}" ]] && prompt_segment black default "${symbols[@]}"
}
######################################################################
#
# experimental right prompt stuff
# requires setting prompt_foo to use PRIGHT vs PR
# doesn't quite work per above
rightprompt() {
printf "%*s" $COLUMNS "$PRIGHT"
}
# quick right prompt I grabbed to test things.
__command_rprompt() {
local times=n=$COLUMNS tz
for tz in ZRH:Europe/Zurich PIT:US/Eastern \
MTV:US/Pacific TOK:Asia/Tokyo; do
[ "$n" -gt 40 ] || break
times="$times ${tz%%:*}\e[30;1m:\e[0;36;1m"
times="$times$(TZ=${tz#*:} date +%H:%M)\e[0m"
n=$(("$n" - 10))
done
[ -z "$times" ] || printf "%${n}s$times\\r" ''
}
# PROMPT_COMMAND=__command_rprompt
# this doens't wrap code in \[ \]
ansi_r() {
local seq
declare -a mycodes2=("${!1}")
debug "ansi: ${!1} all: $* aka " "${mycodes2[@]}"
seq=""
for ((i = 0; i < ${#mycodes2[@]}; i++)); do
if [[ -n $seq ]]; then
seq="${seq};"
fi
seq="${seq}${mycodes2[$i]}"
done
debug "ansi debug:" '\\[\\033['"${seq}"'m\\]'
echo -ne '\033['"${seq}"'m'
# PR="$PR\[\033[${seq}m\]"
}
# Begin a segment on the right
# Takes two arguments, background and foreground. Both can be omitted,
# rendering default background/foreground.
prompt_right_segment() {
local bg fg
declare -a codes
debug "Prompt right"
debug "Prompting $1 $2 $3"
# if commented out from kruton's original... I'm not clear
# if it did anything, but it messed up things like
# prompt_status - Erik 1/14/17
# if [[ -z $1 || ( -z $2 && $2 != default ) ]]; then
codes=("${codes[@]}" "$(text_effect reset)")
# fi
if [[ -n $1 ]]; then
bg=$(bg_color "$1")
codes=("${codes[@]}" "$bg")
debug "Added $bg as background to codes"
fi
if [[ -n $2 ]]; then
fg=$(fg_color "$2")
codes=("${codes[@]}" "$fg")
debug "Added $fg as foreground to codes"
fi
debug "Right Codes: "
# declare -p codes
# right always has a separator
# if [[ $CURRENT_RBG != NONE && $1 != $CURRENT_RBG ]]; then
# $CURRENT_RBG=
# fi
declare -a intermediate2=("$(fg_color "$1")" "$(bg_color $CURRENT_RBG)")
# PRIGHT="$PRIGHT---"
debug "pre prompt " "$(ansi_r intermediate2[@])"
PRIGHT="$PRIGHT$(ansi_r intermediate2[@])$RIGHT_SEPARATOR"
debug "post prompt " "$(ansi_r codes[@])"
PRIGHT="$PRIGHT$(ansi_r codes[@]) "
# else
# debug "no current BG, codes is $codes[@]"
# PRIGHT="$PRIGHT$(ansi codes[@]) "
# fi
CURRENT_RBG=$1
[[ -n $3 ]] && PRIGHT="$PRIGHT$3"
}
######################################################################
## Emacs prompt --- for dir tracking
# stick the following in your .emacs if you use this:
# (setq dirtrack-list '(".*DIR *\\([^ ]*\\) DIR" 1 nil))
# (defun dirtrack-filter-out-pwd-prompt (string)
# "dirtrack-mode doesn't remove the PWD match from the prompt. This does."
# ;; TODO: support dirtrack-mode's multiline regexp.
# (if (and (stringp string) (string-match (first dirtrack-list) string))
# (replace-match "" t t string 0)
# string))
# (add-hook 'shell-mode-hook
# #'(lambda ()
# (dirtrack-mode 1)
# (add-hook 'comint-preoutput-filter-functions
# 'dirtrack-filter-out-pwd-prompt t t)))
prompt_emacsdir() {
# no color or other setting... this will be deleted per above
PR="DIR \w DIR$PR"
}
######################################################################
## Main prompt
build_prompt() {
[[ -n ${AG_EMACS_DIR+x} ]] && prompt_emacsdir
prompt_status
#[[ -z ${AG_NO_HIST+x} ]] && prompt_histdt
[[ -z ${AG_NO_CONTEXT+x} ]] && prompt_context
prompt_virtualenv
prompt_dir
prompt_git
prompt_end
}
# from orig...
# export PS1='$(ansi_single $(text_effect reset)) $(build_prompt) '
# this doesn't work... new model: create a prompt via a PR variable and
# use that.
set_bash_prompt() {
RETVAL=$?
PR=""
PRIGHT=""
CURRENT_BG=NONE
PR="$(ansi_single "$(text_effect reset)")"
build_prompt
# uncomment below to use right prompt
# PS1='\[$(tput sc; printf "%*s" $COLUMNS "$PRIGHT"; tput rc)\]'$PR
PS1=$PR
}
PROMPT_COMMAND=set_bash_prompt
+324
View File
@@ -0,0 +1,324 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# 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 ##
#############
function ____atomic_top_left_parse() {
local ifs_old="${IFS}"
local IFS="|"
read -r -a args <<< "$@"
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+=""
}
function ____atomic_top_right_parse() {
local ifs_old="${IFS}"
local IFS="|"
read -r -a args <<< "$@"
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))
}
function ____atomic_bottom_parse() {
local ifs_old="${IFS}"
local IFS="|"
read -r -a args <<< "$@"
IFS="${ifs_old}"
_BOTTOM+="${args[0]?}${args[1]?${FUNCNAME[0]}}"
[[ ${#args[1]} -gt 0 ]] && _BOTTOM+=" "
}
function ____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}"
}
function ____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 ##
##############
function ___atomic_prompt_user_info() {
local color="${white?}" box
local info="${IYellow}\u${IRed}@${IGreen}\h"
box="${normal?}${LineA?}\$([[ \$? != 0 ]] && echo \"${BIWhite?}[${IRed?}${SX?}${BIWhite?}]${normal?}${Line?}\")${Line?}${BIWhite?}[|${BIWhite?}]${normal?}${Line?}"
printf "%s|%s|%s|%s" "${color}" "${info}" "${white?}" "${box}"
}
function ___atomic_prompt_dir() {
local color="${IRed?}"
local box="[|]${normal}"
local info="\w"
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white?}" "${box}"
}
function ___atomic_prompt_scm() {
[[ "${THEME_SHOW_SCM:-}" != "true" ]] && return
local color="${bold_green?}" box info
box="${Line?}[${IWhite?}$(scm_char)] "
info="$(scm_prompt_info)"
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white?}" "${box}"
}
function ___atomic_prompt_python() {
[[ "${THEME_SHOW_PYTHON:-}" != "true" ]] && return
local color="${bold_yellow?}"
local box="[|]" info
info="$(python_version_prompt)"
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_blue?}" "${box}"
}
function ___atomic_prompt_ruby() {
[[ "${THEME_SHOW_RUBY:-}" != "true" ]] && return
local color="${bold_white?}"
local box="[|]" info
info="rb-$(ruby_version_prompt)"
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_red?}" "${box}"
}
function ___atomic_prompt_todo() {
[[ "${THEME_SHOW_TODO:-}" != "true" ||
-z "$(which todo.sh)" ]] && return
local color="${bold_white?}"
local box="[|]" info
info="t:$(todo.sh ls | grep -E "TODO: [0-9]+ of ([0-9]+)" | awk '{ print $4 }')"
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_green?}" "${box}"
}
function ___atomic_prompt_clock() {
[[ "${THEME_SHOW_CLOCK:-}" != "true" ]] && return
local color="${THEME_CLOCK_COLOR:-}"
local box="[|]" info
info="$(date +"${THEME_CLOCK_FORMAT}")"
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white?}" "${box}"
}
function ___atomic_prompt_battery() {
local batp box info
! _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}"
}
function ___atomic_prompt_exitcode() {
[[ "${THEME_SHOW_EXITCODE:-}" != "true" ]] && return
local color="${bold_purple?}"
[[ "${exitcode?}" -ne 0 ]] && printf "%s|%s" "${color}" "${exitcode}"
}
function ___atomic_prompt_char() {
local color="${white?}"
local prompt_char="${__ATOMIC_PROMPT_CHAR_PS1?}"
if [[ "${THEME_SHOW_SUDO:-}" == "true" ]]; then
if sudo -vn 1> /dev/null 2>&1; then
prompt_char="${__ATOMIC_PROMPT_CHAR_PS1_SUDO?}"
fi
fi
printf "%s|%s" "${color}" "${prompt_char}"
}
#########
## cli ##
#########
function __atomic_show() {
local _seg="${1?}"
export "THEME_SHOW_${_seg}"=true
}
function __atomic_hide() {
local _seg="${1?}"
export "THEME_SHOW_${_seg}"=false
}
function _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 | hide)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "${segments}" -- "${cur}"))
return 0
;;
esac
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "${actions}" -- "${cur}"))
return 0
}
function atomic() {
local action="${1?}"
shift
local segs=("${@?}")
local func
case "${action}" in
show)
func=__atomic_show
;;
hide)
func=__atomic_hide
;;
*)
_log_error "${FUNCNAME[0]}: unknown action '${action}'"
return 1
;;
esac
for seg in "${segs[@]}"; do
seg="$(printf "%s" "${seg}" | tr '[:lower:]' '[:upper:]')"
"${func}" "${seg}"
done
}
complete -F _atomic_completion atomic
###############
## Variables ##
###############
SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX=""
RBENV_THEME_PROMPT_PREFIX=""
RBENV_THEME_PROMPT_SUFFIX=""
RBFU_THEME_PROMPT_PREFIX=""
RBFU_THEME_PROMPT_SUFFIX=""
RVM_THEME_PROMPT_PREFIX=""
RVM_THEME_PROMPT_SUFFIX=""
SCM_THEME_PROMPT_DIRTY=" ${bold_red}${normal}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}${normal}"
: "${THEME_SHOW_SUDO:="true"}"
: "${THEME_SHOW_SCM:="true"}"
: "${THEME_SHOW_RUBY:="false"}"
: "${THEME_SHOW_PYTHON:="false"}"
: "${THEME_SHOW_CLOCK:="true"}"
: "${THEME_SHOW_TODO:="false"}"
: "${THEME_SHOW_BATTERY:="true"}"
: "${THEME_SHOW_EXITCODE:="false"}"
: "${THEME_CLOCK_COLOR:=${BICyan?}}"
: "${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:="user_info dir scm"}"
: "${___ATOMIC_TOP_RIGHT:="exitcode python ruby todo clock battery"}"
: "${___ATOMIC_BOTTOM:="char"}"
############
## Prompt ##
############
function __atomic_ps1() {
printf "%s%s%s" "$(____atomic_top)" "$(____atomic_bottom)" "${normal?}"
}
function __atomic_ps2() {
color="${bold_white?}"
printf "%s%s%s" "${color}" "${__ATOMIC_PROMPT_CHAR_PS2?} " "${normal?}"
}
function _atomic_prompt() {
exitcode="$?"
PS1="$(__atomic_ps1)"
PS2="$(__atomic_ps2)"
}
safe_append_prompt_command _atomic_prompt
+38
View File
@@ -0,0 +1,38 @@
# shellcheck shell=bash
# Axin Bash Prompt, inspired by theme "Sexy" and "Bobby"
# thanks to them
if tput setaf 1 &> /dev/null; then
if [[ $(tput colors) -ge 256 ]] 2> /dev/null; then
MAGENTA=$(tput setaf 9)
ORANGE=$(tput setaf 172)
GREEN=$(tput setaf 190)
PURPLE=$(tput setaf 141)
WHITE=$(tput setaf 0)
else
MAGENTA=$(tput setaf 5)
ORANGE=$(tput setaf 4)
GREEN=$(tput setaf 2)
PURPLE=$(tput setaf 1)
WHITE=$(tput setaf 7)
fi
BOLD=$(tput bold)
RESET=$(tput sgr0)
else
MAGENTA="\033[1;31m"
ORANGE="\033[1;33m"
GREEN="\033[1;32m"
PURPLE="\033[1;35m"
WHITE="\033[1;37m"
BOLD=""
RESET="\033[m"
fi
function prompt_command() {
PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]@ \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\[$SCM_THEME_PROMPT_PREFIX\]$(clock_prompt) \[$PURPLE\]$(scm_prompt_info) \n\$ \[$RESET\]"
}
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"${white}"}
safe_append_prompt_command prompt_command
+27
View File
@@ -0,0 +1,27 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
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?}|"
RVM_THEME_PROMPT_PREFIX="|"
RVM_THEME_PROMPT_SUFFIX="|"
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} "
local virtualenv_prompt scm_prompt_info
virtualenv_prompt="$(virtualenv_prompt)"
scm_prompt_info="$(scm_prompt_info)"
PS1="\n${cyan?}\h:${virtualenv_prompt} ${reset_color?} ${yellow?}\w ${green?}${scm_prompt_info}\n${reset_color?}"
}
safe_append_prompt_command prompt_command
+203
View File
@@ -0,0 +1,203 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# Prompt defaut configuration
BARBUK_PROMPT=${BARBUK_PROMPT:="git-uptream-remote-logo ssh path scm python_venv ruby node terraform cloud duration exit"}
# Theme custom glyphs
# SCM
SCM_GIT_CHAR_GITLAB=${BARBUK_GITLAB_CHAR:=' '}
SCM_GIT_CHAR_BITBUCKET=${BARBUK_BITBUCKET_CHAR:=' '}
SCM_GIT_CHAR_GITHUB=${BARBUK_GITHUB_CHAR:=' '}
SCM_GIT_CHAR_DEFAULT=${BARBUK_GIT_DEFAULT_CHAR:=' '}
SCM_GIT_CHAR_ICON_BRANCH=${BARBUK_GIT_BRANCH_ICON:=''}
SCM_HG_CHAR=${BARBUK_HG_CHAR:='☿ '}
SCM_SVN_CHAR=${BARBUK_SVN_CHAR:='⑆ '}
# Exit code
EXIT_CODE_ICON=${BARBUK_EXIT_CODE_ICON:=' '}
# Programming and tools
PYTHON_VENV_CHAR=${BARBUK_PYTHON_VENV_CHAR:=' '}
RUBY_CHAR=${BARBUK_RUBY_CHAR:=' '}
NODE_CHAR=${BARBUK_NODE_CHAR:=' '}
TERRAFORM_CHAR=${BARBUK_TERRAFORM_CHAR:="t "}
# Cloud
AWS_PROFILE_CHAR=${BARBUK_AWS_PROFILE_CHAR:=" aws "}
SCALEWAY_PROFILE_CHAR=${BARBUK_SCALEWAY_PROFILE_CHAR:=" scw "}
GCLOUD_CHAR=${BARBUK_GCLOUD_CHAR:=" google "}
# Command duration
COMMAND_DURATION_MIN_SECONDS=${COMMAND_DURATION_MIN_SECONDS:-1}
# Ssh user and hostname display
SSH_INFO=${BARBUK_SSH_INFO:=true}
HOST_INFO=${BARBUK_HOST_INFO:=long}
# Bash-it default glyphs customization
SCM_NONE_CHAR=
SCM_THEME_PROMPT_DIRTY=" ${bold_red?}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green?}"
SCM_THEME_PROMPT_PREFIX="|"
SCM_THEME_PROMPT_SUFFIX="${green?}| "
SCM_GIT_BEHIND_CHAR="${bold_red?}${normal?}"
SCM_GIT_AHEAD_CHAR="${bold_green?}${normal?}"
SCM_GIT_UNTRACKED_CHAR="⌀"
SCM_GIT_UNSTAGED_CHAR="${bold_yellow?}${normal?}"
SCM_GIT_STAGED_CHAR="${bold_green?}+${normal?}"
GIT_THEME_PROMPT_DIRTY=" ${bold_red?}"
GIT_THEME_PROMPT_CLEAN=" ${bold_green?}"
GIT_THEME_PROMPT_PREFIX="${cyan?}"
GIT_THEME_PROMPT_SUFFIX="${cyan?}"
SCM_THEME_BRANCH_TRACK_PREFIX="${normal?}${cyan?}"
SCM_THEME_CURRENT_USER_PREFFIX='  '
SCM_GIT_SHOW_CURRENT_USER=false
NVM_THEME_PROMPT_PREFIX=''
NVM_THEME_PROMPT_SUFFIX=''
RVM_THEME_PROMPT_PREFIX=''
RVM_THEME_PROMPT_SUFFIX=''
RBENV_THEME_PROMPT_PREFIX=' '
RBENV_THEME_PROMPT_SUFFIX=''
RBFU_THEME_PROMPT_PREFIX=''
RBFU_THEME_PROMPT_SUFFIX=''
function __git-uptream-remote-logo_prompt() {
[[ "$(_git-upstream)" == "" ]] && SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT"
local remote remote_domain
remote=$(_git-upstream-remote)
remote_domain=$(git config --get remote."$remote".url | awk -F'[@:.]' '{print $2}')
# remove // suffix for https:// url
remote_domain=${remote_domain//\//}
case $remote_domain in
github) SCM_GIT_CHAR="$SCM_GIT_CHAR_GITHUB" ;;
gitlab) SCM_GIT_CHAR="$SCM_GIT_CHAR_GITLAB" ;;
bitbucket) SCM_GIT_CHAR="$SCM_GIT_CHAR_BITBUCKET" ;;
*) SCM_GIT_CHAR="$SCM_GIT_CHAR_DEFAULT" ;;
esac
echo "${purple?}$(scm_char)"
}
function git_prompt_info() {
git_prompt_vars
echo -e "on $SCM_GIT_CHAR_ICON_BRANCH $SCM_PREFIX$SCM_BRANCH$SCM_STATE$SCM_GIT_AHEAD$SCM_GIT_BEHIND$SCM_GIT_STASH$SCM_SUFFIX "
}
function __exit_prompt() {
if [[ "$exit_code" -ne 0 ]]; then
echo "${purple?}${EXIT_CODE_ICON}${yellow?}${exit_code}${bold_orange?} "
else
echo "${bold_green}"
fi
}
function __aws_profile_prompt() {
if [[ -n "${AWS_PROFILE}" ]]; then
echo -n "${bold_purple?}${AWS_PROFILE_CHAR}${normal?}${AWS_PROFILE} "
fi
}
function __scaleway_profile_prompt() {
if [[ -n "${SCW_PROFILE}" ]]; then
echo -n "${bold_purple?}${SCALEWAY_PROFILE_CHAR}${normal?}${SCW_PROFILE} "
fi
}
function __gcloud_prompt() {
local active_gcloud_account=""
active_gcloud_account="$(active_gcloud_account_prompt)"
[[ -n "${active_gcloud_account}" ]] && echo "${bold_purple?}${GCLOUD_CHAR}${normal?}${active_gcloud_account} "
}
function __cloud_prompt() {
__aws_profile_prompt
__scaleway_profile_prompt
__gcloud_prompt
}
function __terraform_prompt() {
local terraform_workspace=""
if [ -d .terraform ]; then
terraform_workspace="$(terraform_workspace_prompt)"
[[ -n "${terraform_workspace}" ]] && echo "${bold_purple?}${TERRAFORM_CHAR}${normal?}${terraform_workspace} "
fi
}
function __node_prompt() {
local node_version=""
node_version="$(node_version_prompt)"
[[ -n "${node_version}" ]] && echo "${bold_purple?}${NODE_CHAR}${normal?}${node_version} "
}
function __ruby_prompt() {
local ruby_version=""
ruby_version="$(ruby_version_prompt)"
[[ -n "${ruby_version}" ]] && echo "${bold_purple?}${RUBY_CHAR}${normal?}${ruby_version} "
}
function __ssh_prompt() {
# Detect ssh
if [[ -n "${SSH_CONNECTION}" ]] && [ "$SSH_INFO" = true ]; then
if [ "$HOST_INFO" = long ]; then
host="\H"
else
host="\h"
fi
echo "${bold_blue?}\u${bold_orange?}@${cyan?}$host ${bold_orange?}in "
fi
}
function __python_venv_prompt() {
# Detect python venv
if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then
echo "${bold_purple?}$PYTHON_VENV_CHAR${normal?}${CONDA_DEFAULT_ENV} "
elif [[ -n "${VIRTUAL_ENV}" ]]; then
echo "${bold_purple?}$PYTHON_VENV_CHAR${normal?}$(basename "${VIRTUAL_ENV}") "
fi
}
function __path_prompt() {
local dir_color=${green?}
# Detect root shell
if [ "$(whoami)" = root ]; then
dir_color=${red?}
fi
echo "${dir_color}\w${normal} "
}
function __scm_prompt() {
scm_prompt_info
}
function __duration_prompt() {
[[ -n "$command_duration" ]] && echo "${command_duration} "
}
function __prompt-command() {
exit_code="$?"
command_duration=$(_command_duration)
local wrap_char
# Generate prompt
PS1="\n "
for segment in $BARBUK_PROMPT; do
local info
info="$(__"${segment}"_prompt)"
[[ -n "${info}" ]] && PS1+="${info}"
done
# Cut prompt when it's too long
if [[ ${#PS1} -gt $((COLUMNS * 2)) ]]; then
wrap_char="\n"
fi
PS1="${PS1}${wrap_char}${normal} "
}
safe_append_prompt_command __prompt-command
@@ -0,0 +1 @@
../../docs/themes-list/barbuk.rst
+585
View File
@@ -0,0 +1,585 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# Colors for listing files, using default color scheme.
# To customize color scheme by theme, check out https://geoff.greer.fm/lscolors/
export CLICOLOR LSCOLORS LS_COLORS
CLOCK_CHAR_THEME_PROMPT_PREFIX=''
CLOCK_CHAR_THEME_PROMPT_SUFFIX=''
CLOCK_THEME_PROMPT_PREFIX=''
CLOCK_THEME_PROMPT_SUFFIX=''
THEME_PROMPT_HOST='\h'
SCM=
: "${SCM_CHECK:=true}"
SCM_THEME_PROMPT_DIRTY=' ✗'
SCM_THEME_PROMPT_CLEAN=' ✓'
SCM_THEME_PROMPT_PREFIX=' |'
SCM_THEME_PROMPT_SUFFIX='|'
SCM_THEME_BRANCH_PREFIX=''
SCM_THEME_TAG_PREFIX='tag:'
SCM_THEME_DETACHED_PREFIX='detached:'
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=''
# Define this here so it can be used by all of the themes
: "${THEME_CHECK_SUDO:=false}"
: "${THEME_BATTERY_PERCENTAGE_CHECK:=true}"
: "${SCM_GIT_SHOW_DETAILS:=true}"
: "${SCM_GIT_SHOW_REMOTE_INFO:=auto}"
: "${SCM_GIT_IGNORE_UNTRACKED:=false}"
: "${SCM_GIT_SHOW_CURRENT_USER:=false}"
: "${SCM_GIT_SHOW_MINIMAL_INFO:=false}"
: "${SCM_GIT_SHOW_STASH_INFO:=true}"
: "${SCM_GIT_SHOW_COMMIT_COUNT:=true}"
: "${SCM_GIT_USE_GITSTATUS:=false}"
: "${SCM_GIT_GITSTATUS_RAN:=false}"
SCM_GIT='git'
SCM_GIT_CHAR='±'
SCM_GIT_DETACHED_CHAR='⌿'
SCM_GIT_AHEAD_CHAR="↑"
SCM_GIT_BEHIND_CHAR="↓"
SCM_GIT_AHEAD_BEHIND_PREFIX_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_P4='p4'
SCM_P4_CHAR='⌛'
SCM_P4_CHANGES_CHAR='C:'
SCM_P4_DEFAULT_CHAR='D:'
SCM_P4_OPENED_CHAR='O:'
SCM_HG='hg'
SCM_HG_CHAR='☿'
SCM_SVN='svn'
SCM_SVN_CHAR='⑆'
SCM_NONE='NONE'
SCM_NONE_CHAR='○'
NVM_THEME_PROMPT_PREFIX=' |'
NVM_THEME_PROMPT_SUFFIX='|'
RVM_THEME_PROMPT_PREFIX=' |'
RVM_THEME_PROMPT_SUFFIX='|'
: "${THEME_SHOW_RUBY_PROMPT:=true}"
: "${THEME_SHOW_USER_HOST:=false}"
USER_HOST_THEME_PROMPT_PREFIX=''
USER_HOST_THEME_PROMPT_SUFFIX=''
VIRTUALENV_THEME_PROMPT_PREFIX=' |'
VIRTUALENV_THEME_PROMPT_SUFFIX='|'
RBENV_THEME_PROMPT_PREFIX=' |'
RBENV_THEME_PROMPT_SUFFIX='|'
RBFU_THEME_PROMPT_PREFIX=' |'
RBFU_THEME_PROMPT_SUFFIX='|'
: "${GIT_EXE:=${SCM_GIT?}}"
: "${HG_EXE:=${SCM_HG?}}"
: "${SVN_EXE:=${SCM_SVN?}}"
: "${P4_EXE:=${SCM_P4?}}"
function _bash_it_appearance_scm_init() {
GIT_EXE="$(type -P "${SCM_GIT:-git}" || true)"
HG_EXE="$(type -P "${SCM_HG:-hg}" || true)"
SVN_EXE="$(type -P "${SCM_SVN:-svn}" || true)"
P4_EXE="$(type -P "${SCM_P4:-p4}" || true)"
# Check for broken SVN exe that is caused by some versions of Xcode.
# See https://github.com/Bash-it/bash-it/issues/1612 for more details.
if [[ -x "${SVN_EXE-}" && -x "${SVN_EXE%/svn}/xcrun" ]]; then
if ! "${SVN_EXE}" --version > /dev/null 2>&1; then
# Unset the SVN exe variable so that SVN commands are avoided.
SVN_EXE=""
fi
fi
return 0
}
_bash_it_library_finalize_hook+=('_bash_it_appearance_scm_init')
function scm() {
if [[ "${SCM_CHECK:-true}" == "false" ]]; then
SCM="${SCM_NONE-NONE}"
elif [[ -x "${GIT_EXE-}" ]] && _bash-it-find-in-ancestor '.git' > /dev/null; then
SCM="${SCM_GIT?}"
elif [[ -x "${HG_EXE-}" ]] && _bash-it-find-in-ancestor '.hg' > /dev/null; then
SCM="${SCM_HG?}"
elif [[ -x "${SVN_EXE-}" ]] && _bash-it-find-in-ancestor '.svn' > /dev/null; then
SCM="${SCM_SVN?}"
elif [[ -x "${P4_EXE-}" && -n "$(p4 set P4CLIENT 2> /dev/null)" ]]; then
SCM="${SCM_P4?}"
else
SCM="${SCM_NONE-NONE}"
fi
}
function scm_prompt() {
local format="${SCM_PROMPT_FORMAT-"[%s%s]"}"
local scm_char scm_prompt_info
scm_char="$(scm_char)"
scm_prompt_info="$(scm_prompt_info)"
if [[ "${scm_char}" != "${SCM_NONE_CHAR:-}" ]]; then
# shellcheck disable=2059
printf "${format}" "${scm_char}" "${scm_prompt_info}"
fi
}
function scm_prompt_char() {
if [[ -z "${SCM:-}" ]]; then
scm
fi
case ${SCM?} in
"${SCM_GIT?}")
SCM_CHAR="${SCM_GIT_CHAR?}"
;;
"${SCM_HG?}")
SCM_CHAR="${SCM_HG_CHAR?}"
;;
"${SCM_SVN?}")
SCM_CHAR="${SCM_SVN_CHAR?}"
;;
"${SCM_P4?}")
SCM_CHAR="${SCM_P4_CHAR?}"
;;
*)
SCM_CHAR="${SCM_NONE_CHAR:-}"
;;
esac
}
function scm_prompt_vars() {
scm
scm_prompt_char
SCM_DIRTY=0
SCM_STATE=''
local prompt_vars="${SCM}_prompt_vars"
_is_function "${prompt_vars}" && "${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() {
local prompt_info
SCM_DIRTY=0
SCM_STATE=''
case ${SCM?} in
"${SCM_GIT?}")
if [[ ${SCM_GIT_SHOW_MINIMAL_INFO:-false} == "true" ]]; then
# user requests minimal git status information
prompt_info="${SCM}_prompt_minimal_info"
else
# more detailed git status
prompt_info="${SCM}_prompt_info"
fi
;;
*)
# TODO: consider adding minimal status information for hg and svn
prompt_info="${SCM}_prompt_info"
;;
esac
_is_function "${prompt_info}" && "${prompt_info}"
}
function terraform_workspace_prompt() {
if _command_exists terraform; then
if [[ -d .terraform ]]; then
terraform workspace show 2> /dev/null
fi
fi
}
function active_gcloud_account_prompt() {
if _command_exists gcloud; then
gcloud config list account --format "value(core.account)" 2> /dev/null
fi
}
function git_prompt_minimal_info() {
SCM_STATE="${SCM_THEME_PROMPT_CLEAN?}"
_git-hide-status && return
SCM_BRANCH="${SCM_THEME_BRANCH_PREFIX-}\$(_git-friendly-ref)"
if [[ -n "$(_git-status | tail -n1)" ]]; then
SCM_DIRTY=1
SCM_STATE="${SCM_THEME_PROMPT_DIRTY?}"
fi
# Output the git prompt
SCM_PREFIX="${SCM_THEME_PROMPT_PREFIX-}"
SCM_SUFFIX="${SCM_THEME_PROMPT_SUFFIX-}"
echo -ne "${SCM_PREFIX}${SCM_BRANCH}${SCM_STATE}${SCM_SUFFIX}"
}
function git_prompt_vars() {
if [[ "${SCM_GIT_USE_GITSTATUS:-false}" != "false" ]] && _command_exists gitstatus_query && gitstatus_query && [[ "${VCS_STATUS_RESULT:-}" == "ok-sync" ]]; then
# we can use faster gitstatus
# use this variable in githelpers and below to choose gitstatus output
SCM_GIT_GITSTATUS_RAN=true
else
SCM_GIT_GITSTATUS_RAN=false
fi
if _git-branch &> /dev/null; then
SCM_GIT_DETACHED="false"
SCM_BRANCH="${SCM_THEME_BRANCH_PREFIX}\$(_git-friendly-ref)$(_git-remote-info)"
else
SCM_GIT_DETACHED="true"
local detached_prefix
if _git-tag &> /dev/null; then
detached_prefix="${SCM_THEME_TAG_PREFIX}"
else
detached_prefix="${SCM_THEME_DETACHED_PREFIX}"
fi
SCM_BRANCH="${detached_prefix}\$(_git-friendly-ref)"
fi
if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]]; then
commits_behind="${VCS_STATUS_COMMITS_BEHIND?}"
commits_ahead="${VCS_STATUS_COMMITS_AHEAD?}"
else
IFS=$'\t' read -r commits_behind commits_ahead <<< "$(_git-upstream-behind-ahead)"
fi
if [[ "${commits_ahead}" -gt 0 ]]; then
SCM_BRANCH+="${SCM_GIT_AHEAD_BEHIND_PREFIX_CHAR}${SCM_GIT_AHEAD_CHAR}"
[[ "${SCM_GIT_SHOW_COMMIT_COUNT}" == "true" ]] && SCM_BRANCH+="${commits_ahead}"
fi
if [[ "${commits_behind}" -gt 0 ]]; then
SCM_BRANCH+="${SCM_GIT_AHEAD_BEHIND_PREFIX_CHAR}${SCM_GIT_BEHIND_CHAR}"
[[ "${SCM_GIT_SHOW_COMMIT_COUNT}" == "true" ]] && SCM_BRANCH+="${commits_behind}"
fi
if [[ "${SCM_GIT_SHOW_STASH_INFO}" == "true" ]]; then
local stash_count
if [[ "${SCM_GIT_GITSTATUS_RAN}" == "true" ]]; then
stash_count="${VCS_STATUS_STASHES?}"
else
stash_count="$(git stash list 2> /dev/null | wc -l | tr -d ' ')"
fi
[[ "${stash_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_STASH_CHAR_PREFIX}${stash_count}${SCM_GIT_STASH_CHAR_SUFFIX}"
fi
SCM_STATE="${GIT_THEME_PROMPT_CLEAN:-${SCM_THEME_PROMPT_CLEAN:-}}"
if ! _git-hide-status; then
if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]]; then
untracked_count="${VCS_STATUS_NUM_UNTRACKED?}"
unstaged_count="${VCS_STATUS_NUM_UNSTAGED?}"
staged_count="${VCS_STATUS_NUM_STAGED?}"
else
IFS=$'\t' read -r untracked_count unstaged_count staged_count < <(_git-status-counts)
fi
if [[ "${untracked_count}" -gt 0 || "${unstaged_count}" -gt 0 || "${staged_count}" -gt 0 ]]; then
SCM_DIRTY=1
if [[ "${SCM_GIT_SHOW_DETAILS}" == "true" ]]; then
[[ "${staged_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_STAGED_CHAR}${staged_count}" && SCM_DIRTY=3
[[ "${unstaged_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_UNSTAGED_CHAR}${unstaged_count}" && SCM_DIRTY=2
[[ "${untracked_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_GIT_UNTRACKED_CHAR}${untracked_count}" && SCM_DIRTY=1
fi
SCM_STATE="${GIT_THEME_PROMPT_DIRTY:-${SCM_THEME_PROMPT_DIRTY?}}"
fi
fi
# no if for gitstatus here, user extraction is not supported by it
[[ "${SCM_GIT_SHOW_CURRENT_USER}" == "true" ]] && SCM_BRANCH+="$(git_user_info)"
SCM_PREFIX="${GIT_THEME_PROMPT_PREFIX:-${SCM_THEME_PROMPT_PREFIX-}}"
SCM_SUFFIX="${GIT_THEME_PROMPT_SUFFIX:-${SCM_THEME_PROMPT_SUFFIX-}}"
SCM_CHANGE=$(_git-short-sha 2> /dev/null || true)
}
function p4_prompt_vars() {
local opened_count non_default_changes default_count \
add_file_count edit_file_count delete_file_count
IFS=$'\t' read -r \
opened_count non_default_changes default_count \
add_file_count edit_file_count delete_file_count \
< <(_p4-opened-counts)
if [[ "${opened_count}" -gt 0 ]]; then
SCM_DIRTY=1
SCM_STATE="${SCM_THEME_PROMPT_DIRTY?}"
[[ "${opened_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_P4_OPENED_CHAR?}${opened_count}"
[[ "${non_default_changes}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_P4_CHANGES_CHAR?}${non_default_changes}"
[[ "${default_count}" -gt 0 ]] && SCM_BRANCH+=" ${SCM_P4_DEFAULT_CHAR?}${default_count}"
else
SCM_DIRTY=0
SCM_STATE="${SCM_THEME_PROMPT_CLEAN?}"
fi
SCM_PREFIX="${P4_THEME_PROMPT_PREFIX:-${SCM_THEME_PROMPT_PREFIX-}}"
SCM_SUFFIX="${P4_THEME_PROMPT_SUFFIX:-${SCM_THEME_PROMPT_SUFFIX-}}"
}
function svn_prompt_vars() {
if [[ -n "$(svn status | head -c1 2> /dev/null)" ]]; then
SCM_DIRTY=1
SCM_STATE="${SVN_THEME_PROMPT_DIRTY:-${SCM_THEME_PROMPT_DIRTY?}}"
else
SCM_DIRTY=0
SCM_STATE="${SVN_THEME_PROMPT_CLEAN:-${SCM_THEME_PROMPT_CLEAN?}}"
fi
SCM_PREFIX="${SVN_THEME_PROMPT_PREFIX:-${SCM_THEME_PROMPT_PREFIX-}}"
SCM_SUFFIX="${SVN_THEME_PROMPT_SUFFIX:-${SCM_THEME_PROMPT_SUFFIX-}}"
SCM_BRANCH="$(svn info --show-item=url 2> /dev/null | awk -F/ '{ for (i=0; i<=NF; i++) { if ($i == "branches" || $i == "tags" ) { print $(i+1); break }; if ($i == "trunk") { print $i; break } } }')" || return
SCM_CHANGE="$(svn info --show-item=revision 2> /dev/null)"
}
function hg_prompt_vars() {
local hg_root bookmark
if [[ -n $(hg status 2> /dev/null) ]]; then
SCM_DIRTY=1
SCM_STATE="${HG_THEME_PROMPT_DIRTY:-${SCM_THEME_PROMPT_DIRTY?}}"
else
SCM_DIRTY=0
SCM_STATE="${HG_THEME_PROMPT_CLEAN:-${SCM_THEME_PROMPT_CLEAN?}}"
fi
SCM_PREFIX="${HG_THEME_PROMPT_PREFIX:-${SCM_THEME_PROMPT_PREFIX-}}"
SCM_SUFFIX="${HG_THEME_PROMPT_SUFFIX:-${SCM_THEME_PROMPT_SUFFIX-}}"
hg_root="$(_bash-it-find-in-ancestor ".hg")/.hg"
if [[ -f "$hg_root/branch" ]]; then
# Mercurial holds it's current branch in .hg/branch file
SCM_BRANCH=$(< "${hg_root}/branch")
bookmark="${hg_root}/bookmarks.current"
[[ -f "${bookmark}" ]] && SCM_BRANCH+=:$(< "${bookmark}")
else
SCM_BRANCH=$(hg summary 2> /dev/null | grep branch: | awk '{print $2}')
fi
if [[ -f "$hg_root/dirstate" ]]; then
# Mercurial holds various information about the working directory in .hg/dirstate file. More on http://mercurial.selenic.com/wiki/DirState
SCM_CHANGE=$(hexdump -vn 10 -e '1/1 "%02x"' "$hg_root/dirstate" | cut -c-12)
else
SCM_CHANGE=$(hg summary 2> /dev/null | grep parent: | awk '{print $2}')
fi
}
function nvm_version_prompt() {
local node
if _is_function nvm; then
node=$(nvm current 2> /dev/null)
[[ "${node}" == "system" ]] && return
echo -ne "${NVM_THEME_PROMPT_PREFIX-}${node}${NVM_THEME_PROMPT_SUFFIX-}"
fi
}
function node_version_prompt() {
nvm_version_prompt
}
function rvm_version_prompt() {
if _command_exists rvm; then
rvm="$(rvm-prompt)" || return
if [[ -n "$rvm" ]]; then
echo -ne "${RVM_THEME_PROMPT_PREFIX-}${rvm}${RVM_THEME_PROMPT_SUFFIX-}"
fi
fi
}
function rbenv_version_prompt() {
if _command_exists rbenv; then
rbenv=$(rbenv version-name) || return
rbenv commands | grep -q gemset && gemset=$(rbenv gemset active 2> /dev/null) && rbenv="$rbenv@${gemset%% *}"
if [[ "$rbenv" != "system" ]]; then
echo -ne "${RBENV_THEME_PROMPT_PREFIX-}${rbenv}${RBENV_THEME_PROMPT_SUFFIX-}"
fi
fi
}
function rbfu_version_prompt() {
if [[ -n "${RBFU_RUBY_VERSION:-}" ]]; then
echo -ne "${RBFU_THEME_PROMPT_PREFIX-}${RBFU_RUBY_VERSION}${RBFU_THEME_PROMPT_SUFFIX-}"
fi
}
function chruby_version_prompt() {
if _is_function chruby; then
if _is_function chruby_auto; then
chruby_auto
fi
ruby_version=$(ruby --version | awk '{print $1, $2;}') || return
if ! chruby | grep -q '\*'; then
ruby_version="${ruby_version} (system)"
fi
echo -ne "${CHRUBY_THEME_PROMPT_PREFIX-}${ruby_version}${CHRUBY_THEME_PROMPT_SUFFIX-}"
fi
}
function ruby_version_prompt() {
if [[ "${THEME_SHOW_RUBY_PROMPT:-}" == "true" ]]; then
rbfu_version_prompt
rbenv_version_prompt
rvm_version_prompt
chruby_version_prompt
fi
}
function k8s_context_prompt() {
kubectl config current-context 2> /dev/null
}
function k8s_namespace_prompt() {
kubectl config view --minify --output 'jsonpath={..namespace}' 2> /dev/null
}
function virtualenv_prompt() {
local virtualenv
if [[ -n "${VIRTUAL_ENV:-}" ]]; then
virtualenv="${VIRTUAL_ENV##*/}"
echo -ne "${VIRTUALENV_THEME_PROMPT_PREFIX-}${virtualenv}${VIRTUALENV_THEME_PROMPT_SUFFIX-}"
fi
}
function condaenv_prompt() {
if [[ -n "${CONDA_DEFAULT_ENV:-}" ]]; then
echo -ne "${CONDAENV_THEME_PROMPT_PREFIX-}${CONDA_DEFAULT_ENV}${CONDAENV_THEME_PROMPT_SUFFIX-}"
fi
}
function py_interp_prompt() {
local py_version
py_version="$(python --version 2>&1 | awk 'NR==1{print "py-"$2;}')" || return
echo -ne "${PYTHON_THEME_PROMPT_PREFIX-}${py_version}${PYTHON_THEME_PROMPT_SUFFIX-}"
}
function python_version_prompt() {
virtualenv_prompt
condaenv_prompt
py_interp_prompt
}
function git_user_info() {
local current_user
# support two or more initials, set by 'git pair' plugin
current_user="$(git config user.initials | sed 's% %+%')"
# if `user.initials` weren't set, attempt to extract initials from `user.name`
[[ -z "${current_user}" ]] && current_user=$(printf "%s" "$(for word in $(git config user.name | PERLIO=:utf8 perl -pe '$_=lc'); do printf "%s" "${word:0:1}"; done)")
[[ -n "${current_user}" ]] && printf "%s" "${SCM_THEME_CURRENT_USER_PREFFIX-}${current_user}${SCM_THEME_CURRENT_USER_SUFFIX-}"
}
function clock_char() {
local clock_char clock_char_color show_clock_char
clock_char="${THEME_CLOCK_CHAR:-}"
clock_char_color="${THEME_CLOCK_CHAR_COLOR:-${normal:-}}"
show_clock_char="${THEME_SHOW_CLOCK_CHAR:-"true"}"
if [[ "${show_clock_char}" == "true" ]]; then
echo -ne "${clock_char_color}${CLOCK_CHAR_THEME_PROMPT_PREFIX-}${clock_char}${CLOCK_CHAR_THEME_PROMPT_SUFFIX-}"
fi
}
function clock_prompt() {
local clock_color="${THEME_CLOCK_COLOR:-${normal?}}"
local clock_format="${THEME_CLOCK_FORMAT:-"%H:%M:%S"}"
local show_clock="${THEME_SHOW_CLOCK:-${THEME_CLOCK_CHECK:-true}}"
local clock_string="\D{${clock_format}}"
if [[ "${show_clock}" == "true" ]]; then
echo -ne "${clock_color}${CLOCK_THEME_PROMPT_PREFIX-}${clock_string}${CLOCK_THEME_PROMPT_SUFFIX-}"
fi
}
function user_host_prompt() {
if [[ "${THEME_SHOW_USER_HOST:-false}" == "true" ]]; then
echo -ne "${USER_HOST_THEME_PROMPT_PREFIX-}\u@${THEME_PROMPT_HOST:-\h}${USER_HOST_THEME_PROMPT_SUFFIX-}"
fi
}
# backwards-compatibility
function git_prompt_info() {
_git-hide-status && return
git_prompt_vars
echo -ne "${SCM_PREFIX?}${SCM_BRANCH?}${SCM_STATE?}${SCM_SUFFIX?}"
}
function p4_prompt_info() {
p4_prompt_vars
echo -ne "${SCM_PREFIX?}${SCM_BRANCH?}:${SCM_CHANGE?}${SCM_STATE?}${SCM_SUFFIX?}"
}
function svn_prompt_info() {
svn_prompt_vars
echo -ne "${SCM_PREFIX?}${SCM_BRANCH?}${SCM_STATE?}${SCM_SUFFIX?}"
}
function hg_prompt_info() {
hg_prompt_vars
echo -ne "${SCM_PREFIX?}${SCM_BRANCH?}:${SCM_CHANGE#*:}${SCM_STATE?}${SCM_SUFFIX?}"
}
function scm_char() {
scm_prompt_char
echo -ne "${SCM_THEME_CHAR_PREFIX?}${SCM_CHAR?}${SCM_THEME_CHAR_SUFFIX?}"
}
function prompt_char() {
scm_char
}
function battery_char() {
# The battery_char function depends on the presence of the battery_percentage function.
if [[ "${THEME_BATTERY_PERCENTAGE_CHECK}" == true ]] && _command_exists battery_percentage; then
echo -ne "${bold_red?}$(battery_percentage)%"
else
false
fi
}
if ! _command_exists battery_charge; then
# if user has installed battery plugin, skip this...
function battery_charge() {
: # no op
}
fi
function aws_profile() {
if [[ -n "${AWS_DEFAULT_PROFILE:-}" ]]; then
echo -ne "${AWS_DEFAULT_PROFILE}"
else
echo -ne "default"
fi
}
function _save-and-reload-history() {
local autosave="${1:-${HISTORY_AUTOSAVE:-0}}"
[[ ${autosave} -eq 1 ]] && local HISTCONTROL="${HISTCONTROL:-}${HISTCONTROL:+:}autoshare"
_bash-it-history-auto-save && _bash-it-history-auto-load
}
@@ -0,0 +1,86 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck disable=SC2154 #TODO: fix these all.
# Detect whether a reboot is required
function show_reboot_required() {
if [ -n "$_bf_prompt_reboot_info" ]; then
if [ -f /var/run/reboot-required ]; then
printf "Reboot required!"
fi
fi
}
# Set different host color for local and remote sessions
function set_host_color() {
# Detect if connection is through SSH
if [[ -n $SSH_CLIENT ]]; then
printf '%s' "${lime_yellow}"
else
printf '%s' "${light_orange}"
fi
}
# Set different username color for users and root
function set_user_color() {
case $(id -u) in
0)
printf '%s' "${red}"
;;
*)
printf '%s' "${cyan}"
;;
esac
}
# Define custom colors we need
# non-printable bytes in PS1 need to be contained within \[ \].
# Otherwise, bash will count them in the length of the prompt
function set_custom_colors() {
dark_grey="\[$(tput setaf 8)\]"
light_grey="\[$(tput setaf 248)\]"
light_orange="\[$(tput setaf 172)\]"
bright_yellow="\[$(tput setaf 220)\]"
lime_yellow="\[$(tput setaf 190)\]"
powder_blue="\[$(tput setaf 153)\]"
}
__ps_time() {
printf '%s' "$(clock_prompt)${normal}\n"
}
function prompt_command() {
ps_reboot="${bright_yellow}$(show_reboot_required)${normal}\n"
ps_username="$(set_user_color)\u${normal}"
ps_uh_separator="${dark_grey}@${normal}"
ps_hostname="$(set_host_color)\h${normal}"
ps_path="${yellow}\w${normal}"
ps_scm_prompt="${light_grey}$(scm_prompt)"
ps_user_mark="${normal} ${normal}"
ps_user_input="${normal}"
# Set prompt
PS1="$ps_reboot$(__ps_time)$ps_username$ps_uh_separator$ps_hostname $ps_path $ps_scm_prompt$ps_user_mark$ps_user_input"
}
# Initialize custom colors
set_custom_colors
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$dark_grey"}
# scm theming
SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX=""
SCM_THEME_PROMPT_DIRTY=" ${bold_red}${light_grey}"
SCM_THEME_PROMPT_CLEAN=" ${green}${light_grey}"
SCM_GIT_CHAR="${green}±${light_grey}"
SCM_SVN_CHAR="${bold_cyan}${light_grey}"
SCM_HG_CHAR="${bold_red}${light_grey}"
safe_append_prompt_command prompt_command
+26
View File
@@ -0,0 +1,26 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
SCM_THEME_PROMPT_PREFIX=" ${yellow?}"
SCM_THEME_PROMPT_SUFFIX="${reset_color?}"
VIRTUALENV_THEME_PROMPT_PREFIX=" ${cyan?}"
VIRTUALENV_THEME_PROMPT_SUFFIX="${reset_color?}"
bold="\[\e[1m\]"
if [[ ${UID} -eq 0 ]]; then
user_host="${bold_red?}\u@\h${normal?}${reset_color?}"
else
user_host="${bold_green?}\u@\h${normal?}${reset_color?}"
fi
function prompt_command() {
local current_dir=" ${bold_blue?}\w${normal?}${reset_color?}"
local virtualenv_prompt scm_prompt_info
virtualenv_prompt="$(virtualenv_prompt)"
scm_prompt_info="$(scm_prompt_info)"
PS1="╭─${user_host?}${current_dir}${virtualenv_prompt}${scm_prompt_info}\n╰─${bold?}\\$ ${normal?}"
}
safe_append_prompt_command prompt_command
@@ -0,0 +1,26 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
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?}|"
CONDAENV_THEME_PROMPT_SUFFIX="|"
function prompt_command() {
PS1="\n${yellow?}$(python_version_prompt) " # Name of virtual env followed by python version
PS1+="${purple?}\h "
PS1+="${reset_color?}in "
PS1+="${green?}\w\n"
PS1+="${bold_cyan?}$(scm_char)"
PS1+="${green?}$(scm_prompt_info) "
PS1+="${green?}${reset_color?} "
}
safe_append_prompt_command prompt_command
+40
View File
@@ -0,0 +1,40 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
SCM_THEME_PROMPT_DIRTY=" ${red?}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green?}"
SCM_THEME_PROMPT_PREFIX=" ${green?}|"
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?}|"
RVM_THEME_PROMPT_PREFIX="|"
RVM_THEME_PROMPT_SUFFIX="|"
function __bobby_clock() {
printf '%s' "$(clock_prompt) "
if [[ "${THEME_SHOW_CLOCK_CHAR:-}" == "true" ]]; then
printf '%s' "$(clock_char) "
fi
}
function prompt_command() {
PS1="\n$(battery_char) $(__bobby_clock)"
PS1+="${yellow?}$(ruby_version_prompt) "
PS1+="${purple?}\h "
PS1+="${reset_color?}in "
PS1+="${green?}\w\n"
PS1+="${bold_cyan?}$(scm_prompt_char_info) "
PS1+="${green?}${reset_color?} "
}
: "${THEME_SHOW_CLOCK_CHAR:="true"}"
: "${THEME_CLOCK_CHAR_COLOR:=${red?}}"
: "${THEME_CLOCK_COLOR:=${bold_cyan?}}"
: "${THEME_CLOCK_FORMAT:="%Y-%m-%d %H:%M:%S"}"
safe_append_prompt_command prompt_command
+303
View File
@@ -0,0 +1,303 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck disable=SC2154 #TODO: fix these all.
# Brainy Bash Prompt for Bash-it
# by MunifTanjim
#############
## Parsers ##
#############
____brainy_top_left_parse() {
ifs_old="${IFS}"
IFS="|"
read -r -a args <<< "$@"
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+=" "
}
____brainy_top_right_parse() {
ifs_old="${IFS}"
IFS="|"
read -r -a args <<< "$@"
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))
}
____brainy_bottom_parse() {
ifs_old="${IFS}"
IFS="|"
read -r -a args <<< "$@"
IFS="${ifs_old}"
_BOTTOM+="${args[0]}${args[1]}"
[ ${#args[1]} -gt 0 ] && _BOTTOM+=" "
}
____brainy_top() {
_TOP_LEFT=""
_TOP_RIGHT=""
__TOP_RIGHT_LEN=0
__SEG_AT_RIGHT=0
for seg in ${___BRAINY_TOP_LEFT}; do
info="$(___brainy_prompt_"${seg}")"
[ -n "${info}" ] && ____brainy_top_left_parse "${info}"
done
___cursor_right="\033[500C"
_TOP_LEFT+="${___cursor_right}"
for seg in ${___BRAINY_TOP_RIGHT}; do
info="$(___brainy_prompt_"${seg}")"
[ -n "${info}" ] && ____brainy_top_right_parse "${info}"
done
[ $__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}"
}
____brainy_bottom() {
_BOTTOM=""
for seg in $___BRAINY_BOTTOM; do
info="$(___brainy_prompt_"${seg}")"
[ -n "${info}" ] && ____brainy_bottom_parse "${info}"
done
printf "\n%s" "${_BOTTOM}"
}
##############
## Segments ##
##############
___brainy_prompt_user_info() {
color=$bold_blue
if [ "${THEME_SHOW_SUDO}" == "true" ]; then
if sudo -vn 1> /dev/null 2>&1; 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=$bold_yellow
box="[|]"
info="\w"
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
}
___brainy_prompt_scm() {
[ "${THEME_SHOW_SCM}" != "true" ] && return
color=$bold_green
box="$(scm_char) "
info="$(scm_prompt_info)"
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
}
___brainy_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}"
}
___brainy_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}"
}
___brainy_prompt_todo() {
[ "${THEME_SHOW_TODO}" != "true" ] \
|| [ -z "$(which todo.sh)" ] && return
color=$bold_white
box="[|]"
info="t:$(todo.sh ls | grep -E "TODO: [0-9]+ of ([0-9]+)" | awk '{ print $4 }')"
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_green}" "${box}"
}
___brainy_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_purple}" "${box}"
}
___brainy_prompt_battery() {
! _command_exists battery_percentage \
|| [ "${THEME_SHOW_BATTERY}" != "true" ] \
|| [ "$(battery_percentage)" = "no" ] && return
info=$(battery_percentage)
color=$bold_green
if [ "$info" -lt 50 ]; then
color=$bold_yellow
elif [ "$info" -lt 25 ]; then
color=$bold_red
fi
box="[|]"
ac_adapter_connected && charging="+"
ac_adapter_disconnected && charging="-"
info+=$charging
[ "$info" == "100+" ] && info="AC"
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
}
___brainy_prompt_exitcode() {
[ "${THEME_SHOW_EXITCODE}" != "true" ] && return
color=$bold_purple
[ "$exitcode" -ne 0 ] && printf "%s|%s" "${color}" "${exitcode}"
}
___brainy_prompt_char() {
color=$bold_white
prompt_char="${__BRAINY_PROMPT_CHAR_PS1}"
printf "%s|%s" "${color}" "${prompt_char}"
}
#########
## cli ##
#########
__brainy_show() {
typeset _seg=${1:-}
shift
export "THEME_SHOW_${_seg}"=true
}
__brainy_hide() {
typeset _seg=${1:-}
shift
export "THEME_SHOW_${_seg}"=false
}
_brainy_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 | hide)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "${segments}" -- "${cur}"))
return 0
;;
esac
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "${actions}" -- "${cur}"))
return 0
}
brainy() {
typeset action=${1:-}
shift
typeset segs=${*:-}
typeset func
case $action in
show)
func=__brainy_show
;;
hide)
func=__brainy_hide
;;
esac
for seg in ${segs}; do
seg=$(printf "%s" "${seg}" | tr '[:lower:]' '[:upper:]')
$func "${seg}"
done
}
complete -F _brainy_completion brainy
###############
## 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 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}"
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:-"false"}
THEME_SHOW_EXITCODE=${THEME_SHOW_EXITCODE:-"true"}
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:-">"}
__BRAINY_PROMPT_CHAR_PS2=${THEME_PROMPT_CHAR_PS2:-"\\"}
___BRAINY_TOP_LEFT=${___BRAINY_TOP_LEFT:-"user_info dir scm"}
___BRAINY_TOP_RIGHT=${___BRAINY_TOP_RIGHT:-"python ruby todo clock battery"}
___BRAINY_BOTTOM=${___BRAINY_BOTTOM:-"exitcode char"}
############
## Prompt ##
############
__brainy_ps1() {
printf "%s%s%s" "$(____brainy_top)" "$(____brainy_bottom)" "${normal}"
}
__brainy_ps2() {
color=$bold_white
printf "%s%s%s" "${color}" "${__BRAINY_PROMPT_CHAR_PS2} " "${normal}"
}
_brainy_prompt() {
exitcode="$?"
PS1="$(__brainy_ps1)"
PS2="$(__brainy_ps2)"
}
safe_append_prompt_command _brainy_prompt
@@ -0,0 +1,31 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX=""
SCM_THEME_PROMPT_DIRTY=" ${bold_red?}${normal?}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green?}${normal?}"
SCM_GIT_CHAR="${bold_green?}±${normal?}"
SCM_SVN_CHAR="${bold_cyan?}${normal?}"
SCM_HG_CHAR="${bold_red?}${normal?}"
function is_vim_shell() {
if [[ -n "${VIMRUNTIME:-}" ]]; then
echo "[${cyan?}vim shell${normal?}]"
fi
}
function prompt() {
local SCM_PROMPT_FORMAT=' %s (%s)' clock_prompt battery_charge scm_prompt is_vim_shell
clock_prompt="$(clock_prompt)"
battery_charge="$(battery_charge)"
scm_prompt="$(scm_prompt)"
is_vim_shell="$(is_vim_shell)"
PS1="${white?}${background_blue?} \u${normal?}${background_blue?}@${red?}${background_blue?}\h ${clock_prompt} ${reset_color?}${normal?} ${battery_charge}\n${bold_black?}${background_white?} \w ${normal?}${scm_prompt}${is_vim_shell}\n${white?}>${normal?} "
}
: "${THEME_CLOCK_COLOR:=${blue?}${background_white?}}"
: "${THEME_CLOCK_FORMAT:=" %H:%M:%S"}"
safe_append_prompt_command prompt
+14
View File
@@ -0,0 +1,14 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
function prompt_command() {
local clock_prompt scm_prompt_info
clock_prompt="$(clock_prompt)"
scm_prompt_info="$(scm_prompt_info)"
PS1="${green?}\u@\h ${clock_prompt} ${reset_color?}${white?}\w${reset_color?}${scm_prompt_info}${blue?}${bold_blue?} ${reset_color?} ${normal?}"
}
: "${THEME_CLOCK_COLOR:=${blue?}}"
: "${THEME_CLOCK_FORMAT:="%I:%M:%S"}"
safe_append_prompt_command prompt_command
+19
View File
@@ -0,0 +1,19 @@
# git theming
SCM_THEME_PROMPT_PREFIX="${bold_blue}(${yellow}"
SCM_THEME_PROMPT_SUFFIX="${bold_blue})${reset_color} "
SCM_THEME_PROMPT_CLEAN=""
SCM_THEME_PROMPT_DIRTY="${bold_red}"
# LS colors, made with http://geoff.greer.fm/lscolors/
export LSCOLORS="Gxfxcxdxbxegedabagacad"
export LS_COLORS='no=00:fi=00:di=01;34:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;31:*.rpm=00;31:*.deb=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:'
function prompt_command() {
if [ "$(whoami)" = root ]; then no_color=$red; else no_color=$white; fi
PS1="${no_color}\u${reset_color}:${blue}\W/${reset_color} $(scm_prompt_info)${normal}$ "
}
safe_append_prompt_command prompt_command
@@ -0,0 +1,25 @@
# shellcheck shell=bash
SCM_THEME_PROMPT_PREFIX="${SCM_THEME_PROMPT_SUFFIX:-}"
SCM_THEME_PROMPT_DIRTY="${bold_red?}${normal?}"
SCM_THEME_PROMPT_CLEAN="${bold_green?}${normal?}"
SCM_GIT_CHAR="${green?}±${normal?}"
function mark_prompt() {
echo "${green?}\$${normal?}"
}
function user_host_path_prompt() {
ps_user="${green?}\u${normal?}";
ps_host="${blue?}\H${normal?}";
ps_path="${yellow?}\w${normal?}";
echo "${ps_user?}@${ps_host?}:${ps_path?}"
}
function prompt() {
local SCM_PROMPT_FORMAT=' [%s%s]'
PS1="$(user_host_path_prompt)$(virtualenv_prompt)$(scm_prompt) $(mark_prompt) "
}
safe_append_prompt_command '_save-and-reload-history 1'
safe_append_prompt_command prompt
@@ -0,0 +1,39 @@
# ------------------------------------------------------------------#
# FILE: cooperkid.zsh-theme #
# BY: Alfredo Bejarano #
# BASED ON: Mr Briggs by Matt Brigg (matt@mattbriggs.net) #
# ------------------------------------------------------------------#
SCM_THEME_PROMPT_DIRTY="${red}${reset_color}"
SCM_THEME_PROMPT_AHEAD="${yellow}${reset_color}"
SCM_THEME_PROMPT_CLEAN="${green}${reset_color}"
SCM_THEME_PROMPT_PREFIX=" "
SCM_THEME_PROMPT_SUFFIX=""
GIT_SHA_PREFIX="${blue}"
GIT_SHA_SUFFIX="${reset_color}"
function rvm_version_prompt {
if which rvm &> /dev/null; then
rvm=$(rvm-prompt) || return
if [ -n "$rvm" ]; then
echo -e "$rvm"
fi
fi
}
function git_short_sha() {
SHA=$(git rev-parse --short HEAD 2> /dev/null) && echo "$GIT_SHA_PREFIX$SHA$GIT_SHA_SUFFIX"
}
function prompt() {
local return_status=""
local ruby="${red}$(ruby_version_prompt)${reset_color}"
local user_host="${green}\h @ \w${reset_color}"
local git_branch="$(git_short_sha)${cyan}$(scm_prompt_info)${reset_color}"
local prompt_symbol=' '
local prompt_char="${purple}>_${reset_color} "
PS1="\n${user_host}${prompt_symbol}${ruby} ${git_branch} ${return_status}\n${prompt_char}"
}
safe_append_prompt_command prompt
@@ -0,0 +1,79 @@
#!/usr/bin/env bash
# Emoji-based theme to display source control management and
# virtual environment info beside the ordinary bash prompt.
# Theme inspired by:
# - Naming your Terminal tabs in OSX Lion - http://thelucid.com/2012/01/04/naming-your-terminal-tabs-in-osx-lion/
# - Bash_it sexy theme
# Demo:
# ┌ⓔ virtualenv 💁user @ 💻 host in 📁directory on 🌿branch {1} ↑1 ↓1 +1 •1 ⌀1 ✗
# └❯ cd .bash-it/themes/cupcake
# virtualenv prompts
VIRTUALENV_CHAR="ⓔ "
VIRTUALENV_THEME_PROMPT_PREFIX=""
VIRTUALENV_THEME_PROMPT_SUFFIX=""
# SCM prompts
SCM_NONE_CHAR=""
SCM_GIT_CHAR="[±] "
SCM_GIT_BEHIND_CHAR="${red}${normal}"
SCM_GIT_AHEAD_CHAR="${bold_green}${normal}"
SCM_GIT_UNTRACKED_CHAR="⌀"
SCM_GIT_UNSTAGED_CHAR="${bold_yellow}${normal}"
SCM_GIT_STAGED_CHAR="${bold_green}+${normal}"
SCM_THEME_PROMPT_DIRTY=""
SCM_THEME_PROMPT_CLEAN=""
SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX=""
# Git status prompts
GIT_THEME_PROMPT_DIRTY=" ${red}${normal}"
GIT_THEME_PROMPT_CLEAN=" ${bold_green}${normal}"
GIT_THEME_PROMPT_PREFIX=""
GIT_THEME_PROMPT_SUFFIX=""
# ICONS =======================================================================
icon_start="┌"
icon_user="💁 "
icon_host=" @ 💻 "
icon_directory=" in 📁 "
icon_branch="🌿"
icon_end="└❯ "
# extra spaces ensure legiblity in prompt
# FUNCTIONS ===================================================================
# Display virtual environment info
function virtualenv_prompt {
if [[ -n "$VIRTUAL_ENV" ]]; then
virtualenv=`basename "$VIRTUAL_ENV"`
echo -e "$VIRTUALENV_CHAR$virtualenv "
fi
}
# Rename tab
function tabname {
printf "\e]1;$1\a"
}
# Rename window
function winname {
printf "\e]2;$1\a"
}
# PROMPT OUTPUT ===============================================================
# Displays the current prompt
function prompt_command() {
PS1="\n${icon_start}$(virtualenv_prompt)${icon_user}${bold_red}\u${normal}${icon_host}${bold_cyan}\h${normal}${icon_directory}${bold_purple}\W${normal}\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on ${icon_branch} \")${white}$(scm_prompt_info)${normal}\n${icon_end}"
PS2="${icon_end}"
}
# Runs prompt (this bypasses bash_it $PROMPT setting)
safe_append_prompt_command prompt_command
+128
View File
@@ -0,0 +1,128 @@
#!/usr/bin/env bash
# Theme inspired on:
# - Ronacher's dotfiles (mitsuhikos) - http://github.com/mitsuhiko/dotfiles/tree/master/bash/
# - Glenbot - http://theglenbot.com/custom-bash-shell-for-development/
# - My extravagant zsh - http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/
# - Monokai colors - http://monokai.nl/blog/2006/07/15/textmate-color-theme/
# - Bash_it modern theme
#
# 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
# terminal configuration:
#! ----------------------------------------------------------- TERMINAL COLORS
#! monokai - http://www.monokai.nl/blog/2006/07/15/textmate-color-theme/
#*background: #272822
#*foreground: #E2DA6E
#*color0: black
#! mild red
#*color1: #CD0000
#! light green
#*color2: #A5E02D
#! orange (yellow)
#*color3: #FB951F
#! "dark" blue
#*color4: #076BCC
#! hot pink
#*color5: #F6266C
#! cyan
#*color6: #64D9ED
#! gray
#*color7: #E5E5E5
# ----------------------------------------------------------------- COLOR CONF
D_DEFAULT_COLOR="${normal}"
D_INTERMEDIATE_COLOR="${white}"
D_USER_COLOR="${purple}"
D_SUPERUSER_COLOR="${red}"
D_MACHINE_COLOR="${cyan}"
D_DIR_COLOR="${green}"
D_SCM_COLOR="${yellow}"
D_BRANCH_COLOR="${yellow}"
D_CHANGES_COLOR="${white}"
D_CMDFAIL_COLOR="${red}"
D_VIMSHELL_COLOR="${cyan}"
# ------------------------------------------------------------------ FUNCTIONS
case $TERM in
xterm*)
TITLEBAR="\033]0;\w\007"
;;
*)
TITLEBAR=""
;;
esac
is_vim_shell() {
if [ ! -z "$VIMRUNTIME" ];
then
echo "${D_INTERMEDIATE_COLOR}on ${D_VIMSHELL_COLOR}\
vim shell${D_DEFAULT_COLOR} "
fi
}
mitsuhikos_lastcommandfailed() {
code=$?
if [ $code != 0 ];
then
echo "${D_INTERMEDIATE_COLOR}exited ${D_CMDFAIL_COLOR}\
$code ${D_DEFAULT_COLOR}"
fi
}
# vcprompt for scm instead of bash_it default
demula_vcprompt() {
if [ ! -z "$VCPROMPT_EXECUTABLE" ];
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"
fi
}
# checks if the plugin is installed before calling battery_charge
safe_battery_charge() {
if _command_exists battery_charge ;
then
battery_charge
fi
}
# -------------------------------------------------------------- PROMPT OUTPUT
prompt() {
local LAST_COMMAND_FAILED=$(mitsuhikos_lastcommandfailed)
local SAVE_CURSOR='\033[s'
local RESTORE_CURSOR='\033[u'
local MOVE_CURSOR_RIGHTMOST='\033[500C'
local MOVE_CURSOR_5_LEFT='\033[5D'
if [[ "$OSTYPE" = 'linux'* ]]
then
PS1="${TITLEBAR}${SAVE_CURSOR}${MOVE_CURSOR_RIGHTMOST}${MOVE_CURSOR_5_LEFT}
$(safe_battery_charge)${RESTORE_CURSOR}\
${D_USER_COLOR}\u ${D_INTERMEDIATE_COLOR}\
at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\
in ${D_DIR_COLOR}\w ${D_INTERMEDIATE_COLOR}\
${LAST_COMMAND_FAILED}\
$(demula_vcprompt)\
$(is_vim_shell)
${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}"
else
PS1="${TITLEBAR}
${D_USER_COLOR}\u ${D_INTERMEDIATE_COLOR}\
at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\
in ${D_DIR_COLOR}\w ${D_INTERMEDIATE_COLOR}\
${LAST_COMMAND_FAILED}\
$(demula_vcprompt)\
$(is_vim_shell)\
$(safe_battery_charge)
${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}"
fi
PS2="${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}"
}
# Runs prompt (this bypasses bash_it $PROMPT setting)
safe_append_prompt_command prompt
+1
View File
@@ -0,0 +1 @@
PROMPT="\w>>"
@@ -0,0 +1,41 @@
# shellcheck shell=bash
SCM_THEME_PROMPT_DIRTY=''
SCM_THEME_PROMPT_CLEAN=''
SCM_GIT_CHAR="${bold_cyan}±${normal}"
SCM_SVN_CHAR="${bold_cyan}${normal}"
SCM_HG_CHAR="${bold_red}${normal}"
SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX=""
if [ ! -z $RVM_THEME_PROMPT_COLOR ]; then
RVM_THEME_PROMPT_COLOR=$(eval echo $`echo ${RVM_THEME_PROMPT_COLOR}`);
else
RVM_THEME_PROMPT_COLOR="${red}"
fi
RVM_THEME_PROMPT_PREFIX="(${RVM_THEME_PROMPT_COLOR}rb${normal}: "
RVM_THEME_PROMPT_SUFFIX=") "
if [ ! -z $VIRTUALENV_THEME_PROMPT_COLOR ]; then
VIRTUALENV_THEME_PROMPT_COLOR=$(eval echo $`echo ${VIRTUALENV_THEME_PROMPT_COLOR}`);
else
VIRTUALENV_THEME_PROMPT_COLOR="${green}"
fi
VIRTUALENV_THEME_PROMPT_PREFIX="(${VIRTUALENV_THEME_PROMPT_COLOR}py${normal}: "
VIRTUALENV_THEME_PROMPT_SUFFIX=") "
if [ ! -z $THEME_PROMPT_HOST_COLOR ]; then
THEME_PROMPT_HOST_COLOR=$(eval echo $`echo ${THEME_PROMPT_HOST_COLOR}`);
else
THEME_PROMPT_HOST_COLOR="$blue"
fi
function prompt_setter() {
# Save history
_save-and-reload-history 1
PS1="
$(clock_prompt) $(scm_char) [${THEME_PROMPT_HOST_COLOR}\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)$(ruby_version_prompt)\w
$(scm_prompt)$reset_color $ "
PS2='> '
PS4='+ '
}
safe_append_prompt_command prompt_setter
@@ -0,0 +1,16 @@
# shellcheck shell=bash
source "$BASH_IT/themes/doubletime/doubletime.theme.bash"
function prompt_setter() {
# Save history
_save-and-reload-history 1
PS1="
$(clock_prompt) $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)$(ruby_version_prompt)
\w
$(scm_prompt)$reset_color $ "
PS2='> '
PS4='+ '
}
safe_append_prompt_command prompt_setter
@@ -0,0 +1,16 @@
# shellcheck shell=bash
source "$BASH_IT/themes/doubletime/doubletime.theme.bash"
function prompt_setter() {
# Save history
_save-and-reload-history 1
PS1="
$(clock_prompt) $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)
\w
$(scm_prompt)$reset_color $ "
PS2='> '
PS4='+ '
}
safe_append_prompt_command prompt_setter
@@ -0,0 +1,98 @@
#!/usr/bin/env bash
# Simplistic one-liner theme to display source control management info beside
# the ordinary Linux bash prompt.
#
# Demo:
#
# [ritola@localhost ~]$ cd .bash-it/themes/dulcie
# [ritola@localhost |master ✓| dulcie]$ # This is single line mode
# |bash-it|± master ✓|
# [ritola@localhost dulcie]$ # In multi line, the SCM info is in the separate line
#
# Configuration. Change these by adding them in your .bash_profile
DULCIE_COLOR=${DULCIE_COLOR:=1} # 0 = monochrome, 1 = colorful
DULCIE_MULTILINE=${DULCIE_MULTILINE:=1} # 0 = Single line, 1 = SCM in separate line
dulcie_color() {
echo -en "\[\e[38;5;${1}m\]"
}
dulcie_background() {
echo -en "\[\e[48;5;${1}m\]"
}
dulcie_prompt() {
color_user_root=$(dulcie_color 169)
color_user_nonroot="${green}"
color_host_local=$(dulcie_color 230)
color_host_remote=$(dulcie_color 214)
color_rootdir=$(dulcie_color 117)
color_workingdir=$(dulcie_color 117)
background_scm=$(dulcie_background 238)
SCM_THEME_ROOT_SUFFIX="|$(scm_char) "
# Set colors
if [ "${DULCIE_COLOR}" -eq "1" ]; then
if [[ $EUID -ne 0 ]]; then
color_user="${color_user_nonroot}"
else
color_user="${color_user_root}"
fi
if [[ -n "${SSH_CLIENT}" ]]; then
color_host="${color_host_remote}"
else
color_host="${color_host_local}"
fi
DULCIE_USER="${color_user}\u${reset_color}"
DULCIE_HOST="${color_host}\h${reset_color}"
DULCIE_WORKINGDIR="${color_workingdir}\W${reset_color}"
DULCIE_PROMPTCHAR="${color_user}"'\$'"${reset_color}"
SCM_THEME_PROMPT_DIRTY=" ${red}${reset_color}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}${normal}"
DULCIE_SCM_BACKGROUND="${background_scm}"
DULCIE_SCM_DIR_COLOR="${color_rootdir}"
SCM_THEME_ROOT_SUFFIX="${reset_color}${SCM_THEME_ROOT_SUFFIX}"
SCM_THEME_PROMPT_DIRTY=" $(dulcie_color 1)${reset_color}"
SCM_THEME_PROMPT_CLEAN=" $(dulcie_color 10)${reset_color}"
else
DULCIE_USER='\u'
DULCIE_HOST='\h'
DULCIE_WORKINGDIR='\W'
DULCIE_PROMPTCHAR='\$'
DULCIE_SCM_BACKGROUND=""
DULCIE_SCM_DIR_COLOR=""
SCM_THEME_DIR_COLOR=""
SCM_THEME_PROMPT_DIRTY=" ✗"
SCM_THEME_PROMPT_CLEAN=" ✓"
fi
# Change terminal title
printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"
# Open the new terminal in the same directory
_is_function __vte_osc7 && __vte_osc7
PS1="${reset_color}[${DULCIE_USER}@${DULCIE_HOST}$(scm_prompt_info)${reset_color} ${DULCIE_WORKINGDIR}]"
if [[ "${DULCIE_MULTILINE}" -eq "1" ]]; then
PS1="${reset_color}[${DULCIE_USER}@${DULCIE_HOST}${reset_color} ${DULCIE_WORKINGDIR}]"
if [[ "$(scm_prompt_info)" ]]; then
SCM_THEME_PROMPT_PREFIX="${DULCIE_SCM_BACKGROUND}|${DULCIE_SCM_DIR_COLOR}"
SCM_THEME_PROMPT_SUFFIX="|${normal}"
PS1="$(scm_prompt_info)\n${PS1}"
fi
else
SCM_THEME_PROMPT_PREFIX=" ${DULCIE_SCM_BACKGROUND}|${DULCIE_SCM_DIR_COLOR}"
SCM_THEME_PROMPT_SUFFIX="|${normal}"
PS1="${reset_color}[${DULCIE_USER}@${DULCIE_HOST}$(scm_prompt_info)${reset_color} ${DULCIE_WORKINGDIR}]"
fi
PS1="${PS1}${DULCIE_PROMPTCHAR} "
}
safe_append_prompt_command dulcie_prompt
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
SCM_THEME_PROMPT_PREFIX="${cyan} on ${green}"
SCM_THEME_PROMPT_SUFFIX=""
SCM_THEME_PROMPT_DIRTY=" ${red}with changes"
SCM_THEME_PROMPT_CLEAN=""
venv() {
if [ ! -z "$VIRTUAL_ENV" ]
then
local env=$VIRTUAL_ENV
echo "${gray} in ${orange}${env##*/} "
fi
}
last_two_dirs() {
pwd|rev|awk -F / '{print $1,$2}'|rev|sed s_\ _/_|sed "s|$(sed 's,\/,,'<<<$HOME)|~|g"
}
prompt() {
PS1="${yellow}# ${reset_color}$(last_two_dirs)$(scm_prompt_info)${reset_color}$(venv)${reset_color} ${cyan}\n> ${reset_color}"
}
safe_append_prompt_command prompt
+22
View File
@@ -0,0 +1,22 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
SCM_THEME_PROMPT_PREFIX="${bold_green?}[ ${normal?}"
SCM_THEME_PROMPT_SUFFIX="${bold_green?} ] "
SCM_THEME_PROMPT_DIRTY=" ${red?}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green?}"
function prompt_command() {
local scm_prompt_info
if [ "${USER:-${LOGNAME?}}" = root ]; then
cursor_color="${bold_red?}"
user_color="${green?}"
else
cursor_color="${bold_green?}"
user_color="${white?}"
fi
scm_prompt_info="$(scm_prompt_info)"
PS1="${user_color}\u${normal?}@${white?}\h ${bold_black?}\w\n${reset_color?}${scm_prompt_info}${cursor_color} ${normal?}"
}
safe_append_prompt_command prompt_command
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}"
SCM_THEME_PROMPT_PREFIX=" ${green}| "
SCM_THEME_PROMPT_SUFFIX="${green} |"
SCM_NONE_CHAR='◐ '
SCM_GIT_SHOW_MINIMAL_INFO=true
GIT_THEME_PROMPT_DIRTY=" ${red}"
GIT_THEME_PROMPT_CLEAN=" ${bold_green}"
GIT_THEME_PROMPT_PREFIX=" ${green}|"
GIT_THEME_PROMPT_SUFFIX="${green}|"
RVM_THEME_PROMPT_PREFIX="|"
RVM_THEME_PROMPT_SUFFIX=" d|"
BOLD="\[\e[1m\]"
function prompt_command() {
PS1="\n${bold_cyan}$(scm_prompt_char_info)$(virtualenv_prompt) ${bold_cyan}\w :${reset_color}${normal}${BOLD} "
}
safe_append_prompt_command prompt_command
@@ -0,0 +1,42 @@
#!/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}|"
RVM_THEME_PROMPT_PREFIX="|"
RVM_THEME_PROMPT_SUFFIX="|"
function get_hour_color {
hour_color=$red
min=$(date +%M)
if [ "$min" -lt "15" ]; then
hour_color=$white
elif [ "$min" -lt "30" ]; then
hour_color=$green
elif [ "$min" -lt "45" ]; then
hour_color=$yellow
else
hour_color=$red
fi
echo "$hour_color"
}
__emperor_clock() {
THEME_CLOCK_COLOR=$(get_hour_color)
clock_prompt
}
function prompt_command() {
PS1="\n$(__emperor_clock)${purple}\h ${reset_color}in ${prompt_color}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}${reset_color} "
}
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%H "}
safe_append_prompt_command prompt_command
+19
View File
@@ -0,0 +1,19 @@
#!/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}|"
VIRTUALENV_THEME_PROMPT_PREFIX="${green}"
VIRTUALENV_THEME_PROMPT_SUFFIX=""
function prompt_command() {
PS1="\n$(virtualenv_prompt)${yellow}$(ruby_version_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}${reset_color} "
}
safe_append_prompt_command prompt_command
@@ -0,0 +1,93 @@
# shellcheck shell=bash
function _user-prompt() {
local -r user='\u'
if [[ "${EUID}" -eq 0 ]]; then
# Privileged users:
local -r user_color="${bold_red?}"
else
# Standard users:
local -r user_color="${bold_green?}"
fi
# Print the current user's name (colored according to their current EUID):
printf '%b%s%b' "${user_color}" "${user}" "${normal?}"
}
function _host-prompt() {
local -r host='\h'
# Check whether or not $SSH_TTY is set:
if [[ -z "${SSH_TTY:-}" ]]; then
# For local hosts, set the host's prompt color to blue:
local -r host_color="${bold_blue?}"
else
# For remote hosts, set the host's prompt color to red:
local -r host_color="${bold_red?}"
fi
# Print the current hostname (colored according to $SSH_TTY's status):
printf '%b%s%b' "${host_color}" "${host}" "${normal?}"
}
function _user-at-host-prompt() {
# Concatenate the user and host prompts into: user@host:
_user-prompt
printf '%b@' "${bold_white?}"
_host-prompt
}
function _exit-status-prompt() {
local -r prompt_string="${1}"
local -r exit_status="${2}"
# Check the exit status of the last command captured by $exit_status:
if [[ "${exit_status}" -eq 0 ]]; then
# For commands that return an exit status of zero, set the exit status's
# notifier to green:
local -r exit_status_color="${bold_green?}"
else
# For commands that return a non-zero exit status, set the exit status's
# notifier to red:
local -r exit_status_color="${bold_red?}"
fi
if [[ "${prompt_string}" -eq 1 ]]; then
# $PS1:
printf '%b +%b' "${exit_status_color}" "${normal?} "
elif [[ "${prompt_string}" -eq 2 ]]; then
# $PS2:
printf '%b |%b' "${exit_status_color}" "${normal?} "
else
# Default:
printf '%b ?%b' "${exit_status_color}" "${normal?} "
fi
}
function _ps1() {
local -r time='\t'
local -r pwd='\w'
printf '%b%s ' "${bold_white?}" "${time}"
_user-at-host-prompt
printf '%b:%b%s\n' "${bold_white?}" "${normal?}" "${pwd}"
_exit-status-prompt 1 "${exit_status}"
}
function _ps2() {
_exit-status-prompt 2 "${exit_status}"
}
function prompt_command() {
# Capture the exit status of the last command:
local -r exit_status="${?}"
# Build the $PS1 prompt:
PS1="$(_ps1)"
# Build the $PS2 prompt:
PS2="$(_ps2)"
}
safe_append_prompt_command prompt_command
+64
View 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
@@ -0,0 +1,33 @@
# scm theming
SCM_THEME_PROMPT_PREFIX="${yellow}("
SCM_THEME_PROMPT_SUFFIX=")${normal}"
SCM_THEME_PROMPT_DIRTY="*"
SCM_THEME_PROMPT_CLEAN=""
SCM_GIT_CHAR="${green}±${normal}"
SCM_SVN_CHAR="${bold_cyan}${normal}"
SCM_HG_CHAR="${bold_red}${normal}"
### TODO: openSUSE has already colors enabled, check if those differs from stock
# LS colors, made with http://geoff.greer.fm/lscolors/
# export LSCOLORS="Gxfxcxdxbxegedabagacad"
# export LS_COLORS='no=00:fi=00:di=01;34:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;31:*.rpm=00;31:*.deb=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:'
gallifrey_prompt() {
SCM_PROMPT_FORMAT='%s%s'
ps_host="${green}\h${normal}";
ps_user_mark="${bold}\$${normal}";
ps_root_mark="${normal}§"
ps_path="${normal}\w";
# make it work
case $(id -u) in
0) PS1="$ps_host $ps_path $(scm_prompt)$ps_root_mark "
;;
*) PS1="$ps_host $ps_path $(scm_prompt)$ps_user_mark "
;;
esac
}
safe_append_prompt_command gallifrey_prompt
+173
View File
@@ -0,0 +1,173 @@
# shellcheck shell=bash
function _git-symbolic-ref() {
git symbolic-ref -q HEAD 2> /dev/null
}
# When on a branch, this is often the same as _git-commit-description,
# but this can be different when two branches are pointing to the
# same commit. _git-branch is used to explicitly choose the checked-out
# branch.
function _git-branch() {
if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]]; then
if [[ -n "${VCS_STATUS_LOCAL_BRANCH:-}" ]]; then
echo "${VCS_STATUS_LOCAL_BRANCH}"
else
return 1
fi
else
git symbolic-ref -q --short HEAD 2> /dev/null || return 1
fi
}
function _git-tag() {
if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]]; then
if [[ -n "${VCS_STATUS_TAG:-}" ]]; then
echo "${VCS_STATUS_TAG}"
fi
else
git describe --tags --exact-match 2> /dev/null
fi
}
function _git-commit-description() {
git describe --contains --all 2> /dev/null
}
function _git-short-sha() {
if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]]; then
echo "${VCS_STATUS_COMMIT:0:7}"
else
git rev-parse --short HEAD
fi
}
# Try the checked-out branch first to avoid collision with branches pointing to the same ref.
function _git-friendly-ref() {
if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]]; then
_git-branch || _git-tag || _git-short-sha # there is no tag based describe output in gitstatus
else
_git-branch || _git-tag || _git-commit-description || _git-short-sha
fi
}
function _git-num-remotes() {
git remote | wc -l
}
function _git-upstream() {
local ref
ref="$(_git-symbolic-ref)" || return 1
git for-each-ref --format="%(upstream:short)" "${ref}"
}
function _git-upstream-remote() {
local upstream branch
upstream="$(_git-upstream)" || return 1
branch="$(_git-upstream-branch)" || return 1
echo "${upstream%"/${branch}"}"
}
function _git-upstream-branch() {
local ref
ref="$(_git-symbolic-ref)" || return 1
# git versions < 2.13.0 do not support "strip" for upstream format
# regex replacement gives the wrong result for any remotes with slashes in the name,
# so only use when the strip format fails.
git for-each-ref --format="%(upstream:strip=3)" "${ref}" 2> /dev/null || git for-each-ref --format="%(upstream)" "${ref}" | sed -e "s/.*\/.*\/.*\///"
}
function _git-upstream-behind-ahead() {
git rev-list --left-right --count "$(_git-upstream)...HEAD" 2> /dev/null
}
function _git-upstream-branch-gone() {
[[ "$(git status -s -b | sed -e 's/.* //')" == "[gone]" ]]
}
function _git-hide-status() {
[[ "$(git config --get bash-it.hide-status)" == "1" ]]
}
function _git-status() {
local git_status_flags=
if [[ "${SCM_GIT_IGNORE_UNTRACKED:-}" == "true" ]]; then
git_status_flags='-uno'
fi
git status --porcelain "${git_status_flags:---}" 2> /dev/null
}
function _git-status-counts() {
_git-status | awk '
BEGIN {
untracked=0;
unstaged=0;
staged=0;
}
{
if ($0 ~ /^\?\? .+/) {
untracked += 1
} else {
if ($0 ~ /^.[^ ] .+/) {
unstaged += 1
}
if ($0 ~ /^[^ ]. .+/) {
staged += 1
}
}
}
END {
print untracked "\t" unstaged "\t" staged
}'
}
function _git-remote-info() {
local same_branch_name="" branch_prefix
# prompt handling only, reimplement because patching the routine below gets ugly
if [[ "${SCM_GIT_GITSTATUS_RAN:-}" == "true" ]]; then
[[ "${VCS_STATUS_REMOTE_NAME?}" == "" ]] && return
[[ "${VCS_STATUS_LOCAL_BRANCH?}" == "${VCS_STATUS_REMOTE_BRANCH?}" ]] && same_branch_name=true
# no multiple remote support in gitstatusd
if [[ "${SCM_GIT_SHOW_REMOTE_INFO:-}" == "true" || "${SCM_GIT_SHOW_REMOTE_INFO:-}" == "auto" ]]; then
if [[ ${same_branch_name:-} != "true" ]]; then
remote_info="${VCS_STATUS_REMOTE_NAME?}/${VCS_STATUS_REMOTE_BRANCH?}"
else
remote_info="${VCS_STATUS_REMOTE_NAME?}"
fi
elif [[ ${same_branch_name:-} != "true" ]]; then
remote_info="${VCS_STATUS_REMOTE_BRANCH?}"
fi
if [[ -n "${remote_info:-}" ]]; then
# no support for gone remote branches in gitstatusd
branch_prefix="${SCM_THEME_BRANCH_TRACK_PREFIX:-}"
echo "${branch_prefix}${remote_info:-}"
fi
else
[[ "$(_git-upstream)" == "" ]] && return
[[ "$(_git-branch)" == "$(_git-upstream-branch)" ]] && same_branch_name=true
if [[ ("${SCM_GIT_SHOW_REMOTE_INFO}" == "auto" && "$(_git-num-remotes)" -ge 2) ||
"${SCM_GIT_SHOW_REMOTE_INFO}" == "true" ]]; then
if [[ ${same_branch_name:-} != "true" ]]; then
# shellcheck disable=SC2016
remote_info='$(_git-upstream)'
else
remote_info="$(_git-upstream-remote)"
fi
elif [[ ${same_branch_name:-} != "true" ]]; then
# shellcheck disable=SC2016
remote_info='$(_git-upstream-branch)'
fi
if [[ -n "${remote_info:-}" ]]; then
local branch_prefix
if _git-upstream-branch-gone; then
branch_prefix="${SCM_THEME_BRANCH_GONE_PREFIX:-}"
else
branch_prefix="${SCM_THEME_BRANCH_TRACK_PREFIX:-}"
fi
echo "${branch_prefix}${remote_info:-}"
fi
fi
}
@@ -0,0 +1,71 @@
#!/usr/bin/env bash
. "$BASH_IT/themes/gitline/powerline.base.bash"
#For the logo(Uncomment if you want a logo before your name)
#PROMPT_DISTRO_LOGO="💻"
PROMPT_DISTRO_LOGO_COLOR=15
PROMPT_DISTRO_LOGO_COLORBG=52
#Prompt Seperator Charactors
PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:=""}
POWERLINE_LEFT_SEPARATOR=${POWERLINE_LEFT_SEPARATOR:=""}
#USER INFO CHARACTERS
USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "}
USER_INFO_SUDO_CHAR=${POWERLINE_USER_INFO_SUDO_CHAR:=" "}
USER_INFO_THEME_PROMPT_COLOR=91
USER_INFO_THEME_PROMPT_COLOR_SUDO=1
#PYTHON VENV
PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:=" "}
CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="c "}
PYTHON_VENV_THEME_PROMPT_COLOR=17
#GIT Prompt Symbols
SCM_NONE_CHAR=""
SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "}
SCM_HG_CHAR=${POWERLINE_SCM_HG_CHAR:="☿ "}
SCM_THEME_PROMPT_CLEAN=" ✓ "
SCM_THEME_PROMPT_DIRTY=" "
SCM_THEME_PROMPT_COLOR=91
SCM_THEME_PROMPT_CLEAN_COLOR=41
SCM_THEME_PROMPT_DIRTY_COLOR=94
SCM_THEME_PROMPT_STAGED_COLOR=220 #52
SCM_THEME_PROMPT_UNSTAGED_COLOR=81
#Ruby Prompt Symbols
RVM_THEME_PROMPT_PREFIX=""
RVM_THEME_PROMPT_SUFFIX=""
RBENV_THEME_PROMPT_PREFIX=""
RBENV_THEME_PROMPT_SUFFIX=""
RUBY_THEME_PROMPT_COLOR=161
RUBY_CHAR=${POWERLINE_RUBY_CHAR:="r "}
CWD_THEME_DIR_SEPARATOR=""
CWD_THEME_DIR_SEPARATOR_COLOR=52
CWD_THEME_PROMPT_COLOR=252
HOST_THEME_PROMPT_COLOR=88
LAST_STATUS_THEME_PROMPT_COLOR=52
#Clock
CLOCK_THEME_PROMPT_COLOR=240
#For Battery Plugin
BATTERY_AC_CHAR=${BATTERY_AC_CHAR:="⚡"}
BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=70
BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=208
BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
IN_VIM_THEME_PROMPT_COLOR=245
IN_VIM_THEME_PROMPT_TEXT="vim"
IN_TOOLBOX_THEME_PROMPT_COLOR=125
IN_TOOLBOX_THEME_PROMPT_TEXT="⬢ "
safe_append_prompt_command __powerline_prompt_command
@@ -0,0 +1,233 @@
#To set color for foreground and background
function set_color {
set +u
if [[ "${1}" != "-" ]]; then
fg="38;5;${1}"
fi
if [[ "${2}" != "-" ]]; then
bg="48;5;${2}"
[[ -n "${fg}" ]] && bg=";${bg}"
fi
echo -e "\[\033[${fg}${bg}m\]"
}
#Customising User Info Segment
function __powerline_user_info_prompt {
local user_info="${USER}"
local color=${USER_INFO_THEME_PROMPT_COLOR}
local fg_color=15
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 [[ "${color}" = "${USER_INFO_THEME_PROMPT_COLOR_SUDO}" ]]; then
user_info="👑 ${USER}"
fg_color=227
color=${USER_INFO_THEME_PROMPT_COLOR_SUDO}
fi
;;
*)
if [[ -n "${SSH_CLIENT}" ]] || [[ -n "${SSH_CONNECTION}" ]]; then
user_info="${USER_INFO_SSH_CHAR}${USER}"
else
user_info="${USER}"
fi
;;
esac
[[ -n "${user_info}" ]] && echo "${user_info}|${color}|${fg_color}"
}
#Customising Ruby Prompt
function __powerline_ruby_prompt {
local ruby_version=""
local fg_color=206
if _command_exists rvm; then
ruby_version="$(rvm_version_prompt)"
elif _command_exists rbenv; then
ruby_version=$(rbenv_version_prompt)
fi
[[ -n "${ruby_version}" ]] && echo "${RUBY_CHAR}${ruby_version}|${RUBY_THEME_PROMPT_COLOR}|${fg_color}"
}
#Customising Python (venv) Prompt
function __powerline_python_venv_prompt {
set +u
local python_venv=""
local fg_color=206
if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then
python_venv="${CONDA_DEFAULT_ENV}"
PYTHON_VENV_CHAR=${CONDA_PYTHON_VENV_CHAR}
elif [[ -n "${VIRTUAL_ENV}" ]]; then
python_venv=$(basename "${VIRTUAL_ENV}")
fi
[[ -n "${python_venv}" ]] && echo "${PYTHON_VENV_CHAR}${python_venv}|${PYTHON_VENV_THEME_PROMPT_COLOR}|${fg_color}"
}
#Customising SCM(GIT) Prompt
function __powerline_scm_prompt {
local color=""
local scm_prompt=""
local fg_color=206
scm_prompt_vars
if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then
if [[ "${SCM_DIRTY}" -eq 3 ]]; then
color=${SCM_THEME_PROMPT_STAGED_COLOR}
fg_color=124
elif [[ "${SCM_DIRTY}" -eq 2 ]]; then
color=${SCM_THEME_PROMPT_UNSTAGED_COLOR}
fg_color=56
elif [[ "${SCM_DIRTY}" -eq 1 ]]; then
color=${SCM_THEME_PROMPT_DIRTY_COLOR}
fg_color=118
elif [[ "${SCM_DIRTY}" -eq 0 ]]; then
color=${SCM_THEME_PROMPT_CLEAN_COLOR}
fg_color=16
else
color=${SCM_THEME_PROMPT_COLOR}
fg_color=255
fi
if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then
scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
elif [[ "${SCM_P4_CHAR}" == "${SCM_CHAR}" ]]; then
scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
elif [[ "${SCM_HG_CHAR}" == "${SCM_CHAR}" ]]; then
scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
fi
echo "${scm_prompt}${scm}|${color}|${fg_color}"
fi
}
function __powerline_cwd_prompt {
local cwd=$(pwd | sed "s|^${HOME}|~|")
local fg_color=16
echo "${cwd}|${CWD_THEME_PROMPT_COLOR}|${fg_color}"
}
function __powerline_hostname_prompt {
local fg_color=206
echo "$(hostname -s)|${HOST_THEME_PROMPT_COLOR}|${fg_color}"
}
function __powerline_wd_prompt {
local fg_color=206
echo "\W|${CWD_THEME_PROMPT_COLOR}|${fg_color}"
}
function __powerline_clock_prompt {
local fg_color=206
echo "$(date +"${THEME_CLOCK_FORMAT}")|${CLOCK_THEME_PROMPT_COLOR}|${fg_color}"
}
function __powerline_battery_prompt {
local color=""
local battery_status="$(battery_percentage 2> /dev/null)"
local fg_color=255
if [[ -z "${battery_status}" ]] || [[ "${battery_status}" = "-1" ]] || [[ "${battery_status}" = "no" ]]; then
true
else
if [[ "$((10#${battery_status}))" -le 5 ]]; then
color="${BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR}"
elif [[ "$((10#${battery_status}))" -le 25 ]]; then
color="${BATTERY_STATUS_THEME_PROMPT_LOW_COLOR}"
else
color="${BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR}"
fi
ac_adapter_connected && battery_status="${BATTERY_AC_CHAR}${battery_status}"
echo "${battery_status}%|${color}|${fg_color}"
fi
}
function __powerline_in_vim_prompt {
local fg_color=206
if [ -n "$VIMRUNTIME" ]; then
echo "${IN_VIM_THEME_PROMPT_TEXT}|${IN_VIM_THEME_PROMPT_COLOR}|${fg_color}"
fi
}
function __powerline_aws_profile_prompt {
local fg_color=206
if [[ -n "${AWS_PROFILE}" ]]; then
echo "${AWS_PROFILE_CHAR}${AWS_PROFILE}|${AWS_PROFILE_PROMPT_COLOR}|${fg_color}"
fi
}
function __powerline_in_toolbox_prompt {
local fg_color=206
if [ -f /run/.containerenv ] && [ -f /run/.toolboxenv ]; then
echo "${IN_TOOLBOX_THEME_PROMPT_TEXT}|${IN_TOOLBOX_THEME_PROMPT_COLOR}|${fg_color}"
fi
}
function __powerline_left_segment {
local OLD_IFS="${IFS}"; IFS="|"
local params=( $1 )
IFS="${OLD_IFS}"
local separator_char="${POWERLINE_LEFT_SEPARATOR}"
local separator=""
local fg_color=206
#for seperator character
if [[ "${SEGMENTS_AT_LEFT}" -gt 0 ]]; then
separator="$(set_color ${LAST_SEGMENT_COLOR} ${params[1]})${separator_char}${normal}"
fi
#change here to cahnge fg color
LEFT_PROMPT+="${separator}$(set_color ${params[2]} ${params[1]}) ${params[0]} ${normal}"
#seperator char color = current bg
LAST_SEGMENT_COLOR=${params[1]}
(( SEGMENTS_AT_LEFT += 1 ))
}
function __powerline_last_status_prompt {
[[ "$1" -ne 0 ]] && echo "${1}|${LAST_STATUS_THEME_PROMPT_COLOR}"
}
function __powerline_prompt_command {
local last_status="$?" ## always the first
local separator_char="${POWERLINE_PROMPT_CHAR}"
LEFT_PROMPT=""
SEGMENTS_AT_LEFT=0
LAST_SEGMENT_COLOR=""
if [[ -n "${POWERLINE_PROMPT_DISTRO_LOGO}" ]]; then
LEFT_PROMPT+="$(set_color ${PROMPT_DISTRO_LOGO_COLOR} ${PROMPT_DISTRO_LOGO_COLORBG})${PROMPT_DISTRO_LOGO}$(set_color - -)"
fi
## left prompt ##
for segment in $POWERLINE_PROMPT; do
local info="$(__powerline_${segment}_prompt)"
[[ -n "${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} -)${separator_char}${normal}"
PS1="${LEFT_PROMPT} "
## cleanup ##
unset LAST_SEGMENT_COLOR \
LEFT_PROMPT \
SEGMENTS_AT_LEFT
}
@@ -0,0 +1,200 @@
#!/usr/bin/env bash
#
# This theme was obviously inspired a lot by
#
# - Demula theme
#
# which in itself was inspired by :
#
# - Ronacher's dotfiles (mitsuhikos) - http://github.com/mitsuhiko/dotfiles/tree/master/bash/
# - Glenbot - http://theglenbot.com/custom-bash-shell-for-development/
# - My extravagant zsh - http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/
# - Monokai colors - http://monokai.nl/blog/2006/07/15/textmate-color-theme/
# - Bash_it modern theme
#
# Hawaii50 theme supports :
#
# - configurable directory length
# - hg, svn, git detection (I work in all of them)
# - virtualenv, rvm + gemsets
#
# Screenshot: http://i.imgur.com/4IAMJ.png
#
# by Ryan Kanno <ryankanno@localkinegrinds.com>
#
# And yes, we code out in Hawaii. :D
#
# Note: I also am really new to this bash scripting game, so if you see things
# that are flat out wrong, or if you think of something neat, just send a pull
# request. This probably only works on a Mac - as some functions are OS
# specific like getting ip, etc.
#
# IMPORTANT THINGS TO CHANGE ==================================================
# Show IP in prompt
# One thing to be weary about if you have slow Internets
IP_ENABLED=1
# virtual prompts
VIRTUAL_PROMPT_ENABLED=1
# COLORS ======================================================================
ORANGE='\[\e[0;33m\]'
DEFAULT_COLOR="${white}"
USER_COLOR="${purple}"
SUPERUSER_COLOR="${red}"
MACHINE_COLOR=$ORANGE
IP_COLOR=$ORANGE
DIRECTORY_COLOR="${green}"
VE_COLOR="${cyan}"
RVM_COLOR="${cyan}"
REF_COLOR="${purple}"
# SCM prompts
SCM_THEME_PROMPT_DIRTY=" ${bold_red}${normal}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}${normal}"
SCM_THEME_PROMPT_PREFIX=' on '
SCM_THEME_PROMPT_SUFFIX=''
# rvm prompts
RVM_THEME_PROMPT_PREFIX=''
RVM_THEME_PROMPT_SUFFIX=''
# virtualenv prompts
VIRTUALENV_THEME_PROMPT_PREFIX=''
VIRTUALENV_THEME_PROMPT_SUFFIX=''
VIRTUAL_THEME_PROMPT_PREFIX=' using '
VIRTUAL_THEME_PROMPT_SUFFIX=''
# Max length of PWD to display
MAX_PWD_LENGTH=20
# Max length of Git Hex to display
MAX_GIT_HEX_LENGTH=5
# IP address
IP_SEPARATOR=', '
# FUNCS =======================================================================
function get_ip_info {
myip=$(curl -s checkip.dyndns.org | grep -Eo '[0-9\.]+')
echo -e "$(ips | sed -e :a -e '$!N;s/\n/${IP_SEPARATOR}/;ta' | sed -e 's/127\.0\.0\.1\${IP_SEPARATOR}//g'), ${myip}"
}
# Displays ip prompt
function ip_prompt_info() {
if [[ $IP_ENABLED == 1 ]]; then
echo -e " ${DEFAULT_COLOR}(${IP_COLOR}$(get_ip_info)${DEFAULT_COLOR})"
fi
}
# Displays virtual info prompt (virtualenv/rvm)
function virtual_prompt_info() {
local virtual_env_info=$(virtualenv_prompt)
local rvm_info=$(ruby_version_prompt)
local virtual_prompt=""
local prefix=${VIRTUAL_THEME_PROMPT_PREFIX}
local suffix=${VIRTUAL_THEME_PROMPT_SUFFIX}
# If no virtual info, just return
[[ -z "$virtual_env_info" && -z "$rvm_info" ]] && return
# If virtual_env info present, append to prompt
[[ -n "$virtual_env_info" ]] && virtual_prompt="virtualenv: ${VE_COLOR}$virtual_env_info${DEFAULT_COLOR}"
if [[ -n "$rvm_info" ]]
then
[[ -n "$virtual_env_info" ]] && virtual_prompt="$virtual_prompt, "
virtual_prompt="${virtual_prompt}rvm: ${RVM_COLOR}$rvm_info${DEFAULT_COLOR}"
fi
echo -e "$prefix$virtual_prompt$suffix"
}
# Parse git info
function git_prompt_info() {
if [[ -n $(git status -s 2> /dev/null |grep -v ^# |grep -v "working directory clean") ]]; then
state=${GIT_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY}
else
state=${GIT_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}
fi
prefix=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX}
suffix=${GIT_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX}
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
commit_id=$(git rev-parse HEAD 2>/dev/null) || return
echo -e "$prefix${REF_COLOR}${ref#refs/heads/}${DEFAULT_COLOR}:${commit_id:0:$MAX_GIT_HEX_LENGTH}$state$suffix"
}
# Parse hg info
function hg_prompt_info() {
if [[ -n $(hg status 2> /dev/null) ]]; then
state=${HG_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY}
else
state=${HG_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}
fi
prefix=${HG_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX}
suffix=${HG_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX}
branch=$(hg summary 2> /dev/null | grep branch | awk '{print $2}')
changeset=$(hg summary 2> /dev/null | grep parent | awk '{print $2}')
echo -e "$prefix${REF_COLOR}${branch}${DEFAULT_COLOR}:${changeset#*:}$state$suffix"
}
# Parse svn info
function svn_prompt_info() {
if [[ -n $(svn status --ignore-externals -q 2> /dev/null) ]]; then
state=${SVN_THEME_PROMPT_DIRTY:-$SCM_THEME_PROMPT_DIRTY}
else
state=${SVN_THEME_PROMPT_CLEAN:-$SCM_THEME_PROMPT_CLEAN}
fi
prefix=${SVN_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX}
suffix=${SVN_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX}
ref=$(svn info 2> /dev/null | awk -F/ '/^URL:/ { for (i=0; i<=NF; i++) { if ($i == "branches" || $i == "tags" ) { print $(i+1); break }; if ($i == "trunk") { print $i; break } } }') || return
[[ -z $ref ]] && return
revision=$(svn info 2> /dev/null | sed -ne 's#^Revision: ##p' )
echo -e "$prefix${REF_COLOR}$ref${DEFAULT_COLOR}:$revision$state$suffix"
}
# Displays last X characters of pwd
function limited_pwd() {
# Replace $HOME with ~ if possible
RELATIVE_PWD=${PWD/#$HOME/\~}
local offset=$((${#RELATIVE_PWD}-$MAX_PWD_LENGTH))
if [ $offset -gt "0" ]
then
local truncated_symbol="..."
TRUNCATED_PWD=${RELATIVE_PWD:$offset:$MAX_PWD_LENGTH}
echo -e "${truncated_symbol}/${TRUNCATED_PWD#*/}"
else
echo -e "${RELATIVE_PWD}"
fi
}
# Displays the current prompt
function prompt() {
local UC=$USER_COLOR
[ $UID -eq "0" ] && UC=$SUPERUSER_COLOR
if [[ $VIRTUAL_PROMPT_ENABLED == 1 ]]; then
PS1="$(scm_char) ${UC}\u ${DEFAULT_COLOR}at ${MACHINE_COLOR}\h$(ip_prompt_info) ${DEFAULT_COLOR}in ${DIRECTORY_COLOR}$(limited_pwd)${DEFAULT_COLOR}$(virtual_prompt_info)$(scm_prompt_info)${reset_color} \$ "
else
PS1="$(scm_char) ${UC}\u ${DEFAULT_COLOR}at ${MACHINE_COLOR}\h$(ip_prompt_info) ${DEFAULT_COLOR}in ${DIRECTORY_COLOR}$(limited_pwd)${DEFAULT_COLOR}$(scm_prompt_info)${reset_color} \$ "
fi
PS2='> '
PS4='+ '
}
safe_append_prompt_command prompt
@@ -0,0 +1,59 @@
#!/usr/bin/env bash
SCM_GIT_CHAR="± "
SCM_HG_CHAR="☿ "
SCM_SVN_CHAR="⑆ "
SCM_NONE_CHAR=""
SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}"
SCM_THEME_PROMPT_PREFIX="|"
SCM_THEME_PROMPT_SUFFIX="${green}| "
SCM_GIT_AHEAD_CHAR="${green}+"
SCM_GIT_BEHIND_CHAR="${red}-"
GIT_THEME_PROMPT_DIRTY=" ${bold_red}"
GIT_THEME_PROMPT_CLEAN=" ${bold_green}"
GIT_THEME_PROMPT_PREFIX="${cyan}|"
GIT_THEME_PROMPT_SUFFIX="${cyan}| "
RVM_THEME_PROMPT_PREFIX="|"
RVM_THEME_PROMPT_SUFFIX="| "
VIRTUALENV_THEME_PROMPT_PREFIX="|"
VIRTUALENV_THEME_PROMPT_SUFFIX="| "
RBENV_THEME_PROMPT_PREFIX="|"
RBENV_THEME_PROMPT_SUFFIX="| "
RBFU_THEME_PROMPT_PREFIX="|"
RBFU_THEME_PROMPT_SUFFIX="| "
function rvm_version_prompt {
if which rvm &> /dev/null; then
rvm_current=$(rvm tools identifier) || return
rvm_default=$(rvm strings default) || return
[ "$rvm_current" != "$rvm_default" ] && ( echo -e "$RVM_THEME_PROMPT_PREFIX$rvm_current$RVM_THEME_PROMPT_SUFFIX" )
fi
}
function git_prompt_info {
git_prompt_vars
echo -e "$SCM_PREFIX$SCM_BRANCH$SCM_STATE$SCM_GIT_AHEAD$SCM_GIT_BEHIND$SCM_GIT_STASH$SCM_SUFFIX"
}
LAST_PROMPT=""
function prompt_command() {
local new_PS1="${bold_cyan}$(scm_char)${yellow}$(ruby_version_prompt)${green}\w $(scm_prompt_info)"
local new_prompt=$(PS1="$new_PS1" "$BASH" --norc -i </dev/null 2>&1 | sed -n '${s/^\(.*\)exit$/\1/p;}')
if [ "$LAST_PROMPT" = "$new_prompt" ]; then
new_PS1=""
else
LAST_PROMPT="$new_prompt"
fi
local wrap_char=""
[[ $COLUMNS && ${#new_PS1} > $(($COLUMNS/1)) ]] && wrap_char="\n"
PS1="${new_PS1}${green}${wrap_char}${reset_color} "
}
safe_append_prompt_command prompt_command
@@ -0,0 +1,38 @@
# This is combination of works from two different people which I combined for my requirement.
# Original PS1 was from reddit user /u/Allevil669 which I found in thread: https://www.reddit.com/r/linux/comments/1z33lj/linux_users_whats_your_favourite_bash_prompt/
# I used that PS1 to the bash-it theme 'morris', and customized it to my liking. All credits to /u/Allevil669 and morris.
#
# prompt theming
# added TITLEBAR for updating the tab and window titles with the pwd
case $TERM in
xterm*)
TITLEBAR=$(printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}")
;;
screen)
TITLEBAR=$(printf "\033]0;%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}")
;;
*)
TITLEBAR=""
;;
esac
if [ "$?" == "0" ]
then
SC="${green}^_^";
else
SC="${red}T_T";
fi
BC=`battery_percentage`
function prompt_command() {
#PS1="${TITLEBAR}[\u@\h \W $(scm_prompt_info)]\$ "
PS1="\n${cyan}┌─${bold_white}[\u@\h]${cyan}${bold_yellow}(\w)$(scm_prompt_info)\n${cyan}└─${bold_green}[\A]-${green}($BC%)${bold_cyan}-[${green}${bold_green}\$${bold_cyan}]${green} "
}
# scm theming
SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}"
SCM_THEME_PROMPT_PREFIX="${bold_cyan}("
SCM_THEME_PROMPT_SUFFIX="${bold_cyan})${reset_color}"
safe_append_prompt_command prompt_command
@@ -0,0 +1 @@
liquidprompt
@@ -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
}
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}"
SCM_THEME_PROMPT_PREFIX="(${yellow}"
SCM_THEME_PROMPT_SUFFIX="${normal})"
GIT_THEME_PROMPT_DIRTY=" ${red}"
GIT_THEME_PROMPT_CLEAN=" ${bold_green}"
GIT_THEME_PROMPT_PREFIX="(${yellow}"
GIT_THEME_PROMPT_SUFFIX="${normal})"
RVM_THEME_PROMPT_PREFIX=""
RVM_THEME_PROMPT_SUFFIX=""
function prompt_command() {
dtime="$(clock_prompt)"
user_host="${green}\u@${cyan}\h${normal}"
current_dir="${bold_blue}\w${normal}"
rvm_ruby="${bold_red}$(ruby_version_prompt)${normal}"
git_branch="$(scm_prompt_info)${normal}"
prompt="${bold_green}\$${normal} "
arrow="${bold_white}${normal} "
prompt="${bold_green}\$${normal} "
PS1="${dtime}${user_host}:${current_dir} ${rvm_ruby} ${git_branch}
$arrow $prompt"
}
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$yellow"}
THEME_CLOCK_FORMAT=${THEME_TIME_FORMAT:-"%I:%M:%S "}
safe_append_prompt_command prompt_command
+120
View File
@@ -0,0 +1,120 @@
# Mairan Bash Prompt, inspired by "Zork"
if tput setaf 1 &> /dev/null; then
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
MAGENTA=$(tput setaf 9)
ORANGE=$(tput setaf 172)
GREEN=$(tput setaf 190)
PURPLE=$(tput setaf 141)
WHITE=$(tput setaf 0)
else
MAGENTA=$(tput setaf 5)
ORANGE=$(tput setaf 4)
GREEN=$(tput setaf 2)
PURPLE=$(tput setaf 1)
WHITE=$(tput setaf 7)
fi
BOLD=$(tput bold)
RESET=$(tput sgr0)
else
MAGENTA="\033[1;31m"
ORANGE="\033[1;33m"
GREEN="\033[1;32m"
PURPLE="\033[1;35m"
WHITE="\033[1;37m"
BOLD=""
RESET="\033[m"
fi
# prompt_symbol='λ'
# prompt_symbol='⚡'
prompt_symbol=''
BRACKET_COLOR=$ORANGE
SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX=""
SCM_THEME_PROMPT_DIRTY=" ${bold_red}${normal}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}${normal}"
SCM_GIT_CHAR="${bold_green}±${normal}"
SCM_SVN_CHAR="${bold_cyan}${normal}"
SCM_HG_CHAR="${bold_red}${normal}"
#Mysql Prompt
export MYSQL_PS1="(\u@\h) [\d]> "
case $TERM in
xterm*)
TITLEBAR="\[\033]0;\w\007\]"
;;
*)
TITLEBAR=""
;;
esac
PS3=">> "
__my_rvm_ruby_version() {
local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}')
[ "$gemset" != "" ] && gemset="@$gemset"
local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}')
local full="$version$gemset"
[ "$full" != "" ] && echo "[$full]"
}
is_vim_shell() {
if [ ! -z "$VIMRUNTIME" ]
then
echo "[${cyan}vim shell${normal}]"
fi
}
# show chroot if exist
chroot(){
if [ -n "$debian_chroot" ]
then
my_ps_chroot="${bold_cyan}$debian_chroot${normal}";
echo "($my_ps_chroot)";
fi
}
# show virtualenvwrapper
my_ve(){
if [ -n "$VIRTUAL_ENV" ]
then
my_ps_ve="${bold_purple}$ve${normal}";
echo "($my_ps_ve)";
fi
echo "";
}
prompt() {
SCM_PROMPT_FORMAT="[%s$GREEN%s]"
my_ps_host="$BOLD$ORANGE\h${normal}";
# yes, these are the the same for now ...
my_ps_host_root="$ORANGE\h${normal}";
my_ps_user="$BOLD$GREEN\u${normal}"
my_ps_root="${bold_red}\u${normal}";
if [ -n "$VIRTUAL_ENV" ]
then
ve=`basename "$VIRTUAL_ENV"`;
fi
# nice prompt
case "`id -u`" in
0) PS1="\n${TITLEBAR}${BRACKET_COLOR}┌─${normal}$(my_ve)$(chroot)[$my_ps_root][$my_ps_host_root]$(scm_prompt)$(__my_rvm_ruby_version)[${green}\w${normal}]$(is_vim_shell)${BRACKET_COLOR}
└─▪ ${prompt_symbol} ${normal}"
;;
*) PS1="\n${TITLEBAR}${BRACKET_COLOR}┌─${normal}$(my_ve)$(chroot)[$my_ps_user][$my_ps_host]$(scm_prompt)${normal}$(__my_rvm_ruby_version)[${green}\w${normal}]$(is_vim_shell)${BRACKET_COLOR}
└─▪ ${prompt_symbol} ${normal}"
;;
esac
}
PS2="└─▪ "
safe_append_prompt_command prompt
@@ -0,0 +1,34 @@
# ------------------------------------------------------------------#
# FILE: mbriggs.zsh-theme #
# BY: Matt Briggs (matt@mattbriggs.net) #
# BASED ON: smt by Stephen Tudor (stephen@tudorstudio.com) #
# ------------------------------------------------------------------#
SCM_THEME_PROMPT_DIRTY="${red}${reset_color}"
SCM_THEME_PROMPT_AHEAD="${red}!${reset_color}"
SCM_THEME_PROMPT_CLEAN="${green}${reset_color}"
SCM_THEME_PROMPT_PREFIX=" "
SCM_THEME_PROMPT_SUFFIX=""
GIT_SHA_PREFIX=" ${yellow}"
GIT_SHA_SUFFIX="${reset_color}"
function git_short_sha() {
SHA=$(git rev-parse --short HEAD 2> /dev/null) && echo "$GIT_SHA_PREFIX$SHA$GIT_SHA_SUFFIX"
}
function prompt() {
local return_status=""
local ruby="${red}$(ruby_version_prompt)${reset_color}"
local user_host="${green}\h${reset_color}"
local current_path="\w"
local n_commands="\!"
local git_branch="$(git_short_sha)$(scm_prompt_info)"
local prompt_symbol='λ'
local open='('
local close=')'
local prompt_char=' \$ '
PS1="\n${n_commands} ${user_host} ${prompt_symbol} ${ruby} ${open}${current_path}${git_branch}${close}${return_status}\n${prompt_char}"
}
safe_append_prompt_command prompt
+81
View File
@@ -0,0 +1,81 @@
#!/usr/bin/env bash
# Emoji-based theme to display source control management and
# virtual environment info beside the ordinary bash prompt.
# Theme inspired by:
# - Naming your Terminal tabs in OSX Lion - http://thelucid.com/2012/01/04/naming-your-terminal-tabs-in-osx-lion/
# - Bash_it sexy theme
# inspired by previous bash_it theme : cupcake
# Demo:
# ┌ⓔ virtualenv 🐲🤘user @ 💻 host in 🗂️ directory on 🌵 branch {1} ↑1 ↓1 +1 •1 ⌀1 ✗
# └❯ cd .bash-it/themes/cupcake
# virtualenv prompts
VIRTUALENV_CHAR="ⓔ "
VIRTUALENV_THEME_PROMPT_PREFIX=""
VIRTUALENV_THEME_PROMPT_SUFFIX=""
# SCM prompts
SCM_NONE_CHAR=""
SCM_GIT_CHAR="[±] "
SCM_GIT_BEHIND_CHAR="${red}${normal}"
SCM_GIT_AHEAD_CHAR="${bold_green}${normal}"
SCM_GIT_UNTRACKED_CHAR="⌀"
SCM_GIT_UNSTAGED_CHAR="${bold_yellow}${normal}"
SCM_GIT_STAGED_CHAR="${bold_green}+${normal}"
SCM_THEME_PROMPT_DIRTY=""
SCM_THEME_PROMPT_CLEAN=""
SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX=""
# Git status prompts
GIT_THEME_PROMPT_DIRTY=" ${red}${normal}"
GIT_THEME_PROMPT_CLEAN=" ${bold_green}${normal}"
GIT_THEME_PROMPT_PREFIX=""
GIT_THEME_PROMPT_SUFFIX=""
# ICONS =======================================================================
icon_start="┌"
icon_user="🤘-🐧"
icon_host="@ 💻 "
icon_directory=" - 🧱 "
icon_branch="🌵"
icon_end="└🤘-> "
# extra spaces ensure legiblity in prompt
# FUNCTIONS ===================================================================
# Display virtual environment info
function virtualenv_prompt {
if [[ -n "$VIRTUAL_ENV" ]]; then
virtualenv=`basename "$VIRTUAL_ENV"`
echo -e "$VIRTUALENV_CHAR$virtualenv "
fi
}
# Rename tab
function tabname {
printf "\e]1;$1\a"
}
# Rename window
function winname {
printf "\e]2;$1\a"
}
# PROMPT OUTPUT ===============================================================
# Displays the current prompt
function prompt_command() {
PS1="\n${icon_start}$(virtualenv_prompt)${icon_user}${bold_green}\u${normal}${icon_host}${bold_cyan}\h${normal}${icon_directory}${bold_purple}\W${normal}\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on ${icon_branch} \")${white}$(scm_prompt_info)${normal}\n${icon_end}"
PS2="${icon_end}"
}
# Runs prompt (this bypasses bash_it $PROMPT setting)
safe_append_prompt_command prompt_command
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
SCM_THEME_PROMPT_PREFIX="${cyan}(${green}"
SCM_THEME_PROMPT_SUFFIX="${cyan})"
SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${green}"
prompt() {
PS1="$(scm_prompt_info)${reset_color} ${cyan}\W${reset_color} "
}
safe_append_prompt_command prompt
@@ -0,0 +1,54 @@
# The "modern-t" theme is a "modern" theme variant with support
# for "t", the minimalist python todo list utility by Steve Losh.
# Get and install "t" at https://github.com/sjl/t#installing-t
#
# Warning: The Bash-it plugin "todo.plugin" breaks the "t"
# prompt integration, please disable it while using this theme.
SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX=""
SCM_THEME_PROMPT_DIRTY=" ${bold_red}${normal}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}${normal}"
SCM_GIT_CHAR="${bold_green}±${normal}"
SCM_SVN_CHAR="${bold_cyan}${normal}"
SCM_HG_CHAR="${bold_red}${normal}"
case $TERM in
xterm*)
TITLEBAR="\[\033]0;\w\007\]"
;;
*)
TITLEBAR=""
;;
esac
PS3=">> "
is_vim_shell() {
if [ ! -z "$VIMRUNTIME" ]
then
echo "[${cyan}vim shell${normal}]"
fi
}
prompt() {
SCM_PROMPT_FORMAT='[%s][%s]'
if [ $? -ne 0 ]
then
# Yes, the indenting on these is weird, but it has to be like
# this otherwise it won't display properly.
PS1="${TITLEBAR}${bold_red}┌─[${cyan}$(t | wc -l | sed -e's/ *//')${reset_color}]${reset_color}$(scm_prompt)[${cyan}\W${normal}]$(is_vim_shell)
${bold_red}└─▪${normal} "
else
PS1="${TITLEBAR}┌─[${cyan}$(t | wc -l | sed -e's/ *//')${reset_color}]$(scm_prompt)[${cyan}\W${normal}]$(is_vim_shell)
└─▪ "
fi
}
PS2="└─▪ "
safe_append_prompt_command prompt
@@ -0,0 +1,54 @@
# Modified version of the original modern theme in bash-it
# Removes the battery charge and adds the current time
SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX=""
SCM_THEME_PROMPT_DIRTY=" ${bold_red}${normal}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}${normal}"
SCM_GIT_CHAR="${bold_green}±${normal}"
SCM_SVN_CHAR="${bold_cyan}${normal}"
SCM_HG_CHAR="${bold_red}${normal}"
case $TERM in
xterm*)
TITLEBAR="\[\033]0;\w\007\]"
;;
*)
TITLEBAR=""
;;
esac
PS3=">> "
is_vim_shell() {
if [ ! -z "$VIMRUNTIME" ]
then
echo "[${cyan}vim shell${normal}]"
fi
}
modern_current_time_prompt() {
echo "[$(date '+%l:%M%p')]"
}
prompt() {
SCM_PROMPT_FORMAT='[%s][%s]'
if [ $? -ne 0 ]
then
# Yes, the indenting on these is weird, but it has to be like
# this otherwise it won't display properly.
PS1="${TITLEBAR}${bold_red}┌─${reset_color}$(scm_prompt)$(modern_current_time_prompt)[${cyan}\W${normal}]$(is_vim_shell)
${bold_red}└─▪${normal} "
else
PS1="${TITLEBAR}┌─$(scm_prompt)$(modern_current_time_prompt)[${cyan}\W${normal}]$(is_vim_shell)
└─▪ "
fi
}
PS2="└─▪ "
safe_append_prompt_command prompt
@@ -0,0 +1,55 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck disable=SC2154 #TODO: fix these all.
SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX=""
SCM_THEME_PROMPT_DIRTY=" ${bold_red}${normal}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}${normal}"
SCM_GIT_CHAR="${bold_green}±${normal}"
SCM_SVN_CHAR="${bold_cyan}${normal}"
SCM_HG_CHAR="${bold_red}${normal}"
case $TERM in
xterm*)
TITLEBAR="\[\033]0;\w\007\]"
;;
*)
TITLEBAR=""
;;
esac
PS3=">> "
is_vim_shell() {
if [ -n "$VIMRUNTIME" ]; then
echo "[${cyan}vim shell${normal}]"
fi
}
detect_venv() {
python_venv=""
# Detect python venv
if [[ -n "${CONDA_DEFAULT_ENV}" ]]; then
python_venv="($PYTHON_VENV_CHAR${CONDA_DEFAULT_ENV}) "
elif [[ -n "${VIRTUAL_ENV}" ]]; then
python_venv="($PYTHON_VENV_CHAR$(basename "${VIRTUAL_ENV}")) "
fi
}
prompt() {
SCM_PROMPT_FORMAT='[%s][%s]'
retval=$?
if [[ retval -ne 0 ]]; then
PS1="${TITLEBAR}${bold_red}┌─${reset_color}$(scm_prompt)[${cyan}\u${normal}][${cyan}\w${normal}]$(is_vim_shell)\n${bold_red}└─▪${normal} "
else
PS1="${TITLEBAR}┌─$(scm_prompt)[${cyan}\u${normal}][${cyan}\w${normal}]$(is_vim_shell)\n└─▪ "
fi
detect_venv
PS1+="${python_venv}${dir_color}"
}
PS2="└─▪ "
safe_append_prompt_command prompt
@@ -0,0 +1,28 @@
# prompt theming
# added TITLEBAR for updating the tab and window titles with the pwd
case $TERM in
xterm*)
TITLEBAR=$(printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}")
;;
screen)
TITLEBAR=$(printf "\033]0;%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}")
;;
*)
TITLEBAR=""
;;
esac
function prompt_command() {
PS1="${TITLEBAR}[\u@\h \W $(scm_prompt_info)]\$ "
}
# scm theming
SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}"
SCM_THEME_PROMPT_PREFIX="${green}("
SCM_THEME_PROMPT_SUFFIX="${green})${reset_color}"
safe_append_prompt_command prompt_command
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
# n0qorg theme by Florian Baumann <flo@noqqe.de>
## look-a-like
# host directory (branch*)»
# for example:
# ananas ~/Code/bash-it/themes (master*)»
function prompt_command() {
PS1="${bold_blue}[$(hostname)]${normal} \w${normal} ${bold_white}[$(git_prompt_info)]${normal}» "
}
safe_append_prompt_command prompt_command
## git-theme
# feel free to change git chars.
GIT_THEME_PROMPT_DIRTY="${bold_blue}*${bold_white}"
GIT_THEME_PROMPT_CLEAN=""
GIT_THEME_PROMPT_PREFIX="${bold_blue}(${bold_white}"
GIT_THEME_PROMPT_SUFFIX="${bold_blue})"
## alternate chars
#
SCM_THEME_PROMPT_DIRTY="*"
SCM_THEME_PROMPT_CLEAN=""
SCM_THEME_PROMPT_PREFIX="("
SCM_THEME_PROMPT_SUFFIX=")"
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${green}"
SCM_THEME_PROMPT_PREFIX=" ${purple}|${green} "
SCM_THEME_PROMPT_SUFFIX="${purple} |"
prompt() {
exit_code=$?
PS1="$(if [[ ${exit_code} = 0 ]]; then echo "${green}${exit_code}"; else echo "${red}${exit_code}"; fi) ${yellow}\t ${cyan}\w$(scm_prompt_info)${reset_color}\n${orange}$ ${reset_color}"
}
safe_append_prompt_command prompt
+29
View File
@@ -0,0 +1,29 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
function set_prompt_symbol() {
if [[ $1 -eq 0 ]]; then
prompt_symbol=">_"
else
prompt_symbol="${orange?}>_${normal?}"
fi
}
function prompt_command() {
local ret_val="$?" prompt_symbol scm_prompt_info
if [[ -n "${VIRTUAL_ENV:-}" ]]; then
PYTHON_VIRTUALENV="${bold_yellow?}[${VIRTUAL_ENV##*/}]"
fi
scm_prompt_info="$(scm_prompt_info)"
set_prompt_symbol "${ret_val}"
PS1="${bold_orange?}${PYTHON_VIRTUALENV:-}${reset_color?}${bold_green?}[\w]${bold_blue?}[${scm_prompt_info}]${normal?} \n${prompt_symbol} "
}
# scm themeing
SCM_THEME_PROMPT_DIRTY=" ✗"
SCM_THEME_PROMPT_CLEAN=" ✓"
SCM_THEME_PROMPT_PREFIX="["
SCM_THEME_PROMPT_SUFFIX="]"
safe_append_prompt_command prompt_command
@@ -0,0 +1,45 @@
# shellcheck shell=bash
# Two line prompt showing the following information:
# (time) SCM [username@hostname] pwd (SCM branch SCM status)
# →
#
# Example:
# (14:00:26) ± [foo@bar] ~/.bash_it (master ✓)
# →
#
# The arrow on the second line is showing the exit status of the last command:
# * Green: 0 exit status
# * Red: non-zero exit status
#
# The exit code functionality currently doesn't work if you are using the 'fasd' plugin,
# since 'fasd' is messing with the $PROMPT_COMMAND
PROMPT_END_CLEAN="${green}${reset_color}"
PROMPT_END_DIRTY="${red}${reset_color}"
function prompt_end() {
echo -e "$PROMPT_END"
}
prompt_setter() {
local exit_status=$?
if [[ $exit_status -eq 0 ]]; then PROMPT_END=$PROMPT_END_CLEAN
else PROMPT_END=$PROMPT_END_DIRTY
fi
# Save history
_save-and-reload-history 1
PS1="($(clock_prompt)) $(scm_char) [${blue}\u${reset_color}@${green}\H${reset_color}] ${yellow}\w${reset_color}$(scm_prompt_info) ${reset_color}\n$(prompt_end) "
PS2='> '
PS4='+ '
}
safe_append_prompt_command prompt_setter
SCM_THEME_PROMPT_DIRTY=" ${bold_red}${normal}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}${normal}"
SCM_THEME_PROMPT_PREFIX=" ("
SCM_THEME_PROMPT_SUFFIX=")"
RVM_THEME_PROMPT_PREFIX=" ("
RVM_THEME_PROMPT_SUFFIX=")"
@@ -0,0 +1,112 @@
# shellcheck shell=bash
# Two line prompt showing the following information:
# (time) SCM [username@hostname] pwd (SCM branch SCM status)
# →
#
# Example:
# (14:00:26) ± [foo@bar] ~/.bash_it (master ✓)
# →
#
# The arrow on the second line is showing the exit status of the last command:
# * Green: 0 exit status
# * Red: non-zero exit status
#
# The exit code functionality currently doesn't work if you are using the 'fasd' plugin,
# since 'fasd' is messing with the $PROMPT_COMMAND
RANDOM_COLOR_FILE=$HOME/.nwinkler_random_colors
function randomize_nwinkler {
declare -a AVAILABLE_COLORS
AVAILABLE_COLORS=(
$black
$red
$green
$yellow
$blue
$purple
$cyan
$white
$orange
$bold_black
$bold_red
$bold_green
$bold_yellow
$bold_blue
$bold_purple
$bold_cyan
$bold_white
$bold_orange
)
# Uncomment these to allow underlines:
#$underline_black
#$underline_red
#$underline_green
#$underline_yellow
#$underline_blue
#$underline_purple
#$underline_cyan
#$underline_white
#$underline_orange
#)
USERNAME_COLOR=${AVAILABLE_COLORS[$RANDOM % ${#AVAILABLE_COLORS[@]} ]}
HOSTNAME_COLOR=${AVAILABLE_COLORS[$RANDOM % ${#AVAILABLE_COLORS[@]} ]}
TIME_COLOR=${AVAILABLE_COLORS[$RANDOM % ${#AVAILABLE_COLORS[@]} ]}
THEME_CLOCK_COLOR=$TIME_COLOR
PATH_COLOR=${AVAILABLE_COLORS[$RANDOM % ${#AVAILABLE_COLORS[@]} ]}
echo "$USERNAME_COLOR,$HOSTNAME_COLOR,$TIME_COLOR,$PATH_COLOR," > $RANDOM_COLOR_FILE
}
if [ -f $RANDOM_COLOR_FILE ];
then
# read the colors already stored in the file
IFS=',' read -ra COLORS < $RANDOM_COLOR_FILE
USERNAME_COLOR=${COLORS[0]}
HOSTNAME_COLOR=${COLORS[1]}
TIME_COLOR=${COLORS[2]}
THEME_CLOCK_COLOR=$TIME_COLOR
PATH_COLOR=${COLORS[3]}
else
# No colors stored yet. Generate them!
randomize_nwinkler
echo
echo "Looks like you are using the nwinkler_random_color bashit theme for the first time."
echo "Random colors have been generated to be used in your prompt."
echo "If you don't like them, run the command:"
echo " randomize_nwinkler"
echo "until you get a combination that you like."
echo
fi
PROMPT_END_CLEAN="${green}${reset_color}"
PROMPT_END_DIRTY="${red}${reset_color}"
function prompt_end() {
echo -e "$PROMPT_END"
}
prompt_setter() {
local exit_status=$?
if [[ $exit_status -eq 0 ]]; then PROMPT_END=$PROMPT_END_CLEAN
else PROMPT_END=$PROMPT_END_DIRTY
fi
# Save history
_save-and-reload-history 1
PS1="($(clock_prompt)${reset_color}) $(scm_char) [${USERNAME_COLOR}\u${reset_color}@${HOSTNAME_COLOR}\H${reset_color}] ${PATH_COLOR}\w${reset_color}$(scm_prompt_info) ${reset_color}\n$(prompt_end) "
PS2='> '
PS4='+ '
}
safe_append_prompt_command prompt_setter
SCM_THEME_PROMPT_DIRTY=" ${bold_red}${normal}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}${normal}"
SCM_THEME_PROMPT_PREFIX=" ("
SCM_THEME_PROMPT_SUFFIX=")"
RVM_THEME_PROMPT_PREFIX=" ("
RVM_THEME_PROMPT_SUFFIX=")"
@@ -0,0 +1,8 @@
# shellcheck shell=bash
if _command_exists oh-my-posh; then
export POSH_THEME=${POSH_THEME:-https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/v$(oh-my-posh --version)/themes/jandedobbeleer.omp.json}
eval "$(oh-my-posh --init --shell bash --config "${POSH_THEME}")"
else
_log_warning "The oh-my-posh binary was not found on your PATH. Falling back to your existing PS1, please see the docs for more info."
fi
+45
View File
@@ -0,0 +1,45 @@
# shellcheck shell=bash
function _p4-opened {
timeout 2.0s p4 opened -s 2> /dev/null
}
function _p4-opened-counts {
# Return the following counts seperated by tabs:
# - count of opened files
# - count of pending changesets (other than defaults)
# - count of files in the default changeset
# - count of opened files in add mode
# - count of opened files in edit mode
# - count of opened files in delete mode
_p4-opened | awk '
BEGIN {
opened=0;
type_array["edit"]=0;
type_array["add"]=0;
type_array["delete"]=0;
change_array["change"]=0;
}
{
# p4 opened prints one file per line, and all lines begin with "//"
# Here is an examples:
#
# $ p4 opened
# //depot/some/file.py#4 - edit change 716431 (text)
# //depot/another/file.py - edit default change (text)
# //now/add/a/newfile.sh - add change 435645 (text+k)
#
#
if ($1 ~ /^\/\//) {
opened += 1
change_array[$5] += 1
type_array[$3] += 1
}
}
END {
default_changes=change_array["change"];
non_default_changes=length(change_array) - 1;
print opened "\t" non_default_changes "\t" default_changes "\t" type_array["add"] "\t" type_array["edit"] "\t" type_array["delete"]
}
'
}
@@ -0,0 +1,37 @@
# git branch parser
function parse_git_branch() {
echo -e "\033[1;34m$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/')\033[0m"
}
function parse_git_branch_no_color() {
echo -e "$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/')"
}
function prompt() {
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
local force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
local color_prompt=yes
else
local color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1="\[\033[0;31m\]\342\224\214\342\224\200\$([[ \$? != 0 ]] && echo \"[\[\033[0;31m\]\342\234\227\[\033[0;37m\]]\342\224\200\")[$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]root\[\033[01;33m\]@\[\033[01;96m\]\h'; else echo '\[\033[0;39m\]\u\[\033[01;33m\]@\[\033[01;96m\]\h'; fi)\[\033[0;31m\]]\342\224\200[\[\033[0;32m\]\w\[\033[0;31m\]]\n\[\033[0;31m\]\342\224\224\342\224\200\342\224\200\342\225\274 \[\033[0m\]\[\e[01;33m\]$(parse_git_branch) $\[\e[0m\] "
else
PS1='┌──[\u@\h]─[\w]\n└──╼ $(parse_git_branch_no_color) $ '
fi
}
safe_append_prompt_command prompt
+23
View File
@@ -0,0 +1,23 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
function prompt_setter() {
local clock_prompt scm_char scm_prompt_info ruby_version_prompt
clock_prompt="$(clock_prompt)"
scm_char="$(scm_char)"
scm_prompt_info="$(scm_prompt_info)"
ruby_version_prompt="$(ruby_version_prompt)"
_save-and-reload-history 1 # Save history
PS1="(${clock_prompt}) ${scm_char} [${blue?}\u${reset_color?}@${green?}\H${reset_color?}] ${yellow?}\w${reset_color?}${scm_prompt_info}${ruby_version_prompt} ${reset_color?} "
PS2='> '
PS4='+ '
}
safe_append_prompt_command prompt_setter
SCM_THEME_PROMPT_DIRTY=" ✗"
SCM_THEME_PROMPT_CLEAN=" ✓"
SCM_THEME_PROMPT_PREFIX=" ("
SCM_THEME_PROMPT_SUFFIX=")"
RVM_THEME_PROMPT_PREFIX=" ("
RVM_THEME_PROMPT_SUFFIX=")"
@@ -0,0 +1,106 @@
. "$BASH_IT/themes/powerline/powerline.base.bash"
function __powerline_last_status_prompt {
[[ "$1" -ne 0 ]] && echo "$(set_color ${LAST_STATUS_THEME_PROMPT_COLOR} -) ${1} ${normal}"
}
function __powerline_right_segment {
local OLD_IFS="${IFS}"; IFS="|"
local params=( $1 )
IFS="${OLD_IFS}"
local padding=0
local pad_before_segment=" "
if [[ "${SEGMENTS_AT_RIGHT}" -eq 0 ]]; then
if [[ "${POWERLINE_COMPACT_AFTER_LAST_SEGMENT}" -ne 0 ]]; then
pad_before_segment=""
fi
RIGHT_PROMPT+="$(set_color ${params[1]} -)${POWERLINE_RIGHT_END}${normal}"
(( padding += 1 ))
else
if [[ "${POWERLINE_COMPACT_BEFORE_SEPARATOR}" -ne 0 ]]; then
pad_before_segment=""
fi
# Since the previous segment wasn't the last segment, add padding, if needed
#
if [[ "${POWERLINE_COMPACT_AFTER_SEPARATOR}" -eq 0 ]]; then
RIGHT_PROMPT+="$(set_color - ${LAST_SEGMENT_COLOR}) ${normal}"
(( padding += 1 ))
fi
if [[ "${LAST_SEGMENT_COLOR}" -eq "${params[1]}" ]]; then
RIGHT_PROMPT+="$(set_color - ${LAST_SEGMENT_COLOR})${POWERLINE_RIGHT_SEPARATOR_SOFT}${normal}"
else
RIGHT_PROMPT+="$(set_color ${params[1]} ${LAST_SEGMENT_COLOR})${POWERLINE_RIGHT_SEPARATOR}${normal}"
fi
(( padding += 1 ))
fi
RIGHT_PROMPT+="$(set_color - ${params[1]})${pad_before_segment}${params[0]}${normal}"
(( padding += ${#pad_before_segment} ))
(( padding += ${#params[0]} ))
(( RIGHT_PROMPT_LENGTH += padding ))
LAST_SEGMENT_COLOR="${params[1]}"
(( SEGMENTS_AT_RIGHT += 1 ))
}
function __powerline_right_first_segment_padding {
RIGHT_PROMPT+="$(set_color - ${LAST_SEGMENT_COLOR}) ${normal}"
(( RIGHT_PROMPT_LENGTH += 1 ))
}
function __powerline_prompt_command {
local last_status="$?" ## always the first
local move_cursor_rightmost='\033[500C'
LEFT_PROMPT=""
RIGHT_PROMPT=""
RIGHT_PROMPT_LENGTH=${POWERLINE_PADDING}
SEGMENTS_AT_LEFT=0
SEGMENTS_AT_RIGHT=0
LAST_SEGMENT_COLOR=""
_save-and-reload-history "${HISTORY_AUTOSAVE:-0}"
## left prompt ##
for segment in $POWERLINE_LEFT_PROMPT; do
local info="$(__powerline_${segment}_prompt)"
[[ -n "${info}" ]] && __powerline_left_segment "${info}"
done
if [[ -n "${LEFT_PROMPT}" ]] && [[ "${POWERLINE_COMPACT_AFTER_LAST_SEGMENT}" -eq 0 ]]; then
__powerline_left_last_segment_padding
fi
[[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="$(set_color ${LAST_SEGMENT_COLOR} -)${POWERLINE_LEFT_END}${normal}"
## right prompt ##
if [[ -n "${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}"
done
if [[ -n "${RIGHT_PROMPT}" ]] && [[ "${POWERLINE_COMPACT_BEFORE_FIRST_SEGMENT}" -eq 0 ]]; then
__powerline_right_first_segment_padding
fi
RIGHT_PAD=$(printf "%.s " $(seq 1 $RIGHT_PROMPT_LENGTH))
LEFT_PROMPT+="${RIGHT_PAD}${move_cursor_rightmost}"
LEFT_PROMPT+="\033[$(( ${#RIGHT_PAD} - 1 ))D"
fi
local prompt="${PROMPT_CHAR}"
if [[ "${POWERLINE_COMPACT_PROMPT}" -eq 0 ]]; then
prompt+=" "
fi
PS1="${LEFT_PROMPT}${RIGHT_PROMPT}\n$(__powerline_last_status_prompt ${last_status})${prompt}"
## cleanup ##
unset LAST_SEGMENT_COLOR \
LEFT_PROMPT RIGHT_PROMPT RIGHT_PROMPT_LENGTH \
SEGMENTS_AT_LEFT SEGMENTS_AT_RIGHT
}
@@ -0,0 +1,105 @@
#!/usr/bin/env bash
. "$BASH_IT/themes/powerline-multiline/powerline-multiline.base.bash"
PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:=""}
POWERLINE_LEFT_SEPARATOR=${POWERLINE_LEFT_SEPARATOR:=""}
POWERLINE_LEFT_SEPARATOR_SOFT=${POWERLINE_LEFT_SEPARATOR_SOFT:=""}
POWERLINE_RIGHT_SEPARATOR=${POWERLINE_RIGHT_SEPARATOR:=""}
POWERLINE_RIGHT_SEPARATOR_SOFT=${POWERLINE_RIGHT_SEPARATOR_SOFT:=""}
POWERLINE_LEFT_END=${POWERLINE_LEFT_END:=""}
POWERLINE_RIGHT_END=${POWERLINE_RIGHT_END:=""}
POWERLINE_PADDING=${POWERLINE_PADDING:=2}
POWERLINE_COMPACT=${POWERLINE_COMPACT:=0}
POWERLINE_COMPACT_BEFORE_SEPARATOR=${POWERLINE_COMPACT_BEFORE_SEPARATOR:=${POWERLINE_COMPACT}}
POWERLINE_COMPACT_AFTER_SEPARATOR=${POWERLINE_COMPACT_AFTER_SEPARATOR:=${POWERLINE_COMPACT}}
POWERLINE_COMPACT_BEFOR_FIRST_SEGMENT=${POWERLINE_COMPACT_BEFORE_FIRST_SEGMENT:=${POWERLINE_COMPACT}}
POWERLINE_COMPACT_AFTER_LAST_SEGMENT=${POWERLINE_COMPACT_AFTER_LAST_SEGMENT:=${POWERLINE_COMPACT}}
POWERLINE_COMPACT_PROMPT=${POWERLINE_COMPACT_PROMPT:=${POWERLINE_COMPACT}}
USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "}
USER_INFO_THEME_PROMPT_COLOR=${POWERLINE_USER_INFO_COLOR:=32}
USER_INFO_THEME_PROMPT_COLOR_SUDO=${POWERLINE_USER_INFO_COLOR_SUDO:=202}
PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:="p "}
CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="c "}
PYTHON_VENV_THEME_PROMPT_COLOR=${POWERLINE_PYTHON_VENV_COLOR:=35}
SCM_NONE_CHAR=""
SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "}
SCM_HG_CHAR=${POWERLINE_SCM_HG_CHAR:="☿ "}
SCM_THEME_PROMPT_CLEAN=""
SCM_THEME_PROMPT_DIRTY=""
SCM_THEME_PROMPT_CLEAN_COLOR=${POWERLINE_SCM_CLEAN_COLOR:=25}
SCM_THEME_PROMPT_DIRTY_COLOR=${POWERLINE_SCM_DIRTY_COLOR:=88}
SCM_THEME_PROMPT_STAGED_COLOR=${POWERLINE_SCM_STAGED_COLOR:=30}
SCM_THEME_PROMPT_UNSTAGED_COLOR=${POWERLINE_SCM_UNSTAGED_COLOR:=92}
SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR}
NVM_THEME_PROMPT_PREFIX=""
NVM_THEME_PROMPT_SUFFIX=""
NODE_CHAR=${POWERLINE_NODE_CHAR:="n "}
NODE_THEME_PROMPT_COLOR=${POWERLINE_NODE_COLOR:=22}
RVM_THEME_PROMPT_PREFIX=""
RVM_THEME_PROMPT_SUFFIX=""
RBENV_THEME_PROMPT_PREFIX=""
RBENV_THEME_PROMPT_SUFFIX=""
RUBY_THEME_PROMPT_COLOR=${POWERLINE_RUBY_COLOR:=161}
RUBY_CHAR=${POWERLINE_RUBY_CHAR:="r "}
TERRAFORM_THEME_PROMPT_COLOR=${POWERLINE_TERRAFORM_COLOR:=161}
TERRAFORM_CHAR=${POWERLINE_TERRAFORM_CHAR:="t "}
KUBERNETES_CONTEXT_THEME_CHAR=${POWERLINE_KUBERNETES_CONTEXT_CHAR:="⎈ "}
KUBERNETES_CONTEXT_THEME_PROMPT_COLOR=${POWERLINE_KUBERNETES_CONTEXT_COLOR:=26}
KUBERNETES_NAMESPACE_THEME_CHAR=${POWERLINE_KUBERNETES_NAMESPACE_CHAR:="⎈ "}
KUBERNETES_NAMESPACE_THEME_PROMPT_COLOR=${POWERLINE_KUBERNETES_NAMESPACE_COLOR:=64}
AWS_PROFILE_CHAR=${POWERLINE_AWS_PROFILE_CHAR:="aws "}
AWS_PROFILE_PROMPT_COLOR=${POWERLINE_AWS_PROFILE_COLOR:=208}
CWD_THEME_PROMPT_COLOR=${POWERLINE_CWD_COLOR:=240}
LAST_STATUS_THEME_PROMPT_COLOR=${POWERLINE_LAST_STATUS_COLOR:=196}
CLOCK_THEME_PROMPT_COLOR=${POWERLINE_CLOCK_COLOR:=240}
BATTERY_AC_CHAR=${BATTERY_AC_CHAR:="⚡"}
BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=${POWERLINE_BATTERY_GOOD_COLOR:=70}
BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=${POWERLINE_BATTERY_LOW_COLOR:=208}
BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=${POWERLINE_BATTERY_CRITICAL_COLOR:=160}
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
IN_VIM_THEME_PROMPT_COLOR=${POWERLINE_IN_VIM_COLOR:=245}
IN_VIM_THEME_PROMPT_TEXT=${POWERLINE_IN_VIM_TEXT:="vim"}
IN_TOOLBOX_THEME_PROMPT_COLOR=${POWERLINE_IN_TOOLBOX_COLOR:=125}
IN_TOOLBOX_THEME_PROMPT_TEXT=${POWERLINE_IN_TOOLBOX_TEXT:="⬢ "}
HOST_THEME_PROMPT_COLOR=${POWERLINE_HOST_COLOR:=0}
SHLVL_THEME_PROMPT_COLOR=${POWERLINE_SHLVL_COLOR:=${HOST_THEME_PROMPT_COLOR}}
SHLVL_THEME_PROMPT_CHAR=${POWERLINE_SHLVL_CHAR:="§"}
DIRSTACK_THEME_PROMPT_COLOR=${POWERLINE_DIRSTACK_COLOR:=${CWD_THEME_PROMPT_COLOR}}
DIRSTACK_THEME_PROMPT_CHAR=${POWERLINE_DIRSTACK_CHAR:="←"}
HISTORY_NUMBER_THEME_PROMPT_COLOR=${POWERLINE_HISTORY_NUMBER_COLOR:=0}
HISTORY_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_HISTORY_NUMBER_CHAR:="#"}
COMMAND_NUMBER_THEME_PROMPT_COLOR=${POWERLINE_COMMAND_NUMBER_COLOR:=0}
COMMAND_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_COMMAND_NUMBER_CHAR:="#"}
GCLOUD_THEME_PROMPT_COLOR=${POWERLINE_GCLOUD_COLOR:=161}
GCLOUD_CHAR=${POWERLINE_GCLOUD_CHAR:="G "}
COMMAND_DURATION_PROMPT_COLOR=${POWERLINE_COMMAND_DURATION_COLOR:=129}
POWERLINE_LEFT_PROMPT=${POWERLINE_LEFT_PROMPT:="scm python_venv ruby node cwd"}
POWERLINE_RIGHT_PROMPT=${POWERLINE_RIGHT_PROMPT:="in_vim clock battery user_info"}
safe_append_prompt_command __powerline_prompt_command
@@ -0,0 +1,35 @@
. "$BASH_IT/themes/powerline/powerline.base.bash"
function __powerline_left_segment {
local OLD_IFS="${IFS}"; IFS="|"
local params=( $1 )
IFS="${OLD_IFS}"
local separator=""
local pad_before_segment=" "
if [[ "${SEGMENTS_AT_LEFT}" -eq 0 ]]; then
if [[ "${POWERLINE_COMPACT_BEFORE_FIRST_SEGMENT}" -ne 0 ]]; then
pad_before_segment=""
fi
else
if [[ "${POWERLINE_COMPACT_AFTER_SEPARATOR}" -ne 0 ]]; then
pad_before_segment=""
fi
# Since the previous segment wasn't the last segment, add padding, if needed
#
if [[ "${POWERLINE_COMPACT_BEFORE_SEPARATOR}" -eq 0 ]]; then
LEFT_PROMPT+=" "
fi
LEFT_PROMPT+="${POWERLINE_LEFT_SEPARATOR}"
fi
LEFT_PROMPT+="$(set_color ${params[1]} -)${pad_before_segment}${params[0]}${normal}"
LAST_SEGMENT_COLOR=${params[1]}
(( SEGMENTS_AT_LEFT += 1 ))
_save-and-reload-history "${HISTORY_AUTOSAVE:-0}"
}
function __powerline_left_last_segment_padding {
LEFT_PROMPT+="$(set_color ${LAST_SEGMENT_COLOR} -) ${normal}"
}
@@ -0,0 +1,97 @@
#!/usr/bin/env bash
. "$BASH_IT/themes/powerline-naked/powerline-naked.base.bash"
PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:=""}
POWERLINE_LEFT_SEPARATOR=${POWERLINE_LEFT_SEPARATOR:=""}
POWERLINE_LEFT_LAST_SEGMENT_PROMPT_CHAR=""
POWERLINE_COMPACT=${POWERLINE_COMPACT:=0}
POWERLINE_COMPACT_BEFORE_SEPARATOR=${POWERLINE_COMPACT_BEFORE_SEPARATOR:=${POWERLINE_COMPACT}}
POWERLINE_COMPACT_AFTER_SEPARATOR=${POWERLINE_COMPACT_AFTER_SEPARATOR:=${POWERLINE_COMPACT}}
POWERLINE_COMPACT_BEFOR_FIRST_SEGMENT=${POWERLINE_COMPACT_BEFORE_FIRST_SEGMENT:=${POWERLINE_COMPACT}}
POWERLINE_COMPACT_AFTER_LAST_SEGMENT=${POWERLINE_COMPACT_AFTER_LAST_SEGMENT:=${POWERLINE_COMPACT}}
POWERLINE_COMPACT_PROMPT=${POWERLINE_COMPACT_PROMPT:=${POWERLINE_COMPACT}}
USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "}
USER_INFO_THEME_PROMPT_COLOR=${POWERLINE_USER_INFO_COLOR:=240}
USER_INFO_THEME_PROMPT_COLOR_SUDO=${POWERLINE_USER_INFO_COLOR_SUDO:=202}
PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:="p "}
CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="c "}
PYTHON_VENV_THEME_PROMPT_COLOR=${POWERLINE_PYTHON_VENV_COLOR:=35}
SCM_NONE_CHAR=""
SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "}
SCM_HG_CHAR=${POWERLINE_SCM_HG_CHAR:="☿ "}
SCM_THEME_PROMPT_CLEAN=""
SCM_THEME_PROMPT_DIRTY=""
SCM_THEME_PROMPT_CLEAN_COLOR=${POWERLINE_SCM_CLEAN_COLOR:=25}
SCM_THEME_PROMPT_DIRTY_COLOR=${POWERLINE_SCM_DIRTY_COLOR:=88}
SCM_THEME_PROMPT_STAGED_COLOR=${POWERLINE_SCM_STAGED_COLOR:=30}
SCM_THEME_PROMPT_UNSTAGED_COLOR=${POWERLINE_SCM_UNSTAGED_COLOR:=92}
SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR}
NVM_THEME_PROMPT_PREFIX=""
NVM_THEME_PROMPT_SUFFIX=""
NODE_CHAR=${POWERLINE_NODE_CHAR:="n "}
NODE_THEME_PROMPT_COLOR=${POWERLINE_NODE_COLOR:=22}
RVM_THEME_PROMPT_PREFIX=""
RVM_THEME_PROMPT_SUFFIX=""
RBENV_THEME_PROMPT_PREFIX=""
RBENV_THEME_PROMPT_SUFFIX=""
RUBY_THEME_PROMPT_COLOR=${POWERLINE_RUBY_COLOR:=161}
RUBY_CHAR=${POWERLINE_RUBY_CHAR:="r "}
TERRAFORM_THEME_PROMPT_COLOR=${POWERLINE_TERRAFORM_COLOR:=161}
TERRAFORM_CHAR=${POWERLINE_TERRAFORM_CHAR:="t "}
KUBERNETES_CONTEXT_THEME_CHAR=${POWERLINE_KUBERNETES_CONTEXT_CHAR:="⎈ "}
KUBERNETES_CONTEXT_THEME_PROMPT_COLOR=${POWERLINE_KUBERNETES_CONTEXT_COLOR:=26}
KUBERNETES_NAMESPACE_THEME_CHAR=${POWERLINE_KUBERNETES_NAMESPACE_CHAR:="⎈ "}
KUBERNETES_NAMESPACE_THEME_PROMPT_COLOR=${POWERLINE_KUBERNETES_NAMESPACE_COLOR:=64}
AWS_PROFILE_CHAR=${POWERLINE_AWS_PROFILE_CHAR:="aws "}
AWS_PROFILE_PROMPT_COLOR=${POWERLINE_AWS_PROFILE_COLOR:=208}
CWD_THEME_PROMPT_COLOR=${POWERLINE_CWD_COLOR:=254}
LAST_STATUS_THEME_PROMPT_COLOR=${POWERLINE_LAST_STATUS_COLOR:=124}
CLOCK_THEME_PROMPT_COLOR=${POWERLINE_CLOCK_COLOR:=240}
BATTERY_AC_CHAR=${BATTERY_AC_CHAR:="⚡"}
BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=${POWERLINE_BATTERY_GOOD_COLOR:=70}
BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=${POWERLINE_BATTERY_LOW_COLOR:=208}
BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=${POWERLINE_BATTERY_CRITICAL_COLOR:=160}
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
IN_VIM_THEME_PROMPT_COLOR=${POWERLINE_IN_VIM_COLOR:=245}
IN_VIM_THEME_PROMPT_TEXT=${POWERLINE_IN_VIM_TEXT:="vim"}
IN_TOOLBOX_THEME_PROMPT_COLOR=${POWERLINE_IN_TOOLBOX_COLOR:=125}
IN_TOOLBOX_THEME_PROMPT_TEXT=${POWERLINE_IN_TOOLBOX_TEXT:="⬢ "}
HOST_THEME_PROMPT_COLOR=${POWERLINE_HOST_COLOR:=254}
SHLVL_THEME_PROMPT_COLOR=${POWERLINE_SHLVL_COLOR:=${HOST_THEME_PROMPT_COLOR}}
SHLVL_THEME_PROMPT_CHAR=${POWERLINE_SHLVL_CHAR:="§"}
DIRSTACK_THEME_PROMPT_COLOR=${POWERLINE_DIRSTACK_COLOR:=${CWD_THEME_PROMPT_COLOR}}
DIRSTACK_THEME_PROMPT_CHAR=${POWERLINE_DIRSTACK_CHAR:="←"}
HISTORY_NUMBER_THEME_PROMPT_COLOR=${POWERLINE_HISTORY_NUMBER_COLOR:=254}
HISTORY_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_HISTORY_NUMBER_CHAR:="#"}
COMMAND_NUMBER_THEME_PROMPT_COLOR=${POWERLINE_COMMAND_NUMBER_COLOR:=254}
COMMAND_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_COMMAND_NUMBER_CHAR:="#"}
GCLOUD_THEME_PROMPT_COLOR=${POWERLINE_GCLOUD_COLOR:=161}
GCLOUD_CHAR=${POWERLINE_GCLOUD_CHAR:="G "}
POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby node cwd"}
safe_append_prompt_command __powerline_prompt_command
@@ -0,0 +1,61 @@
. "$BASH_IT/themes/powerline/powerline.base.bash"
function __powerline_left_segment {
local OLD_IFS="${IFS}"; IFS="|"
local params=( $1 )
IFS="${OLD_IFS}"
local pad_before_segment=" "
if [[ "${SEGMENTS_AT_LEFT}" -eq 0 ]]; then
if [[ "${POWERLINE_COMPACT_BEFORE_FIRST_SEGMENT}" -ne 0 ]]; then
pad_before_segment=""
fi
else
if [[ "${POWERLINE_COMPACT_AFTER_SEPARATOR}" -ne 0 ]]; then
pad_before_segment=""
fi
# Since the previous segment wasn't the last segment, add padding, if needed
#
if [[ "${POWERLINE_COMPACT_BEFORE_SEPARATOR}" -eq 0 ]]; then
LEFT_PROMPT+="$(set_color - ${LAST_SEGMENT_COLOR}) ${normal}"
fi
fi
LEFT_PROMPT+="$(set_color - ${params[1]})${pad_before_segment}${params[0]}${normal}"
LAST_SEGMENT_COLOR=${params[1]}
(( SEGMENTS_AT_LEFT += 1 ))
}
function __powerline_prompt_command {
local last_status="$?" ## always the first
LEFT_PROMPT=""
SEGMENTS_AT_LEFT=0
LAST_SEGMENT_COLOR=""
PROMPT_AFTER="${POWERLINE_PROMPT_AFTER}"
_save-and-reload-history "${HISTORY_AUTOSAVE:-0}"
## left prompt ##
for segment in $POWERLINE_PROMPT; do
local info="$(__powerline_${segment}_prompt)"
[[ -n "${info}" ]] && __powerline_left_segment "${info}"
done
[[ "${last_status}" -ne 0 ]] && __powerline_left_segment $(__powerline_last_status_prompt ${last_status})
if [[ -n "${LEFT_PROMPT}" ]] && [[ "${POWERLINE_COMPACT_AFTER_LAST_SEGMENT}" -eq 0 ]]; then
__powerline_left_last_segment_padding
fi
if [[ "${POWERLINE_COMPACT_PROMPT}" -eq 0 ]]; then
LEFT_PROMPT+=" "
fi
PS1="${LEFT_PROMPT}${PROMPT_AFTER}"
## cleanup ##
unset LAST_SEGMENT_COLOR \
LEFT_PROMPT \
SEGMENTS_AT_LEFT
}
@@ -0,0 +1,94 @@
#!/usr/bin/env bash
. "$BASH_IT/themes/powerline-plain/powerline-plain.base.bash"
USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:="⌁ "}
USER_INFO_THEME_PROMPT_COLOR=${POWERLINE_USER_INFO_COLOR:=32}
USER_INFO_THEME_PROMPT_COLOR_SUDO=${POWERLINE_USER_INFO_COLOR_SUDO:=202}
POWERLINE_COMPACT=${POWERLINE_COMPACT:=0}
POWERLINE_COMPACT_BEFORE_SEPARATOR=${POWERLINE_COMPACT_BEFORE_SEPARATOR:=${POWERLINE_COMPACT}}
POWERLINE_COMPACT_AFTER_SEPARATOR=${POWERLINE_COMPACT_AFTER_SEPARATOR:=${POWERLINE_COMPACT}}
POWERLINE_COMPACT_BEFOR_FIRST_SEGMENT=${POWERLINE_COMPACT_BEFORE_FIRST_SEGMENT:=${POWERLINE_COMPACT}}
POWERLINE_COMPACT_AFTER_LAST_SEGMENT=${POWERLINE_COMPACT_AFTER_LAST_SEGMENT:=${POWERLINE_COMPACT}}
POWERLINE_COMPACT_PROMPT=${POWERLINE_COMPACT_PROMPT:=${POWERLINE_COMPACT}}
POWERLINE_PROMPT_AFTER=${POWERLINE_PROMPT_AFTER:-""}
PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:="ⓔ "}
CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="ⓔ "}
PYTHON_VENV_THEME_PROMPT_COLOR=${POWERLINE_PYTHON_VENV_COLOR:=35}
SCM_NONE_CHAR=""
SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:="⎇ "}
SCM_HG_CHAR=${POWERLINE_SCM_HG_CHAR:="☿ "}
SCM_THEME_PROMPT_CLEAN=""
SCM_THEME_PROMPT_DIRTY=""
SCM_THEME_PROMPT_CLEAN_COLOR=${POWERLINE_SCM_CLEAN_COLOR:=25}
SCM_THEME_PROMPT_DIRTY_COLOR=${POWERLINE_SCM_DIRTY_COLOR:=88}
SCM_THEME_PROMPT_STAGED_COLOR=${POWERLINE_SCM_STAGED_COLOR:=30}
SCM_THEME_PROMPT_UNSTAGED_COLOR=${POWERLINE_SCM_UNSTAGED_COLOR:=92}
SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR}
NVM_THEME_PROMPT_PREFIX=""
NVM_THEME_PROMPT_SUFFIX=""
NODE_CHAR=${POWERLINE_NODE_CHAR:="n "}
NODE_THEME_PROMPT_COLOR=${POWERLINE_NODE_COLOR:=22}
RVM_THEME_PROMPT_PREFIX=""
RVM_THEME_PROMPT_SUFFIX=""
RBENV_THEME_PROMPT_PREFIX=""
RBENV_THEME_PROMPT_SUFFIX=""
RUBY_THEME_PROMPT_COLOR=${POWERLINE_RUBY_COLOR:=161}
RUBY_CHAR=${POWERLINE_RUBY_CHAR:="💎 "}
TERRAFORM_THEME_PROMPT_COLOR=${POWERLINE_TERRAFORM_COLOR:=161}
TERRAFORM_CHAR=${POWERLINE_TERRAFORM_CHAR:="t "}
KUBERNETES_CONTEXT_THEME_CHAR=${POWERLINE_KUBERNETES_CONTEXT_CHAR:="⎈ "}
KUBERNETES_CONTEXT_THEME_PROMPT_COLOR=${POWERLINE_KUBERNETES_CONTEXT_COLOR:=26}
KUBERNETES_NAMESPACE_THEME_CHAR=${POWERLINE_KUBERNETES_NAMESPACE_CHAR:="⎈ "}
KUBERNETES_NAMESPACE_THEME_PROMPT_COLOR=${POWERLINE_KUBERNETES_NAMESPACE_COLOR:=60}
AWS_PROFILE_CHAR=${POWERLINE_AWS_PROFILE_CHAR:="aws "}
AWS_PROFILE_PROMPT_COLOR=${POWERLINE_AWS_PROFILE_COLOR:=208}
CWD_THEME_PROMPT_COLOR=${POWERLINE_CWD_COLOR:=240}
LAST_STATUS_THEME_PROMPT_COLOR=${POWERLINE_LAST_STATUS_COLOR:=52}
CLOCK_THEME_PROMPT_COLOR=${POWERLINE_CLOCK_COLOR:=240}
BATTERY_AC_CHAR=${BATTERY_AC_CHAR:="+ "}
BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=${POWERLINE_BATTERY_GOOD_COLOR:=70}
BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=${POWERLINE_BATTERY_LOW_COLOR:=208}
BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=${POWERLINE_BATTERY_CRITICAL_COLOR:=160}
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
IN_VIM_THEME_PROMPT_COLOR=${POWERLINE_IN_VIM_COLOR:=245}
IN_VIM_THEME_PROMPT_TEXT=${POWERLINE_IN_VIM_TEXT:="vim"}
IN_TOOLBOX_THEME_PROMPT_COLOR=${POWERLINE_IN_TOOLBOX_COLOR:=125}
IN_TOOLBOX_THEME_PROMPT_TEXT=${POWERLINE_IN_TOOLBOX_TEXT:="⬢ "}
HOST_THEME_PROMPT_COLOR=${POWERLINE_HOST_COLOR:=0}
SHLVL_THEME_PROMPT_COLOR=${POWERLINE_SHLVL_COLOR:=${HOST_THEME_PROMPT_COLOR}}
SHLVL_THEME_PROMPT_CHAR=${POWERLINE_SHLVL_CHAR:="§"}
DIRSTACK_THEME_PROMPT_COLOR=${POWERLINE_DIRSTACK_COLOR:=${CWD_THEME_PROMPT_COLOR}}
DIRSTACK_THEME_PROMPT_CHAR=${POWERLINE_DIRSTACK_CHAR:="←"}
HISTORY_NUMBER_THEME_PROMPT_COLOR=${POWERLINE_HISTORY_NUMBER_COLOR:=0}
HISTORY_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_HISTORY_NUMBER_CHAR:="#"}
COMMAND_NUMBER_THEME_PROMPT_COLOR=${POWERLINE_COMMAND_NUMBER_COLOR:=0}
COMMAND_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_COMMAND_NUMBER_CHAR:="#"}
GCLOUD_THEME_PROMPT_COLOR=${POWERLINE_GCLOUD_COLOR:=161}
GCLOUD_CHAR=${POWERLINE_GCLOUD_CHAR:="G "}
POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby node cwd"}
safe_append_prompt_command __powerline_prompt_command
@@ -0,0 +1,308 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
function set_color() {
local fg='' bg=''
if [[ "${1:-}" != "-" ]]; then
fg="38;5;${1}"
fi
if [[ "${2:-}" != "-" ]]; then
bg="48;5;${2}"
[[ -n "${fg}" ]] && bg=";${bg}"
fi
echo -e "\[\033[${fg}${bg}m\]"
}
function __powerline_user_info_prompt() {
local user_info=""
local color=${USER_INFO_THEME_PROMPT_COLOR}
if [[ "${THEME_CHECK_SUDO}" = true ]]; then
sudo -vn 1> /dev/null 2>&1 && color=${USER_INFO_THEME_PROMPT_COLOR_SUDO}
fi
case "${POWERLINE_PROMPT_USER_INFO_MODE}" in
"sudo")
if [[ "${color}" = "${USER_INFO_THEME_PROMPT_COLOR_SUDO}" ]]; then
user_info="!"
fi
;;
*)
local user=${SHORT_USER:-${USER}}
if [[ -n "${SSH_CLIENT}" ]] || [[ -n "${SSH_CONNECTION}" ]]; then
user_info="${USER_INFO_SSH_CHAR}${user}"
else
user_info="${user}"
fi
;;
esac
[[ -n "${user_info}" ]] && echo "${user_info}|${color}"
}
function __powerline_terraform_prompt() {
local terraform_workspace=""
if [ -d .terraform ]; then
terraform_workspace="$(terraform_workspace_prompt)"
[[ -n "${terraform_workspace}" ]] && echo "${TERRAFORM_CHAR}${terraform_workspace}|${TERRAFORM_THEME_PROMPT_COLOR}"
fi
}
function __powerline_gcloud_prompt() {
local active_gcloud_account=""
active_gcloud_account="$(active_gcloud_account_prompt)"
[[ -n "${active_gcloud_account}" ]] && echo "${GCLOUD_CHAR}${active_gcloud_account}|${GCLOUD_THEME_PROMPT_COLOR}"
}
function __powerline_node_prompt() {
local node_version=""
node_version="$(node_version_prompt)"
[[ -n "${node_version}" ]] && echo "${NODE_CHAR}${node_version}|${NODE_THEME_PROMPT_COLOR}"
}
function __powerline_ruby_prompt() {
local ruby_version=""
if _command_exists rvm; then
ruby_version="$(rvm_version_prompt)"
elif _command_exists rbenv; then
ruby_version=$(rbenv_version_prompt)
fi
[[ -n "${ruby_version}" ]] && echo "${RUBY_CHAR}${ruby_version}|${RUBY_THEME_PROMPT_COLOR}"
}
function __powerline_k8s_context_prompt() {
local kubernetes_context=""
if _command_exists kubectl; then
kubernetes_context="$(k8s_context_prompt)"
fi
[[ -n "${kubernetes_context}" ]] && echo "${KUBERNETES_CONTEXT_THEME_CHAR}${kubernetes_context}|${KUBERNETES_CONTEXT_THEME_PROMPT_COLOR}"
}
function __powerline_k8s_namespace_prompt() {
local kubernetes_namespace=""
if _command_exists kubectl; then
kubernetes_namespace="$(k8s_namespace_prompt)"
fi
[[ -n "${kubernetes_namespace}" ]] && echo "${KUBERNETES_NAMESPACE_THEME_CHAR}${kubernetes_namespace}|${KUBERNETES_NAMESPACE_THEME_PROMPT_COLOR}"
}
function __powerline_python_venv_prompt() {
local python_venv=""
if [[ -n "${CONDA_DEFAULT_ENV:-}" ]]; then
python_venv="${CONDA_DEFAULT_ENV}"
PYTHON_VENV_CHAR=${CONDA_PYTHON_VENV_CHAR}
elif [[ -n "${VIRTUAL_ENV:-}" ]]; then
python_venv="${VIRTUAL_ENV##*/}"
fi
[[ -n "${python_venv}" ]] && echo "${PYTHON_VENV_CHAR}${python_venv}|${PYTHON_VENV_THEME_PROMPT_COLOR}"
}
function __powerline_scm_prompt() {
local color=""
local scm_prompt=""
scm_prompt_vars
if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then
if [[ "${SCM_DIRTY}" -eq 3 ]]; then
color=${SCM_THEME_PROMPT_STAGED_COLOR}
elif [[ "${SCM_DIRTY}" -eq 2 ]]; then
color=${SCM_THEME_PROMPT_UNSTAGED_COLOR}
elif [[ "${SCM_DIRTY}" -eq 1 ]]; then
color=${SCM_THEME_PROMPT_DIRTY_COLOR}
else
color=${SCM_THEME_PROMPT_CLEAN_COLOR}
fi
if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then
scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
elif [[ "${SCM_P4_CHAR}" == "${SCM_CHAR}" ]]; then
scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
elif [[ "${SCM_HG_CHAR}" == "${SCM_CHAR}" ]]; then
scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
elif [[ "${SCM_SVN_CHAR}" == "${SCM_CHAR}" ]]; then
scm_prompt+="${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
fi
echo "${scm_prompt?}|${color}"
fi
}
function __powerline_cwd_prompt() {
echo "\w|${CWD_THEME_PROMPT_COLOR}"
}
function __powerline_hostname_prompt() {
echo "${SHORT_HOSTNAME:-$(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}"
}
function __powerline_battery_prompt() {
local color="" battery_status
battery_status="$(battery_percentage 2> /dev/null)"
if [[ -z "${battery_status}" || "${battery_status}" == "-1" || "${battery_status}" == "no" ]]; then
true
else
if [[ "$((10#${battery_status}))" -le 5 ]]; then
color="${BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR}"
elif [[ "$((10#${battery_status}))" -le 25 ]]; then
color="${BATTERY_STATUS_THEME_PROMPT_LOW_COLOR}"
else
color="${BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR}"
fi
ac_adapter_connected && battery_status="${BATTERY_AC_CHAR}${battery_status}"
echo "${battery_status}%|${color}"
fi
}
function __powerline_in_vim_prompt() {
if [[ -n "$VIMRUNTIME" ]]; then
echo "${IN_VIM_THEME_PROMPT_TEXT}|${IN_VIM_THEME_PROMPT_COLOR}"
fi
}
function __powerline_aws_profile_prompt() {
if [[ -n "${AWS_PROFILE}" ]]; then
echo "${AWS_PROFILE_CHAR}${AWS_PROFILE}|${AWS_PROFILE_PROMPT_COLOR}"
fi
}
function __powerline_in_toolbox_prompt() {
if [ -f /run/.containerenv ] && [ -f /run/.toolboxenv ]; then
echo "${IN_TOOLBOX_THEME_PROMPT_TEXT}|${IN_TOOLBOX_THEME_PROMPT_COLOR}"
fi
}
function __powerline_shlvl_prompt() {
if [[ "${SHLVL}" -gt 1 ]]; then
local prompt="${SHLVL_THEME_PROMPT_CHAR}"
local level=$((SHLVL - 1))
echo "${prompt}${level}|${SHLVL_THEME_PROMPT_COLOR}"
fi
}
function __powerline_dirstack_prompt() {
if [[ "${#DIRSTACK[@]}" -gt 1 ]]; then
local depth=$((${#DIRSTACK[@]} - 1))
local prompt="${DIRSTACK_THEME_PROMPT_CHAR}"
if [[ "${depth}" -ge 2 ]]; then
prompt+="${depth}"
fi
echo "${prompt}|${DIRSTACK_THEME_PROMPT_COLOR}"
fi
}
function __powerline_history_number_prompt() {
echo "${HISTORY_NUMBER_THEME_PROMPT_CHAR}\!|${HISTORY_NUMBER_THEME_PROMPT_COLOR}"
}
function __powerline_command_number_prompt() {
echo "${COMMAND_NUMBER_THEME_PROMPT_CHAR}\#|${COMMAND_NUMBER_THEME_PROMPT_COLOR}"
}
function __powerline_duration_prompt() {
local duration
duration=$(_command_duration)
[[ -n "$duration" ]] && echo "${duration}|${COMMAND_DURATION_PROMPT_COLOR}"
}
function __powerline_left_segment() {
local params
IFS="|" read -ra params <<< "${1}"
local pad_before_segment=" "
if [[ "${SEGMENTS_AT_LEFT}" -eq 0 ]]; then
if [[ "${POWERLINE_COMPACT_BEFORE_FIRST_SEGMENT}" -ne 0 ]]; then
pad_before_segment=""
fi
else
if [[ "${POWERLINE_COMPACT_AFTER_SEPARATOR}" -ne 0 ]]; then
pad_before_segment=""
fi
# Since the previous segment wasn't the last segment, add padding, if needed
#
if [[ "${POWERLINE_COMPACT_BEFORE_SEPARATOR}" -eq 0 ]]; then
LEFT_PROMPT+="$(set_color - "${LAST_SEGMENT_COLOR}") ${normal?}"
fi
if [[ "${LAST_SEGMENT_COLOR}" -eq "${params[1]}" ]]; then
LEFT_PROMPT+="$(set_color - "${LAST_SEGMENT_COLOR}")${POWERLINE_LEFT_SEPARATOR_SOFT}${normal?}"
else
LEFT_PROMPT+="$(set_color "${LAST_SEGMENT_COLOR}" "${params[1]}")${POWERLINE_LEFT_SEPARATOR}${normal?}"
fi
fi
LEFT_PROMPT+="$(set_color - "${params[1]}")${pad_before_segment}${params[0]}${normal}"
LAST_SEGMENT_COLOR=${params[1]}
((SEGMENTS_AT_LEFT += 1))
}
function __powerline_left_last_segment_padding() {
LEFT_PROMPT+="$(set_color - "${LAST_SEGMENT_COLOR}") ${normal?}"
}
function __powerline_last_status_prompt() {
[[ "$1" -ne 0 ]] && echo "${1}|${LAST_STATUS_THEME_PROMPT_COLOR}"
}
function __powerline_prompt_command() {
local last_status="$?" ## always the first
local separator_char="${POWERLINE_PROMPT_CHAR}" info prompt_color
LEFT_PROMPT=""
SEGMENTS_AT_LEFT=0
LAST_SEGMENT_COLOR=""
_save-and-reload-history "${HISTORY_AUTOSAVE:-0}"
if [[ -n "${POWERLINE_PROMPT_DISTRO_LOGO}" ]]; then
LEFT_PROMPT+="$(set_color "${PROMPT_DISTRO_LOGO_COLOR}" "${PROMPT_DISTRO_LOGO_COLORBG}")${PROMPT_DISTRO_LOGO}$(set_color - -)"
fi
## left prompt ##
for segment in $POWERLINE_PROMPT; do
info="$(__powerline_"${segment}"_prompt)"
[[ -n "${info}" ]] && __powerline_left_segment "${info}"
done
[[ "${last_status}" -ne 0 ]] && __powerline_left_segment "$(__powerline_last_status_prompt "${last_status}")"
if [[ -n "${LEFT_PROMPT}" ]] && [[ "${POWERLINE_COMPACT_AFTER_LAST_SEGMENT:-}" -eq 0 ]]; then
__powerline_left_last_segment_padding
fi
# By default we try to match the prompt to the adjacent segment's background color,
# but when part of the prompt exists within that segment, we instead match the foreground color.
prompt_color="$(set_color "${LAST_SEGMENT_COLOR}" -)"
if [[ -n "${LEFT_PROMPT}" ]] && [[ -n "${POWERLINE_LEFT_LAST_SEGMENT_PROMPT_CHAR}" ]]; then
LEFT_PROMPT+="$(set_color - "${LAST_SEGMENT_COLOR}")${POWERLINE_LEFT_LAST_SEGMENT_PROMPT_CHAR}"
prompt_color="${normal?}"
fi
[[ -n "${LEFT_PROMPT}" ]] && LEFT_PROMPT+="${prompt_color}${separator_char}${normal?}"
if [[ "${POWERLINE_COMPACT_PROMPT:-}" -eq 0 ]]; then
LEFT_PROMPT+=" "
fi
PS1="${LEFT_PROMPT}"
## cleanup ##
unset LAST_SEGMENT_COLOR \
LEFT_PROMPT \
SEGMENTS_AT_LEFT
}
@@ -0,0 +1,102 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# shellcheck source=../../themes/powerline/powerline.base.bash
. "$BASH_IT/themes/powerline/powerline.base.bash"
PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:=""}
POWERLINE_LEFT_SEPARATOR=${POWERLINE_LEFT_SEPARATOR:=""}
POWERLINE_LEFT_SEPARATOR_SOFT=${POWERLINE_LEFT_SEPARATOR_SOFT:=""}
POWERLINE_LEFT_LAST_SEGMENT_PROMPT_CHAR=${POWERLINE_LEFT_LAST_SEGMENT_PROMPT_CHAR:=""}
POWERLINE_COMPACT=${POWERLINE_COMPACT:=0}
POWERLINE_COMPACT_BEFORE_SEPARATOR=${POWERLINE_COMPACT_BEFORE_SEPARATOR:=${POWERLINE_COMPACT}}
POWERLINE_COMPACT_AFTER_SEPARATOR=${POWERLINE_COMPACT_AFTER_SEPARATOR:=${POWERLINE_COMPACT}}
POWERLINE_COMPACT_BEFOR_FIRST_SEGMENT=${POWERLINE_COMPACT_BEFORE_FIRST_SEGMENT:=${POWERLINE_COMPACT}}
POWERLINE_COMPACT_AFTER_LAST_SEGMENT=${POWERLINE_COMPACT_AFTER_LAST_SEGMENT:=${POWERLINE_COMPACT}}
POWERLINE_COMPACT_PROMPT=${POWERLINE_COMPACT_PROMPT:=${POWERLINE_COMPACT}}
USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "}
USER_INFO_THEME_PROMPT_COLOR=${POWERLINE_USER_INFO_COLOR:=32}
USER_INFO_THEME_PROMPT_COLOR_SUDO=${POWERLINE_USER_INFO_COLOR_SUDO:=202}
PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:="p "}
CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="c "}
PYTHON_VENV_THEME_PROMPT_COLOR=${POWERLINE_PYTHON_VENV_COLOR:=35}
SCM_NONE_CHAR=""
SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "}
SCM_HG_CHAR=${POWERLINE_SCM_HG_CHAR:="☿ "}
SCM_THEME_PROMPT_CLEAN=""
SCM_THEME_PROMPT_DIRTY=""
SCM_THEME_PROMPT_CLEAN_COLOR=${POWERLINE_SCM_CLEAN_COLOR:=25}
SCM_THEME_PROMPT_DIRTY_COLOR=${POWERLINE_SCM_DIRTY_COLOR:=88}
SCM_THEME_PROMPT_STAGED_COLOR=${POWERLINE_SCM_STAGED_COLOR:=30}
SCM_THEME_PROMPT_UNSTAGED_COLOR=${POWERLINE_SCM_UNSTAGED_COLOR:=92}
SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR}
NVM_THEME_PROMPT_PREFIX=""
NVM_THEME_PROMPT_SUFFIX=""
NODE_CHAR=${POWERLINE_NODE_CHAR:="n "}
NODE_THEME_PROMPT_COLOR=${POWERLINE_NODE_COLOR:=22}
RVM_THEME_PROMPT_PREFIX=""
RVM_THEME_PROMPT_SUFFIX=""
RBENV_THEME_PROMPT_PREFIX=""
RBENV_THEME_PROMPT_SUFFIX=""
RUBY_THEME_PROMPT_COLOR=${POWERLINE_RUBY_COLOR:=161}
RUBY_CHAR=${POWERLINE_RUBY_CHAR:="r "}
TERRAFORM_THEME_PROMPT_COLOR=${POWERLINE_TERRAFORM_COLOR:=161}
TERRAFORM_CHAR=${POWERLINE_TERRAFORM_CHAR:="t "}
KUBERNETES_CONTEXT_THEME_CHAR=${POWERLINE_KUBERNETES_CONTEXT_CHAR:="⎈ "}
KUBERNETES_CONTEXT_THEME_PROMPT_COLOR=${POWERLINE_KUBERNETES_CONTEXT_COLOR:=26}
KUBERNETES_NAMESPACE_THEME_CHAR=${POWERLINE_KUBERNETES_NAMESPACE_CHAR:="⎈ "}
KUBERNETES_NAMESPACE_THEME_PROMPT_COLOR=${POWERLINE_KUBERNETES_NAMESPACE_COLOR:=64}
AWS_PROFILE_CHAR=${POWERLINE_AWS_PROFILE_CHAR:="aws "}
AWS_PROFILE_PROMPT_COLOR=${POWERLINE_AWS_PROFILE_COLOR:=208}
CWD_THEME_PROMPT_COLOR=${POWERLINE_CWD_COLOR:=240}
LAST_STATUS_THEME_PROMPT_COLOR=${POWERLINE_LAST_STATUS_COLOR:=52}
CLOCK_THEME_PROMPT_COLOR=${POWERLINE_CLOCK_COLOR:=240}
BATTERY_AC_CHAR=${BATTERY_AC_CHAR:="⚡"}
BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=${POWERLINE_BATTERY_GOOD_COLOR:=70}
BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=${POWERLINE_BATTERY_LOW_COLOR:=208}
BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=${POWERLINE_BATTERY_CRITICAL_COLOR:=160}
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
IN_VIM_THEME_PROMPT_COLOR=${POWERLINE_IN_VIM_COLOR:=245}
IN_VIM_THEME_PROMPT_TEXT=${POWERLINE_IN_VIM_TEXT:="vim"}
IN_TOOLBOX_THEME_PROMPT_COLOR=${POWERLINE_IN_TOOLBOX_COLOR:=125}
IN_TOOLBOX_THEME_PROMPT_TEXT=${POWERLINE_IN_TOOLBOX_TEXT:="⬢ "}
HOST_THEME_PROMPT_COLOR=${POWERLINE_HOST_COLOR:=0}
SHLVL_THEME_PROMPT_COLOR=${POWERLINE_SHLVL_COLOR:=${HOST_THEME_PROMPT_COLOR}}
SHLVL_THEME_PROMPT_CHAR=${POWERLINE_SHLVL_CHAR:="§"}
DIRSTACK_THEME_PROMPT_COLOR=${POWERLINE_DIRSTACK_COLOR:=${CWD_THEME_PROMPT_COLOR}}
DIRSTACK_THEME_PROMPT_CHAR=${POWERLINE_DIRSTACK_CHAR:="←"}
HISTORY_NUMBER_THEME_PROMPT_COLOR=${POWERLINE_HISTORY_NUMBER_COLOR:=0}
HISTORY_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_HISTORY_NUMBER_CHAR:="#"}
COMMAND_NUMBER_THEME_PROMPT_COLOR=${POWERLINE_COMMAND_NUMBER_COLOR:=0}
COMMAND_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_COMMAND_NUMBER_CHAR:="#"}
GCLOUD_THEME_PROMPT_COLOR=${POWERLINE_GCLOUD_COLOR:=161}
GCLOUD_CHAR=${POWERLINE_GCLOUD_CHAR:="G "}
COMMAND_DURATION_PROMPT_COLOR=${POWERLINE_COMMAND_DURATION_COLOR:=129}
POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby node cwd"}
safe_append_prompt_command __powerline_prompt_command
@@ -0,0 +1,184 @@
#!/usr/bin/env bash
# Power-Turk theme for bash-it
# Author (C) 2015 Ahmed Seref Guneysu
THEME_PROMPT_SEPARATOR=""
SHELL_SSH_CHAR=" "
SHELL_THEME_PROMPT_COLOR=2
SHELL_SSH_THEME_PROMPT_COLOR=208
VIRTUALENV_CHAR="ⓔ "
VIRTUALENV_THEME_PROMPT_COLOR=35
SCM_NONE_CHAR=""
SCM_GIT_CHAR=" " # " "
SCM_THEME_PROMPT_CLEAN=""
SCM_THEME_PROMPT_DIRTY=""
SCM_THEME_PROMPT_COLOR=16
SCM_THEME_PROMPT_CLEAN_COLOR=231
SCM_THEME_PROMPT_DIRTY_COLOR=196
SCM_THEME_PROMPT_STAGED_COLOR=220
SCM_THEME_PROMPT_UNSTAGED_COLOR=166
CWD_THEME_PROMPT_COLOR=240
LAST_STATUS_THEME_PROMPT_COLOR=52
_collapsed_wd() {
# echo -e "\u2771\u276d\u276f"
echo $(pwd | perl -pe "
BEGIN {
binmode STDIN, ':encoding(UTF-8)';
binmode STDOUT, ':encoding(UTF-8)';
}; s|^$HOME|<HOME>|g; s|/([^/])[^/]*(?=/)|/\$1|g") | \
sed -re "s/\//  /g"
}
_swd(){
# Adapted from http://stackoverflow.com/a/2951707/1766716
begin="" # The unshortened beginning of the path.
shortbegin="" # The shortened beginning of the path.
current="" # The section of the path we're currently working on.
end="${2:-${PWD}}/" # The unmodified rest of the path.
if [[ "$end" =~ "$HOME" ]]; then
INHOME=1
end="${end#$HOME}" #strip /home/username from start of string
begin="$HOME" #start expansion from the right spot
else
INHOME=0
fi
end="${end#/}" # Strip the first /
shortenedpath="$end" # The whole path, to check the length.
maxlength="${1:-0}"
shopt -q nullglob && NGV="-s" || NGV="-u" # Store the value for later.
shopt -s nullglob # Without this, anything that doesn't exist in the filesystem turns into */*/*/...
while [[ "$end" ]] && (( ${#shortenedpath} > maxlength ))
do
current="${end%%/*}" # everything before the first /
end="${end#*/}" # everything after the first /
shortcur="$current"
shortcurstar="$current" # No star if we don't shorten it.
for ((i=${#current}-2; i>=0; i--)); do
subcurrent="${current:0:i}"
matching=("$begin/$subcurrent"*) # Array of all files that start with $subcurrent.
(( ${#matching[*]} != 1 )) && break # Stop shortening if more than one file matches.
shortcur="$subcurrent"
shortcurstar="$subcurrent*"
done
#advance
begin="$begin/$current"
shortbegin="$shortbegin/$shortcurstar"
shortenedpath="$shortbegin/$end"
done
shortenedpath="${shortenedpath%/}" # strip trailing /
shortenedpath="${shortenedpath#/}" # strip leading /
# Replaces slashes with  except first occurence.
if [ $INHOME -eq 1 ]; then
echo "~/$shortenedpath" | sed "s/\///2g" # make sure it starts with ~/
else
echo "/$shortenedpath" | sed "s/\///2g" # Make sure it starts with /
fi
shopt "$NGV" nullglob # Reset nullglob in case this is being used as a function.
}
function set_rgb_color {
if [[ "${1}" != "-" ]]; then
fg="38;5;${1}"
fi
if [[ "${2}" != "-" ]]; then
bg="48;5;${2}"
[[ -n "${fg}" ]] && bg=";${bg}"
fi
echo -e "\[\033[${fg}${bg}m\]"
}
function powerline_shell_prompt {
if [[ -n "${SSH_CLIENT}" ]]; then
SHELL_PROMPT="${bold_white}$(set_rgb_color - ${SHELL_SSH_THEME_PROMPT_COLOR}) ${SHELL_SSH_CHAR}\u@\h ${normal}"
LAST_THEME_COLOR=${SHELL_SSH_THEME_PROMPT_COLOR}
else
SHELL_PROMPT="${bold_white}$(set_rgb_color - ${SHELL_THEME_PROMPT_COLOR}) ${normal}"
LAST_THEME_COLOR=${SHELL_THEME_PROMPT_COLOR}
fi
}
function powerline_virtualenv_prompt {
local environ=""
if [[ -n "$CONDA_DEFAULT_ENV" ]]; then
environ="conda: $CONDA_DEFAULT_ENV"
elif [[ -n "$VIRTUAL_ENV" ]]; then
environ=$(basename "$VIRTUAL_ENV")
fi
if [[ -n "$environ" ]]; then
VIRTUALENV_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${VIRTUALENV_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${VIRTUALENV_THEME_PROMPT_COLOR}) ${VIRTUALENV_CHAR}$environ ${normal}"
LAST_THEME_COLOR=${VIRTUALENV_THEME_PROMPT_COLOR}
else
VIRTUALENV_PROMPT=""
fi
}
function powerline_scm_prompt {
scm_prompt_vars
if [[ "${SCM_NONE_CHAR}" != "${SCM_CHAR}" ]]; then
if [[ "${SCM_DIRTY}" -eq 3 ]]; then
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_STAGED_COLOR} ${SCM_THEME_PROMPT_COLOR})"
elif [[ "${SCM_DIRTY}" -eq 2 ]]; then
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_UNSTAGED_COLOR} ${SCM_THEME_PROMPT_COLOR})"
elif [[ "${SCM_DIRTY}" -eq 1 ]]; then
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_DIRTY_COLOR} ${SCM_THEME_PROMPT_COLOR})"
else
SCM_PROMPT="$(set_rgb_color ${SCM_THEME_PROMPT_CLEAN_COLOR} ${SCM_THEME_PROMPT_COLOR})"
fi
if [[ "${SCM_GIT_CHAR}" == "${SCM_CHAR}" ]]; then
SCM_PROMPT+=" ${SCM_CHAR}${SCM_BRANCH}${SCM_STATE}"
fi
SCM_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${SCM_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}${SCM_PROMPT} ${normal}"
LAST_THEME_COLOR=${SCM_THEME_PROMPT_COLOR}
else
SCM_PROMPT=""
fi
}
function powerline_cwd_prompt {
CWD_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${CWD_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}$(set_rgb_color 0 ${CWD_THEME_PROMPT_COLOR}) $(_swd)${normal}$(set_rgb_color ${CWD_THEME_PROMPT_COLOR} -)${normal}"
LAST_THEME_COLOR=${CWD_THEME_PROMPT_COLOR}
}
function powerline_last_status_prompt {
if [[ "$1" -eq 0 ]]; then
LAST_STATUS_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}"
else
LAST_STATUS_PROMPT="$(set_rgb_color ${LAST_THEME_COLOR} ${LAST_STATUS_THEME_PROMPT_COLOR})${THEME_PROMPT_SEPARATOR}${normal}$(set_rgb_color - ${LAST_STATUS_THEME_PROMPT_COLOR}) ${LAST_STATUS} ${normal}$(set_rgb_color ${LAST_STATUS_THEME_PROMPT_COLOR} -)${THEME_PROMPT_SEPARATOR}${normal}"
fi
}
function powerline_prompt_command() {
local LAST_STATUS="$?"
powerline_shell_prompt
powerline_virtualenv_prompt
powerline_scm_prompt
powerline_cwd_prompt
powerline_last_status_prompt LAST_STATUS
PS1="${SHELL_PROMPT}${VIRTUALENV_PROMPT}${SCM_PROMPT}${CWD_PROMPT}${LAST_STATUS_PROMPT} "
}
PROMPT_COMMAND=powerline_prompt_command
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
# based of the candy theme, but minimized by odbol
function prompt_command() {
PS1="$(clock_prompt) ${reset_color}${white}\w${reset_color}$(scm_prompt_info)${blue}${bold_blue} ${reset_color} ";
}
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$blue"}
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%I:%M:%S"}
safe_append_prompt_command prompt_command
+22
View File
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${green}"
SCM_THEME_PROMPT_PREFIX=" ${blue}scm:( "
SCM_THEME_PROMPT_SUFFIX="${blue} )"
GIT_THEME_PROMPT_DIRTY=" ${red}"
GIT_THEME_PROMPT_CLEAN=" ${green}"
GIT_THEME_PROMPT_PREFIX="${green}git:( "
GIT_THEME_PROMPT_SUFFIX="${green} )"
function git_prompt_info {
git_prompt_vars
echo -e "$SCM_PREFIX$SCM_BRANCH$SCM_STATE$SCM_SUFFIX"
}
function prompt() {
PS1="\h: \W $(scm_prompt_info)${reset_color} $ "
}
safe_append_prompt_command prompt
+37
View File
@@ -0,0 +1,37 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
# scm theming
SCM_THEME_PROMPT_PREFIX="|"
SCM_THEME_PROMPT_SUFFIX=""
SCM_THEME_PROMPT_DIRTY=" ${bold_red?}${normal?}"
SCM_THEME_PROMPT_CLEAN=" ${green?}${normal?}"
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=")"
function pure_prompt() {
local ps_host="${bold_blue?}\h${normal?}"
local ps_user="${green?}\u${normal?}"
local ps_user_mark="${green?} \$ ${normal?}"
local ps_root="${red?}\u${red?}"
local ps_root_mark="${red?} \$ ${normal?}"
local ps_path="${yellow?}\w${normal?}"
local virtualenv_prompt scm_prompt
virtualenv_prompt="$(virtualenv_prompt)"
scm_prompt="$(scm_prompt)"
# make it work
case "${EUID:-$UID}" in
0)
ps_user_mark="${ps_root_mark}"
ps_user="${ps_root}"
;;
esac
PS1="${virtualenv_prompt}${ps_user}@${ps_host}${scm_prompt}:${ps_path}${ps_user_mark}"
}
safe_append_prompt_command pure_prompt
@@ -0,0 +1,44 @@
# shellcheck shell=bash
# shellcheck disable=SC2034 # Expected behavior for themes.
SCM_THEME_PROMPT_DIRTY=" ${bold_red?}${normal?}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green?}${normal?}"
SCM_THEME_PROMPT_PREFIX="${reset_color?}( "
SCM_THEME_PROMPT_SUFFIX=" ${reset_color?})"
GIT_THEME_PROMPT_DIRTY=" ${bold_red?}${normal?}"
GIT_THEME_PROMPT_CLEAN=" ${bold_green?}${normal?}"
GIT_THEME_PROMPT_PREFIX="${reset_color?}( "
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:=$blue}"
function venv_prompt() {
python_venv=""
# Detect python venv
if [[ -n "${CONDA_DEFAULT_ENV:-}" ]]; then
python_venv="(${PYTHON_VENV_CHAR}${CONDA_DEFAULT_ENV}) "
elif [[ -n "${VIRTUAL_ENV}" ]]; then
python_venv="(${PYTHON_VENV_CHAR}${VIRTUAL_ENV##*/}) "
fi
[[ -n "${python_venv}" ]] && echo "${python_venv}"
}
function prompt_command() {
local retval="$?" ret_status python_venv scm_prompt_info venv_prompt
case "${retval}" in
0)
ret_status="$STATUS_THEME_PROMPT_OK"
;;
*)
ret_status="$STATUS_THEME_PROMPT_BAD"
;;
esac
scm_prompt_info="$(scm_prompt_info)"
venv_prompt="$(venv_prompt)"
PS1="\n${PURITY_THEME_PROMPT_COLOR}\w ${scm_prompt_info}\n${ret_status}${venv_prompt}"
}
safe_append_prompt_command prompt_command
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
GIT_THEME_PROMPT_DIRTY="${red}"
GIT_THEME_PROMPT_CLEAN="${bold_green}"
GIT_THEME_PROMPT_PREFIX="${bold_cyan}["
GIT_THEME_PROMPT_SUFFIX="${bold_cyan}]"
VIRTUALENV_THEME_PROMPT_PREFIX="${bold_green}["
VIRTUALENV_THEME_PROMPT_SUFFIX="${bold_green}]"
CONDAENV_THEME_PROMPT_PREFIX="${bold_green}["
CONDAENV_THEME_PROMPT_SUFFIX="${bold_green}]"
PYTHON_THEME_PROMPT_PREFIX="${bold_green}["
PYTHON_THEME_PROMPT_SUFFIX="${bold_green}]"
function prompt_command() {
PS1="\n${bold_white}[\u@\h]${bold_yellow}[\w] ${bold_cyan}$(scm_prompt_char_info)$(python_version_prompt)${green}\n→${reset_color} "
}
safe_append_prompt_command prompt_command
@@ -0,0 +1,27 @@
# shellcheck shell=bash
# based off of n0qorg
# looks like, if you're in a git repo:
# ± ~/path/to (branch ✓) $
# in glorious red / blue / yellow color scheme
prompt_setter() {
# Save history
_save-and-reload-history 1
# displays user@server in purple
# PS1="$red$(scm_char) $purple\u@\h$reset_color:$blue\w$yellow$(scm_prompt_info)$(ruby_version_prompt) $black\$$reset_color "
# no user@server
PS1="$red$(scm_char) $blue\w$yellow$(scm_prompt_info)$(ruby_version_prompt) $black\$$reset_color "
PS2='> '
PS4='+ '
}
safe_append_prompt_command prompt_setter
SCM_NONE_CHAR='·'
SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${green}"
SCM_THEME_PROMPT_PREFIX=" ("
SCM_THEME_PROMPT_SUFFIX="${yellow})"
RVM_THEME_PROMPT_PREFIX=" ("
RVM_THEME_PROMPT_SUFFIX=")"
@@ -0,0 +1,99 @@
SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX=""
SCM_THEME_PROMPT_DIRTY=" ${bold_red}${normal}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}${normal}"
SCM_GIT_CHAR="${bold_green}±${normal}"
SCM_SVN_CHAR="${bold_cyan}${normal}"
SCM_HG_CHAR="${bold_red}${normal}"
#Mysql Prompt
export MYSQL_PS1="(\u@\h) [\d]> "
case $TERM in
xterm*)
TITLEBAR="\[\033]0;\w\007\]"
;;
*)
TITLEBAR=""
;;
esac
PS3=">> "
__my_rvm_ruby_version() {
local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}')
[ "$gemset" != "" ] && gemset="@$gemset"
local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}')
local full="$version$gemset"
[ "$full" != "" ] && echo "[$full]"
}
is_vim_shell() {
if [ ! -z "$VIMRUNTIME" ]
then
echo "[${cyan}vim shell${normal}]"
fi
}
# show chroot if exist
chroot(){
if [ -n "$debian_chroot" ]
then
my_ps_chroot="${bold_cyan}$debian_chroot${normal}";
echo "($my_ps_chroot)";
fi
}
# show virtualenvwrapper
my_ve(){
if [ -n "$CONDA_DEFAULT_ENV" ]
then
my_ps_ve="${bold_purple}${CONDA_DEFAULT_ENV}${normal}";
echo "($my_ps_ve)";
elif [ -n "$VIRTUAL_ENV" ]
then
my_ps_ve="${bold_purple}$ve${normal}";
echo "($my_ps_ve)";
fi
echo "";
}
prompt() {
SCM_PROMPT_FORMAT='[%s][%s]'
my_ps_host="${green}\h${normal}";
# yes, these are the the same for now ...
my_ps_host_root="${green}\h${normal}";
my_ps_user="${bold_green}\u${normal}"
my_ps_root="${bold_red}\u${normal}";
if [ -n "$VIRTUAL_ENV" ]
then
ve=`basename "$VIRTUAL_ENV"`;
fi
# nice prompt
case "`id -u`" in
0) PS1="${TITLEBAR}┌─$(my_ve)$(chroot)[$my_ps_root][$my_ps_host_root]$(scm_prompt)$(__my_rvm_ruby_version)[${cyan}\w${normal}]
"
;;
*) PS1="${TITLEBAR}┌─$(my_ve)$(chroot)[$my_ps_user][$my_ps_host]$(scm_prompt)$(__my_rvm_ruby_version)
|─[${bold_purple}\w${normal}]
"
;;
esac
}
PS2="▪ "
# vi mode
set -o vi
bind 'set vi-ins-mode-string "└+"'
bind 'set vi-cmd-mode-string "└─"'
bind 'set show-mode-in-prompt on'
bind '"jj":vi-movement-mode'
VIMRUNTIME='true'
safe_append_prompt_command prompt
+214
View File
@@ -0,0 +1,214 @@
#!/usr/bin/env bash
# Theme inspired on:
# - Ronacher's dotfiles (mitsuhikos) - http://github.com/mitsuhiko/dotfiles/tree/master/bash/
# - Glenbot - http://theglenbot.com/custom-bash-shell-for-development/
# - My extravagant zsh - http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/
# - Monokai colors - http://monokai.nl/blog/2006/07/15/textmate-color-theme/
# - Bash_it modern theme
#
# by Rana Amrit Parth<ramrit9@gmaiil.com>
# 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/
#*background: #272822
#*foreground: #E2DA6E
#*color0: black
#! mild red
#*color1: #CD0000
#! light green
#*color2: #A5E02D
#! orange (yellow)
#*color3: #FB951F
#! "dark" blue
#*color4: #076BCC
#! hot pink
#*color5: #F6266C
#! cyan
#*color6: #64D9ED
#! gray
#*color7: #E5E5E5
# ----------------------------------------------------------------- DEF COLOR
RCol='\e[0m' # Text Reset
# Regular
Bla='\e[0;30m';
Red='\e[0;31m';
Gre='\e[0;32m';
Yel='\e[0;33m';
Blu='\e[0;34m';
Pur='\e[0;35m';
Cya='\e[0;36m';
Whi='\e[0;37m';
# Bold
BBla='\e[1;30m';
BRed='\e[1;31m';
BYel='\e[1;33m';
BGre='\e[1;32m';
BBlu='\e[1;34m';
BPur='\e[1;35m';
BCya='\e[1;36m';
BWhi='\e[1;37m';
# High Intensity
IBla='\e[0;90m';
IRed='\e[0;91m';
IGre='\e[0;92m';
IYel='\e[0;93m';
IBlu='\e[0;94m';
IPur='\e[0;95m';
ICya='\e[0;96m';
IWhi='\e[0;97m';
# ----------------------------------------------------------------- COLOR CONF
D_DEFAULT_COLOR="${Whi}"
D_INTERMEDIATE_COLOR="${BWhi}"
D_USER_COLOR="${Yel}"
D_SUPERUSER_COLOR="${Red}"
D_MACHINE_COLOR="${IYel}"
D_DIR_COLOR="${Gre}"
D_GIT_COLOR="${BBlu}"
D_SCM_COLOR="${BYel}"
D_BRANCH_COLOR="${BYel}"
D_CHANGES_COLOR="${Whi}"
D_CMDFAIL_COLOR="${Red}"
D_VIMSHELL_COLOR="${Cya}"
# ------------------------------------------------------------------ FUNCTIONS
case $TERM in
xterm*)
TITLEBAR="\033]0;\w\007"
;;
*)
TITLEBAR=""
;;
esac
is_vim_shell() {
if [ ! -z "$VIMRUNTIME" ];
then
echo "${D_INTERMEDIATE_COLOR}on ${D_VIMSHELL_COLOR}\
vim shell${D_DEFAULT_COLOR} "
fi
}
mitsuhikos_lastcommandfailed() {
code=$?
if [ $code != 0 ];
then
echo "${D_INTERMEDIATE_COLOR}exited ${D_CMDFAIL_COLOR}\
$code ${D_DEFAULT_COLOR}"
fi
}
# vcprompt for scm instead of bash_it default
demula_vcprompt() {
if [ ! -z "$VCPROMPT_EXECUTABLE" ];
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"
fi
}
# checks if the plugin is installed before calling battery_charge
safe_battery_charge() {
if _command_exists battery_charge ;
then
battery_charge
fi
}
prompt_git() {
local s='';
local branchName='';
# Check if the current directory is in a Git repository.
if [ $(git rev-parse --is-inside-work-tree &>/dev/null; echo "${?}") == '0' ]; then
# check if the current directory is in .git before running git checks
if [ "$(git rev-parse --is-inside-git-dir 2> /dev/null)" == 'false' ]; then
# Ensure the index is up to date.
git update-index --really-refresh -q &>/dev/null;
# Check for uncommitted changes in the index.
if ! $(git diff --quiet --ignore-submodules --cached); then
s+='+';
fi;
# Check for unstaged changes.
if ! $(git diff-files --quiet --ignore-submodules --); then
s+='!';
fi;
# Check for untracked files.
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
s+='?';
fi;
# Check for stashed files.
if $(git rev-parse --verify refs/stash &>/dev/null); then
s+='$';
fi;
fi;
# Get the short symbolic ref.
# If HEAD isnt a symbolic ref, get the short SHA for the latest commit
# Otherwise, just give up.
branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \
git rev-parse --short HEAD 2> /dev/null || \
echo '(unknown)')";
[ -n "${s}" ] && s=" [${s}]";
echo -e "${1}${branchName}${Cya}${s}";
else
return;
fi;
}
# -------------------------------------------------------------- PROMPT OUTPUT
prompt() {
local LAST_COMMAND_FAILED=$(mitsuhikos_lastcommandfailed)
local SAVE_CURSOR='\033[s'
local RESTORE_CURSOR='\033[u'
local MOVE_CURSOR_RIGHTMOST='\033[500C'
local MOVE_CURSOR_5_LEFT='\033[5D'
if [[ "$OSTYPE" == 'linux'* ]];
then
PS1="${TITLEBAR}
${SAVE_CURSOR}${MOVE_CURSOR_RIGHTMOST}${MOVE_CURSOR_5_LEFT}\
$(safe_battery_charge)${RESTORE_CURSOR}\
${D_USER_COLOR}\u ${D_INTERMEDIATE_COLOR}\
at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\
in ${D_DIR_COLOR}\w ${D_INTERMEDIATE_COLOR}\
$(prompt_git "$D_INTERMEDIATE_COLOR on $D_GIT_COLOR")\
${LAST_COMMAND_FAILED}\
$(demula_vcprompt)\
$(is_vim_shell)
${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}"
else
PS1="${TITLEBAR}
${D_USER_COLOR}\u ${D_INTERMEDIATE_COLOR}\
at ${D_MACHINE_COLOR}\h ${D_INTERMEDIATE_COLOR}\
in ${D_DIR_COLOR}\w ${D_INTERMEDIATE_COLOR}\
$(prompt_git "$D_INTERMEDIATE_COLOR on $D_GIT_COLOR")\
${LAST_COMMAND_FAILED}\
$(demula_vcprompt)\
$(is_vim_shell)\
$(safe_battery_charge)
${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}"
fi
PS2="${D_INTERMEDIATE_COLOR}$ ${D_DEFAULT_COLOR}"
}
# Runs prompt (this bypasses bash_it $PROMPT setting)
safe_append_prompt_command prompt
@@ -0,0 +1,63 @@
#!/usr/bin/env bash
. "$BASH_IT/themes/powerline/powerline.base.bash"
PROMPT_DISTRO_LOGO=" "
PROMPT_DISTRO_LOGO_COLOR=15
PROMPT_DISTRO_LOGO_COLORBG=52
PROMPT_CHAR=${POWERLINE_PROMPT_CHAR:=""}
POWERLINE_LEFT_SEPARATOR=${POWERLINE_LEFT_SEPARATOR:=""}
USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "}
USER_INFO_SUDO_CHAR=${POWERLINE_USER_INFO_SUDO_CHAR:=" "}
USER_INFO_THEME_PROMPT_COLOR=52
USER_INFO_THEME_PROMPT_COLOR_SUDO=52
PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:=" "}
CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="c "}
PYTHON_VENV_THEME_PROMPT_COLOR=23
SCM_NONE_CHAR=""
SCM_GIT_CHAR=${POWERLINE_SCM_GIT_CHAR:=" "}
SCM_THEME_PROMPT_CLEAN=""
SCM_THEME_PROMPT_DIRTY=""
SCM_THEME_PROMPT_CLEAN_COLOR=235
SCM_THEME_PROMPT_DIRTY_COLOR=235 #124
SCM_THEME_PROMPT_STAGED_COLOR=235 #52
SCM_THEME_PROMPT_UNSTAGED_COLOR=88
SCM_THEME_PROMPT_COLOR=${SCM_THEME_PROMPT_CLEAN_COLOR}
RVM_THEME_PROMPT_PREFIX=""
RVM_THEME_PROMPT_SUFFIX=""
RBENV_THEME_PROMPT_PREFIX=""
RBENV_THEME_PROMPT_SUFFIX=""
RUBY_THEME_PROMPT_COLOR=161
RUBY_CHAR=${POWERLINE_RUBY_CHAR:=" "}
CWD_THEME_DIR_SEPARATOR=""
CWD_THEME_DIR_SEPARATOR_COLOR=52
CWD_THEME_PROMPT_COLOR=238
HOST_THEME_PROMPT_COLOR=88
LAST_STATUS_THEME_PROMPT_COLOR=52
CLOCK_THEME_PROMPT_COLOR=240
BATTERY_AC_CHAR=${BATTERY_AC_CHAR:="⚡"}
BATTERY_STATUS_THEME_PROMPT_GOOD_COLOR=70
BATTERY_STATUS_THEME_PROMPT_LOW_COLOR=208
BATTERY_STATUS_THEME_PROMPT_CRITICAL_COLOR=160
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:="%H:%M:%S"}
IN_VIM_THEME_PROMPT_COLOR=245
IN_VIM_THEME_PROMPT_TEXT="vim"
IN_TOOLBOX_THEME_PROMPT_COLOR=125
IN_TOOLBOX_THEME_PROMPT_TEXT="⬢ "
POWERLINE_PROMPT=${POWERLINE_PROMPT:="python_venv ruby user_info hostname cwd scm"}
safe_append_prompt_command __powerline_prompt_command
@@ -0,0 +1,91 @@
# port of zork theme
# set colors for use throughout the prompt
# i like things consistent
BRACKET_COLOR=${blue}
STRING_COLOR=${green}
SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX=""
SCM_THEME_PROMPT_DIRTY=" ${bold_red}${normal}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}${normal}"
SCM_GIT_CHAR="${STRING_COLOR}±${normal}"
SCM_SVN_CHAR="${bold_cyan}${normal}"
SCM_HG_CHAR="${bold_red}${normal}"
#Mysql Prompt
export MYSQL_PS1="(\u@\h) [\d]> "
case $TERM in
xterm*)
TITLEBAR="\[\033]0;\w\007\]"
;;
*)
TITLEBAR=""
;;
esac
PS3=">> "
__my_rvm_ruby_version() {
local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}')
[ "$gemset" != "" ] && gemset="@$gemset"
local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}')
local full="$version$gemset"
[ "$full" != "" ] && echo "${BRACKET_COLOR}[${STRING_COLOR}$full${BRACKET_COLOR}]${normal}"
}
is_vim_shell() {
if [ ! -z "$VIMRUNTIME" ]
then
echo "${BRACKET_COLOR}[${STRING_COLOR}vim shell${BRACKET_COLOR}]${normal}"
fi
}
function is_integer() { # helper function for todo-txt-count
[ "$1" -eq "$1" ] > /dev/null 2>&1
return $?
}
todo_txt_count() {
if `hash todo.sh 2>&-`; then # is todo.sh installed
count=`todo.sh ls | egrep "TODO: [0-9]+ of ([0-9]+) tasks shown" | awk '{ print $4 }'`
if is_integer $count; then # did we get a sane answer back
echo "${BRACKET_COLOR}[${STRING_COLOR}T:$count${BRACKET_COLOR}]$normal"
fi
fi
}
my_prompt_char() {
if [[ $OSTYPE =~ "darwin" ]]; then
echo "${BRACKET_COLOR}${normal}"
else
echo "${BRACKET_COLOR}${normal}"
fi
}
prompt() {
SCM_PROMPT_FORMAT="${BRACKET_COLOR}[%s${BRACKET_COLOR}][${STRING_COLOR}%s${BRACKET_COLOR}]"
my_ps_host="${STRING_COLOR}\h${normal}";
my_ps_user="${STRING_COLOR}\u${normal}";
my_ps_root="${bold_red}\u${normal}";
my_ps_path="${STRING_COLOR}\w${normal}";
# nice prompt
case "`id -u`" in
0) PS1="${TITLEBAR}${BRACKET_COLOR}┌─[$my_ps_root${BRACKET_COLOR}][$my_ps_host${BRACKET_COLOR}]$(scm_prompt)$(__my_rvm_ruby_version)${BRACKET_COLOR}[${STRING_COLOR}\w${BRACKET_COLOR}]$(is_vim_shell)
${BRACKET_COLOR}└─$(my_prompt_char)${normal}"
;;
*) PS1="${TITLEBAR}${BRACKET_COLOR}┌─[$my_ps_user${BRACKET_COLOR}][$my_ps_host${BRACKET_COLOR}]$(scm_prompt)$(__my_rvm_ruby_version)${BRACKET_COLOR}[${STRING_COLOR}\w${BRACKET_COLOR}]$(is_vim_shell)
${BRACKET_COLOR}└─$(todo_txt_count)$(my_prompt_char)"
;;
esac
}
PS2="└─$(my_prompt_char)"
safe_append_prompt_command prompt
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
SCM_THEME_PROMPT_DIRTY=" ${bold_yellow}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}"
SCM_THEME_PROMPT_PREFIX=" ${bold_blue}scm:("
SCM_THEME_PROMPT_SUFFIX="${bold_blue})"
GIT_THEME_PROMPT_DIRTY=" ${bold_yellow}"
GIT_THEME_PROMPT_CLEAN=" ${bold_green}"
GIT_THEME_PROMPT_PREFIX=" ${bold_blue}git:("
GIT_THEME_PROMPT_SUFFIX="${bold_blue})"
RVM_THEME_PROMPT_PREFIX="|"
RVM_THEME_PROMPT_SUFFIX="|"
function git_prompt_info() {
git_prompt_vars
echo -e "$SCM_PREFIX${bold_red}$SCM_BRANCH$SCM_STATE$SCM_SUFFIX"
}
function prompt_command() {
PS1="${bold_green}${bold_cyan}\W${reset_color}$(scm_prompt_info)${normal} "
}
PROMPT_COMMAND=prompt_command
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true
export GIT_PS1_SHOWSTASHSTATE=true
export PROMPT_DIRTRIM=3
function prompt_command() {
if [[ ${EUID} == 0 ]] ; then
PS1="[$(clock_prompt)]${yellow}[${red}\u@\h ${green}\w${yellow}]${red}$(__git_ps1 "(%s)")${normal}\\$ "
else
PS1="[$(clock_prompt)]${yellow}[${cyan}\u@\h ${green}\w${yellow}]${red}$(__git_ps1 "(%s)")${normal}\\$ "
fi
}
safe_append_prompt_command prompt_command
+56
View File
@@ -0,0 +1,56 @@
# Sexy Bash Prompt, inspired by "Extravagant Zsh Prompt"
# Screenshot: http://cloud.gf3.ca/M5rG
# A big thanks to \amethyst on Freenode
#
# Configuration:
# * To visualize python environment (virtualenv and conda) add in your .bash_profile the following line:
# export SEXY_THEME_SHOW_PYTHON=true
# Default setting
SEXY_THEME_SHOW_PYTHON="${SEXY_THEME_SHOW_PYTHON:=false}"
if tput setaf 1 &> /dev/null; then
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
MAGENTA=$(tput setaf 9)
ORANGE=$(tput setaf 172)
GREEN=$(tput setaf 190)
PURPLE=$(tput setaf 141)
WHITE=$(tput setaf 0)
else
MAGENTA=$(tput setaf 5)
ORANGE=$(tput setaf 4)
GREEN=$(tput setaf 2)
PURPLE=$(tput setaf 1)
WHITE=$(tput setaf 7)
fi
BOLD=$(tput bold)
RESET=$(tput sgr0)
else
MAGENTA="\033[1;31m"
ORANGE="\033[1;33m"
GREEN="\033[1;32m"
PURPLE="\033[1;35m"
WHITE="\033[1;37m"
BOLD=""
RESET="\033[m"
fi
parse_git_dirty () {
[[ $(git status 2> /dev/null | tail -n1 | cut -c 1-17) != "nothing to commit" ]] && echo "*"
}
parse_git_branch () {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
}
env_prompt () {
echo -e "($(virtualenv_prompt)$(condaenv_prompt))"
}
function prompt_command() {
PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]"
if [ "$SEXY_THEME_SHOW_PYTHON" = true ] ; then
PS1="\[${BOLD}${WHITE}\]$(env_prompt) "$PS1
fi
}
safe_append_prompt_command prompt_command
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# prompt themeing
#added TITLEBAR for updating the tab and window titles with the pwd
case $TERM in
xterm*)
TITLEBAR="\[\033]0;\w\007\]"
;;
*)
TITLEBAR=""
;;
esac
function prompt_command() {
PS1="${TITLEBAR}${orange}${reset_color}${green}\w${bold_blue}\[$(scm_prompt_info)\]${normal} "
}
# scm themeing
SCM_THEME_PROMPT_DIRTY=" ✗"
SCM_THEME_PROMPT_CLEAN=" ✓"
SCM_THEME_PROMPT_PREFIX="("
SCM_THEME_PROMPT_SUFFIX=")"
safe_append_prompt_command prompt_command
+22
View File
@@ -0,0 +1,22 @@
# For unstaged(*) and staged(+) values next to branch name in __git_ps1
GIT_PS1_SHOWDIRTYSTATE="enabled"
function rvm_version_prompt {
local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}')
[ "$gemset" != "" ] && gemset="@$gemset"
local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}')
[ "$version" == "1.9.2" ] && version=""
local full="$version$gemset"
[ "$full" != "" ] && echo "$full"
}
function prompt_command() {
# Check http://github.com/Sirupsen/dotfiles for screenshot
PS1="$blue\W/$bold_blue$(rvm_version_prompt)$bold_green$(__git_ps1 " (%s)") ${normal}$ "
}
safe_append_prompt_command prompt_command
+76
View File
@@ -0,0 +1,76 @@
SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX=""
SCM_THEME_PROMPT_DIRTY=" ${bold_red}${normal}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}${normal}"
SCM_GIT_CHAR="${bold_cyan}±${normal}"
SCM_SVN_CHAR="${bold_green}${normal}"
SCM_HG_CHAR="${bold_red}${normal}"
#Mysql Prompt
export MYSQL_PS1="(\u@\h) [\d]> "
case $TERM in
xterm*)
TITLEBAR="\[\033]0;\w\007\]"
;;
*)
TITLEBAR=""
;;
esac
PS3=">> "
__my_rvm_ruby_version() {
local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}')
[ "$gemset" != "" ] && gemset="@$gemset"
local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}')
local full="$version$gemset"
[ "$full" != "" ] && echo "[$full]"
}
__my_venv_prompt() {
if [ ! -z "$VIRTUAL_ENV" ]
then
echo "[${blue}@${normal}${VIRTUAL_ENV##*/}]"
fi
}
is_vim_shell() {
if [ ! -z "$VIMRUNTIME" ]
then
echo "[${cyan}vim shell${normal}]"
fi
}
prompt() {
SCM_PROMPT_FORMAT='[%s][%s]'
case $HOSTNAME in
"clappy"* ) my_ps_host="${green}\h${normal}";
;;
"icekernel") my_ps_host="${red}\h${normal}";
;;
* ) my_ps_host="${green}\h${normal}";
;;
esac
my_ps_user="\[\033[01;32m\]\u\[\033[00m\]";
my_ps_root="\[\033[01;31m\]\u\[\033[00m\]";
my_ps_path="\[\033[01;36m\]\w\[\033[00m\]";
# nice prompt
case "`id -u`" in
0) PS1="${TITLEBAR}[$my_ps_root][$my_ps_host]$(scm_prompt)$(__my_rvm_ruby_version)[${cyan}\w${normal}]$(is_vim_shell)
$ "
;;
*) PS1="${TITLEBAR}[$my_ps_user][$my_ps_host]$(scm_prompt)$(__my_rvm_ruby_version)$(__my_venv_prompt)[${cyan}\w${normal}]$(is_vim_shell)
$ "
;;
esac
}
PS2="> "
safe_append_prompt_command prompt
@@ -0,0 +1,24 @@
# scm themeing
SCM_THEME_PROMPT_DIRTY="×"
SCM_THEME_PROMPT_CLEAN="✓"
SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX=""
# TODO: need a check for OS before adding this to the prompt
# ${debian_chroot:+($debian_chroot)}
#added TITLEBAR for updating the tab and window titles with the pwd
case $TERM in
xterm*)
TITLEBAR='\[\033]0;\w\007\]'
;;
*)
TITLEBAR=""
;;
esac
function prompt_command() {
PROMPT='${green}\u${normal}@${green}\h${normal}:${blue}\w${normal}${red}$(prompt_char)$(git_prompt_info)${normal}\$ '
}
safe_append_prompt_command prompt_command
+61
View File
@@ -0,0 +1,61 @@
#!/usr/bin/env bash
__tonka_time() {
THEME_CLOCK_FORMAT="%H%M"
clock_prompt
}
__tonka_date() {
THEME_CLOCK_FORMAT="%a,%d %b %y"
clock_prompt
}
__tonka_clock() {
local LIGHT_BLUE="\[\033[1;34m\]"
if [[ "${THEME_SHOW_CLOCK}" = "true" ]]; then
echo "$(__tonka_time)${LIGHT_BLUE}:$(__tonka_date)${LIGHT_BLUE}:"
fi
}
prompt_setter() {
# Named "Tonka" because of the colour scheme
local WHITE="\[\033[1;37m\]"
local LIGHT_BLUE="\[\033[1;34m\]"
local YELLOW="\[\033[1;33m\]"
local NO_COLOUR="\[\033[0m\]"
case $TERM in
xterm*|rxvt*)
TITLEBAR='\[\033]0;\u@\h:\w\007\]'
;;
*)
TITLEBAR=""
;;
esac
PS1="$TITLEBAR\
$YELLOW-$LIGHT_BLUE-(\
$YELLOW\u$LIGHT_BLUE@$YELLOW\h\
$LIGHT_BLUE)-(\
$YELLOW\$PWD\
$LIGHT_BLUE)-$YELLOW-\
\n\
$YELLOW-$LIGHT_BLUE-(\
$(__tonka_clock)\
$WHITE\$ $LIGHT_BLUE)-$YELLOW-$NO_COLOUR "
PS2="$LIGHT_BLUE-$YELLOW-$YELLOW-$NO_COLOUR "
}
safe_append_prompt_command prompt_setter
THEME_SHOW_CLOCK=${THEME_SHOW_CLOCK:-"true"}
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"\[\033[1;33m\]"}
export PS3=">> "
LS_COLORS='no=00:fi=00:di=00;33:ln=01;36:pi=40;34:so=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.deb=01;31:*.jpg=01;35:*.gif=01;35:*.bmp=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.mpg=01;37:*.avi=01;37:*.gl=01;37:*.dl=01;37:';
export LS_COLORS
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
SCM_THEME_PROMPT_PREFIX=" ${purple}"
SCM_THEME_PROMPT_SUFFIX=" ${normal}"
SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${green}"
SCM_GIT_SHOW_DETAILS="false"
function prompt_command() {
PS1="${yellow}\u${normal}${cyan}@\h${normal}${purple} ${normal}${green}\w${normal}$(scm_prompt_info)> "
}
safe_append_prompt_command prompt_command
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
#
# Based on 'bobby' theme with the addition of virtualenv_prompt
#
SCM_THEME_PROMPT_DIRTY=" ${red}"
SCM_THEME_PROMPT_CLEAN=" ${green}"
SCM_THEME_PROMPT_PREFIX=" ${yellow}|${reset_color}"
SCM_THEME_PROMPT_SUFFIX="${yellow}|"
RVM_THEME_PROMPT_PREFIX="|"
RVM_THEME_PROMPT_SUFFIX="|"
VIRTUALENV_THEME_PROMPT_PREFIX='|'
VIRTUALENV_THEME_PROMPT_SUFFIX='|'
function prompt_command() {
PS1="\n${green}$(virtualenv_prompt)${red}$(ruby_version_prompt) ${reset_color}\h ${orange}in ${reset_color}\w\n${yellow}$(scm_char)$(scm_prompt_info) ${yellow}${white} "
}
safe_append_prompt_command prompt_command
@@ -0,0 +1,26 @@
#!/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}|"
RVM_THEME_PROMPT_PREFIX="|"
RVM_THEME_PROMPT_SUFFIX="|"
function prompt_command() {
if [ $? -eq 0 ]; then
status=❤️
else
status=💔
fi
PS1="\n${yellow}$(ruby_version_prompt) ${purple}\h ${reset_color}in ${green}\w $status \n${bold_cyan} ${blue}|$(clock_prompt)|${green}$(scm_prompt_info) ${green}${reset_color} "
}
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$blue"}
PROMPT_COMMAND=prompt_command;
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# zitron theme by Florian Baumann <flo@noqqe.de>
## git-theme
# feel free to change git chars.
GIT_THEME_PROMPT_DIRTY="${bold_yellow}*${normal}"
GIT_THEME_PROMPT_CLEAN=""
GIT_THEME_PROMPT_PREFIX=""
GIT_THEME_PROMPT_SUFFIX=""
## ls colors
# thanks a lot to http://geoff.greer.fm/lscolors/
export LSCOLORS="Gxfxcxdxbxegedabagacad"
export LS_COLORS="no=00:fi=00:di=01;33:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;34:*.svg=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:"
function prompt_command() {
## look-a-like
# user:host:pwd git-branch(*)$
# for example:
# noqqe:deathstar:themes master*$
PS1="${no_color}\u:$(hostname)${normal}:${bold_yellow}\W/${normal} $(git_prompt_info)${reset_color}$ "
}
safe_append_prompt_command prompt_command
+92
View File
@@ -0,0 +1,92 @@
SCM_THEME_PROMPT_PREFIX=""
SCM_THEME_PROMPT_SUFFIX=""
SCM_THEME_PROMPT_DIRTY=" ${bold_red}${normal}"
SCM_THEME_PROMPT_CLEAN=" ${bold_green}${normal}"
SCM_GIT_CHAR="${bold_green}±${normal}"
SCM_SVN_CHAR="${bold_cyan}${normal}"
SCM_HG_CHAR="${bold_red}${normal}"
#Mysql Prompt
export MYSQL_PS1="(\u@\h) [\d]> "
case $TERM in
xterm*)
TITLEBAR="\[\033]0;\w\007\]"
;;
*)
TITLEBAR=""
;;
esac
PS3=">> "
__my_rvm_ruby_version() {
local gemset=$(echo $GEM_HOME | awk -F'@' '{print $2}')
[ "$gemset" != "" ] && gemset="@$gemset"
local version=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}')
local full="$version$gemset"
[ "$full" != "" ] && echo "[$full]"
}
is_vim_shell() {
if [ ! -z "$VIMRUNTIME" ]
then
echo "[${cyan}vim shell${normal}]"
fi
}
# show chroot if exist
chroot(){
if [ -n "$debian_chroot" ]
then
my_ps_chroot="${bold_cyan}$debian_chroot${normal}";
echo "($my_ps_chroot)";
fi
}
# show virtualenvwrapper
my_ve(){
if [ -n "$CONDA_DEFAULT_ENV" ]
then
my_ps_ve="${bold_purple}${CONDA_DEFAULT_ENV}${normal}";
echo "($my_ps_ve)";
elif [ -n "$VIRTUAL_ENV" ]
then
my_ps_ve="${bold_purple}$ve${normal}";
echo "($my_ps_ve)";
fi
echo "";
}
prompt() {
SCM_PROMPT_FORMAT='[%s][%s]'
my_ps_host="${green}\h${normal}";
# yes, these are the the same for now ...
my_ps_host_root="${green}\h${normal}";
my_ps_user="${bold_green}\u${normal}"
my_ps_root="${bold_red}\u${normal}";
if [ -n "$VIRTUAL_ENV" ]
then
ve=`basename "$VIRTUAL_ENV"`;
fi
# nice prompt
case "`id -u`" in
0) PS1="${TITLEBAR}┌─$(my_ve)$(chroot)[$my_ps_root][$my_ps_host_root]$(scm_prompt)$(__my_rvm_ruby_version)[${cyan}\w${normal}]$(is_vim_shell)
└─▪ "
;;
*) PS1="${TITLEBAR}┌─$(my_ve)$(chroot)[$my_ps_user][$my_ps_host]$(scm_prompt)$(__my_rvm_ruby_version)[${cyan}\w${normal}]$(is_vim_shell)
└─▪ "
;;
esac
}
PS2="└─▪ "
safe_append_prompt_command prompt