Merge pull request #1980 from gaelicWizard/themes-SC2154-B
Themes: `shellcheck` (SC2154); Part Bpull/1958/head
commit
86c1e3c043
|
|
@ -1,6 +1,5 @@
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
# shellcheck disable=SC2034 # Expected behavior for themes.
|
# shellcheck disable=SC2034 # Expected behavior for themes.
|
||||||
# shellcheck disable=SC2154 #TODO: fix these all.
|
|
||||||
|
|
||||||
# Atomic Bash Prompt for Bash-it
|
# Atomic Bash Prompt for Bash-it
|
||||||
# By lfelipe base on the theme brainy of MunifTanjim
|
# By lfelipe base on the theme brainy of MunifTanjim
|
||||||
|
|
@ -29,48 +28,48 @@ Face="\342\230\273"
|
||||||
## Parsers ##
|
## Parsers ##
|
||||||
#############
|
#############
|
||||||
|
|
||||||
____atomic_top_left_parse() {
|
function ____atomic_top_left_parse() {
|
||||||
ifs_old="${IFS}"
|
local ifs_old="${IFS}"
|
||||||
IFS="|"
|
local IFS="|"
|
||||||
read -r -a args <<< "$@"
|
read -r -a args <<< "$@"
|
||||||
IFS="${ifs_old}"
|
IFS="${ifs_old}"
|
||||||
if [ -n "${args[3]}" ]; then
|
if [[ -n "${args[3]:-}" ]]; then
|
||||||
_TOP_LEFT+="${args[2]}${args[3]}"
|
_TOP_LEFT+="${args[2]?}${args[3]?}"
|
||||||
fi
|
fi
|
||||||
_TOP_LEFT+="${args[0]}${args[1]}"
|
_TOP_LEFT+="${args[0]?}${args[1]:-}"
|
||||||
if [ -n "${args[4]}" ]; then
|
if [[ -n "${args[4]:-}" ]]; then
|
||||||
_TOP_LEFT+="${args[2]}${args[4]}"
|
_TOP_LEFT+="${args[2]?}${args[4]?}"
|
||||||
fi
|
fi
|
||||||
_TOP_LEFT+=""
|
_TOP_LEFT+=""
|
||||||
}
|
}
|
||||||
|
|
||||||
____atomic_top_right_parse() {
|
function ____atomic_top_right_parse() {
|
||||||
ifs_old="${IFS}"
|
local ifs_old="${IFS}"
|
||||||
IFS="|"
|
local IFS="|"
|
||||||
read -r -a args <<< "$@"
|
read -r -a args <<< "$@"
|
||||||
IFS="${ifs_old}"
|
IFS="${ifs_old}"
|
||||||
_TOP_RIGHT+=" "
|
_TOP_RIGHT+=" "
|
||||||
if [ -n "${args[3]}" ]; then
|
if [[ -n "${args[3]:-}" ]]; then
|
||||||
_TOP_RIGHT+="${args[2]}${args[3]}"
|
_TOP_RIGHT+="${args[2]?}${args[3]?}"
|
||||||
fi
|
fi
|
||||||
_TOP_RIGHT+="${args[0]}${args[1]}"
|
_TOP_RIGHT+="${args[0]?}${args[1]:-}"
|
||||||
if [ -n "${args[4]}" ]; then
|
if [[ -n "${args[4]:-}" ]]; then
|
||||||
_TOP_RIGHT+="${args[2]}${args[4]}"
|
_TOP_RIGHT+="${args[2]?}${args[4]?}"
|
||||||
fi
|
fi
|
||||||
__TOP_RIGHT_LEN=$((__TOP_RIGHT_LEN + ${#args[1]} + ${#args[3]} + ${#args[4]} + 1))
|
__TOP_RIGHT_LEN=$((__TOP_RIGHT_LEN + ${#args[1]} + ${#args[3]} + ${#args[4]} + 1))
|
||||||
((__SEG_AT_RIGHT += 1))
|
((__SEG_AT_RIGHT += 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
____atomic_bottom_parse() {
|
function ____atomic_bottom_parse() {
|
||||||
ifs_old="${IFS}"
|
local ifs_old="${IFS}"
|
||||||
IFS="|"
|
local IFS="|"
|
||||||
read -r -a args <<< "$@"
|
read -r -a args <<< "$@"
|
||||||
IFS="${ifs_old}"
|
IFS="${ifs_old}"
|
||||||
_BOTTOM+="${args[0]}${args[1]}"
|
_BOTTOM+="${args[0]?}${args[1]?${FUNCNAME[0]}}"
|
||||||
[ ${#args[1]} -gt 0 ] && _BOTTOM+=" "
|
[[ ${#args[1]} -gt 0 ]] && _BOTTOM+=" "
|
||||||
}
|
}
|
||||||
|
|
||||||
____atomic_top() {
|
function ____atomic_top() {
|
||||||
_TOP_LEFT=""
|
_TOP_LEFT=""
|
||||||
_TOP_RIGHT=""
|
_TOP_RIGHT=""
|
||||||
__TOP_RIGHT_LEN=0
|
__TOP_RIGHT_LEN=0
|
||||||
|
|
@ -78,7 +77,7 @@ ____atomic_top() {
|
||||||
|
|
||||||
for seg in ${___ATOMIC_TOP_LEFT}; do
|
for seg in ${___ATOMIC_TOP_LEFT}; do
|
||||||
info="$(___atomic_prompt_"${seg}")"
|
info="$(___atomic_prompt_"${seg}")"
|
||||||
[ -n "${info}" ] && ____atomic_top_left_parse "${info}"
|
[[ -n "${info}" ]] && ____atomic_top_left_parse "${info}"
|
||||||
done
|
done
|
||||||
|
|
||||||
___cursor_right="\e[500C"
|
___cursor_right="\e[500C"
|
||||||
|
|
@ -86,21 +85,21 @@ ____atomic_top() {
|
||||||
|
|
||||||
for seg in ${___ATOMIC_TOP_RIGHT}; do
|
for seg in ${___ATOMIC_TOP_RIGHT}; do
|
||||||
info="$(___atomic_prompt_"${seg}")"
|
info="$(___atomic_prompt_"${seg}")"
|
||||||
[ -n "${info}" ] && ____atomic_top_right_parse "${info}"
|
[[ -n "${info}" ]] && ____atomic_top_right_parse "${info}"
|
||||||
done
|
done
|
||||||
|
|
||||||
[ $__TOP_RIGHT_LEN -gt 0 ] && __TOP_RIGHT_LEN=$((__TOP_RIGHT_LEN - 0))
|
[[ $__TOP_RIGHT_LEN -gt 0 ]] && __TOP_RIGHT_LEN=$((__TOP_RIGHT_LEN - 0))
|
||||||
___cursor_adjust="\e[${__TOP_RIGHT_LEN}D"
|
___cursor_adjust="\e[${__TOP_RIGHT_LEN}D"
|
||||||
_TOP_LEFT+="${___cursor_adjust}"
|
_TOP_LEFT+="${___cursor_adjust}"
|
||||||
|
|
||||||
printf "%s%s" "${_TOP_LEFT}" "${_TOP_RIGHT}"
|
printf "%s%s" "${_TOP_LEFT}" "${_TOP_RIGHT}"
|
||||||
}
|
}
|
||||||
|
|
||||||
____atomic_bottom() {
|
function ____atomic_bottom() {
|
||||||
_BOTTOM=""
|
_BOTTOM=""
|
||||||
for seg in $___ATOMIC_BOTTOM; do
|
for seg in $___ATOMIC_BOTTOM; do
|
||||||
info="$(___atomic_prompt_"${seg}")"
|
info="$(___atomic_prompt_"${seg}")"
|
||||||
[ -n "${info}" ] && ____atomic_bottom_parse "${info}"
|
[[ -n "${info}" ]] && ____atomic_bottom_parse "${info}"
|
||||||
done
|
done
|
||||||
printf "\n%s" "${_BOTTOM}"
|
printf "\n%s" "${_BOTTOM}"
|
||||||
}
|
}
|
||||||
|
|
@ -109,95 +108,96 @@ ____atomic_bottom() {
|
||||||
## Segments ##
|
## Segments ##
|
||||||
##############
|
##############
|
||||||
|
|
||||||
___atomic_prompt_user_info() {
|
function ___atomic_prompt_user_info() {
|
||||||
color=$white
|
local color="${white?}" box
|
||||||
box="${normal}${LineA}\$([[ \$? != 0 ]] && echo \"${BIWhite}[${IRed}${SX}${BIWhite}]${normal}${Line}\")${Line}${BIWhite}[|${BIWhite}]${normal}${Line}"
|
local info="${IYellow}\u${IRed}@${IGreen}\h"
|
||||||
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}"
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${white?}" "${box}"
|
||||||
}
|
}
|
||||||
|
|
||||||
___atomic_prompt_dir() {
|
function ___atomic_prompt_dir() {
|
||||||
color=${IRed}
|
local color="${IRed?}"
|
||||||
box="[|]${normal}"
|
local box="[|]${normal}"
|
||||||
info="\w"
|
local info="\w"
|
||||||
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white?}" "${box}"
|
||||||
}
|
}
|
||||||
|
|
||||||
___atomic_prompt_scm() {
|
function ___atomic_prompt_scm() {
|
||||||
[ "${THEME_SHOW_SCM}" != "true" ] && return
|
[[ "${THEME_SHOW_SCM:-}" != "true" ]] && return
|
||||||
color=$bold_green
|
local color="${bold_green?}" box info
|
||||||
box="${Line}[${IWhite}$(scm_char)] "
|
box="${Line?}[${IWhite?}$(scm_char)] "
|
||||||
info="$(scm_prompt_info)"
|
info="$(scm_prompt_info)"
|
||||||
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white?}" "${box}"
|
||||||
}
|
}
|
||||||
|
|
||||||
___atomic_prompt_python() {
|
function ___atomic_prompt_python() {
|
||||||
[ "${THEME_SHOW_PYTHON}" != "true" ] && return
|
[[ "${THEME_SHOW_PYTHON:-}" != "true" ]] && return
|
||||||
color=$bold_yellow
|
local color="${bold_yellow?}"
|
||||||
box="[|]"
|
local box="[|]" info
|
||||||
info="$(python_version_prompt)"
|
info="$(python_version_prompt)"
|
||||||
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_blue}" "${box}"
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_blue?}" "${box}"
|
||||||
}
|
}
|
||||||
|
|
||||||
___atomic_prompt_ruby() {
|
function ___atomic_prompt_ruby() {
|
||||||
[ "${THEME_SHOW_RUBY}" != "true" ] && return
|
[[ "${THEME_SHOW_RUBY:-}" != "true" ]] && return
|
||||||
color=$bold_white
|
local color="${bold_white?}"
|
||||||
box="[|]"
|
local box="[|]" info
|
||||||
info="rb-$(ruby_version_prompt)"
|
info="rb-$(ruby_version_prompt)"
|
||||||
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_red}" "${box}"
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_red?}" "${box}"
|
||||||
}
|
}
|
||||||
|
|
||||||
___atomic_prompt_todo() {
|
function ___atomic_prompt_todo() {
|
||||||
[ "${THEME_SHOW_TODO}" != "true" ] \
|
[[ "${THEME_SHOW_TODO:-}" != "true" ||
|
||||||
|| [ -z "$(which todo.sh)" ] && return
|
-z "$(which todo.sh)" ]] && return
|
||||||
color=$bold_white
|
local color="${bold_white?}"
|
||||||
box="[|]"
|
local box="[|]" info
|
||||||
info="t:$(todo.sh ls | grep -E "TODO: [0-9]+ of ([0-9]+)" | awk '{ print $4 }')"
|
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}"
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_green?}" "${box}"
|
||||||
}
|
}
|
||||||
|
|
||||||
___atomic_prompt_clock() {
|
function ___atomic_prompt_clock() {
|
||||||
[ "${THEME_SHOW_CLOCK}" != "true" ] && return
|
[[ "${THEME_SHOW_CLOCK:-}" != "true" ]] && return
|
||||||
color=$THEME_CLOCK_COLOR
|
local color="${THEME_CLOCK_COLOR:-}"
|
||||||
box="[|]"
|
local box="[|]" info
|
||||||
info="$(date +"${THEME_CLOCK_FORMAT}")"
|
info="$(date +"${THEME_CLOCK_FORMAT}")"
|
||||||
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white?}" "${box}"
|
||||||
}
|
}
|
||||||
|
|
||||||
___atomic_prompt_battery() {
|
function ___atomic_prompt_battery() {
|
||||||
|
local batp box info
|
||||||
! _command_exists battery_percentage \
|
! _command_exists battery_percentage \
|
||||||
|| [ "${THEME_SHOW_BATTERY}" != "true" ] \
|
|| [[ "${THEME_SHOW_BATTERY:-}" != "true" ]] \
|
||||||
|| [ "$(battery_percentage)" = "no" ] && return
|
|| [[ "$(battery_percentage)" = "no" ]] && return
|
||||||
|
|
||||||
batp=$(battery_percentage)
|
batp=$(battery_percentage)
|
||||||
if [ "$batp" -eq 50 ] || [ "$batp" -gt 50 ]; then
|
if [[ "$batp" -eq 50 || "$batp" -gt 50 ]]; then
|
||||||
color=$bold_green
|
color="${bold_green?}"
|
||||||
elif [ "$batp" -lt 50 ] && [ "$batp" -gt 25 ]; then
|
elif [[ "$batp" -lt 50 && "$batp" -gt 25 ]]; then
|
||||||
color=$bold_yellow
|
color="${bold_yellow?}"
|
||||||
elif [ "$batp" -eq 25 ] || [ "$batp" -lt 25 ]; then
|
elif [[ "$batp" -eq 25 || "$batp" -lt 25 ]]; then
|
||||||
color=$IRed
|
color="${IRed?}"
|
||||||
fi
|
fi
|
||||||
box="[|]"
|
box="[|]"
|
||||||
ac_adapter_connected && info="+"
|
ac_adapter_connected && info="+"
|
||||||
ac_adapter_disconnected && info="-"
|
ac_adapter_disconnected && info="-"
|
||||||
info+=$batp
|
info+=$batp
|
||||||
[ "$batp" -eq 100 ] || [ "$batp" -gt 100 ] && info="AC"
|
[[ "$batp" -eq 100 || "$batp" -gt 100 ]] && info="AC"
|
||||||
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white}" "${box}"
|
printf "%s|%s|%s|%s" "${color}" "${info}" "${bold_white?}" "${box}"
|
||||||
}
|
}
|
||||||
|
|
||||||
___atomic_prompt_exitcode() {
|
function ___atomic_prompt_exitcode() {
|
||||||
[ "${THEME_SHOW_EXITCODE}" != "true" ] && return
|
[[ "${THEME_SHOW_EXITCODE:-}" != "true" ]] && return
|
||||||
color=$bold_purple
|
local color="${bold_purple?}"
|
||||||
[ "$exitcode" -ne 0 ] && printf "%s|%s" "${color}" "${exitcode}"
|
[[ "${exitcode?}" -ne 0 ]] && printf "%s|%s" "${color}" "${exitcode}"
|
||||||
}
|
}
|
||||||
|
|
||||||
___atomic_prompt_char() {
|
function ___atomic_prompt_char() {
|
||||||
color=$white
|
local color="${white?}"
|
||||||
prompt_char="${__ATOMIC_PROMPT_CHAR_PS1}"
|
local prompt_char="${__ATOMIC_PROMPT_CHAR_PS1?}"
|
||||||
if [ "${THEME_SHOW_SUDO}" == "true" ]; then
|
if [[ "${THEME_SHOW_SUDO:-}" == "true" ]]; then
|
||||||
if sudo -vn 1> /dev/null 2>&1; then
|
if sudo -vn 1> /dev/null 2>&1; then
|
||||||
prompt_char="${__ATOMIC_PROMPT_CHAR_PS1_SUDO}"
|
prompt_char="${__ATOMIC_PROMPT_CHAR_PS1_SUDO?}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
printf "%s|%s" "${color}" "${prompt_char}"
|
printf "%s|%s" "${color}" "${prompt_char}"
|
||||||
|
|
@ -207,19 +207,17 @@ ___atomic_prompt_char() {
|
||||||
## cli ##
|
## cli ##
|
||||||
#########
|
#########
|
||||||
|
|
||||||
__atomic_show() {
|
function __atomic_show() {
|
||||||
typeset _seg=${1:-}
|
local _seg="${1?}"
|
||||||
shift
|
|
||||||
export "THEME_SHOW_${_seg}"=true
|
export "THEME_SHOW_${_seg}"=true
|
||||||
}
|
}
|
||||||
|
|
||||||
__atomic_hide() {
|
function __atomic_hide() {
|
||||||
typeset _seg=${1:-}
|
local _seg="${1?}"
|
||||||
shift
|
|
||||||
export "THEME_SHOW_${_seg}"=false
|
export "THEME_SHOW_${_seg}"=false
|
||||||
}
|
}
|
||||||
|
|
||||||
_atomic_completion() {
|
function _atomic_completion() {
|
||||||
local cur _action actions segments
|
local cur _action actions segments
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
|
@ -239,22 +237,26 @@ _atomic_completion() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
atomic() {
|
function atomic() {
|
||||||
typeset action=${1:-}
|
local action="${1?}"
|
||||||
shift
|
shift
|
||||||
typeset segs=${*:-}
|
local segs=("${@?}")
|
||||||
typeset func
|
local func
|
||||||
case $action in
|
case "${action}" in
|
||||||
show)
|
show)
|
||||||
func=__atomic_show
|
func=__atomic_show
|
||||||
;;
|
;;
|
||||||
hide)
|
hide)
|
||||||
func=__atomic_hide
|
func=__atomic_hide
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
_log_error "${FUNCNAME[0]}: unknown action '${action}'"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
for seg in ${segs}; do
|
for seg in "${segs[@]}"; do
|
||||||
seg=$(printf "%s" "${seg}" | tr '[:lower:]' '[:upper:]')
|
seg="$(printf "%s" "${seg}" | tr '[:lower:]' '[:upper:]')"
|
||||||
$func "${seg}"
|
"${func}" "${seg}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -264,55 +266,55 @@ complete -F _atomic_completion atomic
|
||||||
## Variables ##
|
## Variables ##
|
||||||
###############
|
###############
|
||||||
|
|
||||||
export SCM_THEME_PROMPT_PREFIX=""
|
SCM_THEME_PROMPT_PREFIX=""
|
||||||
export SCM_THEME_PROMPT_SUFFIX=""
|
SCM_THEME_PROMPT_SUFFIX=""
|
||||||
|
|
||||||
export RBENV_THEME_PROMPT_PREFIX=""
|
RBENV_THEME_PROMPT_PREFIX=""
|
||||||
export RBENV_THEME_PROMPT_SUFFIX=""
|
RBENV_THEME_PROMPT_SUFFIX=""
|
||||||
export RBFU_THEME_PROMPT_PREFIX=""
|
RBFU_THEME_PROMPT_PREFIX=""
|
||||||
export RBFU_THEME_PROMPT_SUFFIX=""
|
RBFU_THEME_PROMPT_SUFFIX=""
|
||||||
export RVM_THEME_PROMPT_PREFIX=""
|
RVM_THEME_PROMPT_PREFIX=""
|
||||||
export RVM_THEME_PROMPT_SUFFIX=""
|
RVM_THEME_PROMPT_SUFFIX=""
|
||||||
|
|
||||||
export SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}"
|
SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}"
|
||||||
export SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓${normal}"
|
SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓${normal}"
|
||||||
|
|
||||||
THEME_SHOW_SUDO=${THEME_SHOW_SUDO:-"true"}
|
: "${THEME_SHOW_SUDO:="true"}"
|
||||||
THEME_SHOW_SCM=${THEME_SHOW_SCM:-"true"}
|
: "${THEME_SHOW_SCM:="true"}"
|
||||||
THEME_SHOW_RUBY=${THEME_SHOW_RUBY:-"false"}
|
: "${THEME_SHOW_RUBY:="false"}"
|
||||||
THEME_SHOW_PYTHON=${THEME_SHOW_PYTHON:-"false"}
|
: "${THEME_SHOW_PYTHON:="false"}"
|
||||||
THEME_SHOW_CLOCK=${THEME_SHOW_CLOCK:-"true"}
|
: "${THEME_SHOW_CLOCK:="true"}"
|
||||||
THEME_SHOW_TODO=${THEME_SHOW_TODO:-"false"}
|
: "${THEME_SHOW_TODO:="false"}"
|
||||||
THEME_SHOW_BATTERY=${THEME_SHOW_BATTERY:-"true"}
|
: "${THEME_SHOW_BATTERY:="true"}"
|
||||||
THEME_SHOW_EXITCODE=${THEME_SHOW_EXITCODE:-"false"}
|
: "${THEME_SHOW_EXITCODE:="false"}"
|
||||||
|
|
||||||
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"${BICyan}"}
|
: "${THEME_CLOCK_COLOR:=${BICyan?}}"
|
||||||
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%a %b %d - %H:%M"}
|
: "${THEME_CLOCK_FORMAT:="%a %b %d - %H:%M"}"
|
||||||
|
|
||||||
__ATOMIC_PROMPT_CHAR_PS1=${THEME_PROMPT_CHAR_PS1:-"${normal}${LineB}${bold_white}${Circle}"}
|
__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_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_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_PROMPT_CHAR_PS2_SUDO=${THEME_PROMPT_CHAR_PS2_SUDO:-"${normal?}${LineB?}${bold_red?}${Face?}"}
|
||||||
|
|
||||||
___ATOMIC_TOP_LEFT=${___ATOMIC_TOP_LEFT:-"user_info dir scm"}
|
: "${___ATOMIC_TOP_LEFT:="user_info dir scm"}"
|
||||||
___ATOMIC_TOP_RIGHT=${___ATOMIC_TOP_RIGHT:-"exitcode python ruby todo clock battery"}
|
: "${___ATOMIC_TOP_RIGHT:="exitcode python ruby todo clock battery"}"
|
||||||
___ATOMIC_BOTTOM=${___ATOMIC_BOTTOM:-"char"}
|
: "${___ATOMIC_BOTTOM:="char"}"
|
||||||
|
|
||||||
############
|
############
|
||||||
## Prompt ##
|
## Prompt ##
|
||||||
############
|
############
|
||||||
|
|
||||||
__atomic_ps1() {
|
function __atomic_ps1() {
|
||||||
printf "%s%s%s" "$(____atomic_top)" "$(____atomic_bottom)" "${normal}"
|
printf "%s%s%s" "$(____atomic_top)" "$(____atomic_bottom)" "${normal?}"
|
||||||
}
|
}
|
||||||
|
|
||||||
__atomic_ps2() {
|
function __atomic_ps2() {
|
||||||
color=$bold_white
|
color="${bold_white?}"
|
||||||
printf "%s%s%s" "${color}" "${__ATOMIC_PROMPT_CHAR_PS2} " "${normal}"
|
printf "%s%s%s" "${color}" "${__ATOMIC_PROMPT_CHAR_PS2?} " "${normal?}"
|
||||||
}
|
}
|
||||||
|
|
||||||
_atomic_prompt() {
|
function _atomic_prompt() {
|
||||||
exitcode="$?"
|
exitcode="$?"
|
||||||
|
|
||||||
PS1="$(__atomic_ps1)"
|
PS1="$(__atomic_ps1)"
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,26 @@
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
# shellcheck disable=SC2034 # Expected behavior for themes.
|
# shellcheck disable=SC2034 # Expected behavior for themes.
|
||||||
# shellcheck disable=SC2154 #TODO: fix these all.
|
|
||||||
|
|
||||||
SCM_THEME_PROMPT_DIRTY=" ${red}✗"
|
SCM_THEME_PROMPT_DIRTY=" ${red?}✗"
|
||||||
SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓"
|
SCM_THEME_PROMPT_CLEAN=" ${bold_green?}✓"
|
||||||
SCM_THEME_PROMPT_PREFIX=" |"
|
SCM_THEME_PROMPT_PREFIX=" |"
|
||||||
SCM_THEME_PROMPT_SUFFIX="${green}|"
|
SCM_THEME_PROMPT_SUFFIX="${green?}|"
|
||||||
|
|
||||||
GIT_THEME_PROMPT_DIRTY=" ${red}✗"
|
GIT_THEME_PROMPT_DIRTY=" ${red?}✗"
|
||||||
GIT_THEME_PROMPT_CLEAN=" ${bold_green}✓"
|
GIT_THEME_PROMPT_CLEAN=" ${bold_green?}✓"
|
||||||
GIT_THEME_PROMPT_PREFIX=" ${green}|"
|
GIT_THEME_PROMPT_PREFIX=" ${green?}|"
|
||||||
GIT_THEME_PROMPT_SUFFIX="${green}|"
|
GIT_THEME_PROMPT_SUFFIX="${green?}|"
|
||||||
|
|
||||||
CONDAENV_THEME_PROMPT_SUFFIX="|"
|
CONDAENV_THEME_PROMPT_SUFFIX="|"
|
||||||
|
|
||||||
function prompt_command() {
|
function prompt_command() {
|
||||||
PS1="\n${yellow}$(python_version_prompt) " # Name of virtual env followed by python version
|
PS1="\n${yellow?}$(python_version_prompt) " # Name of virtual env followed by python version
|
||||||
PS1+="${purple}\h "
|
PS1+="${purple?}\h "
|
||||||
PS1+="${reset_color}in "
|
PS1+="${reset_color?}in "
|
||||||
PS1+="${green}\w\n"
|
PS1+="${green?}\w\n"
|
||||||
PS1+="${bold_cyan}$(scm_char)"
|
PS1+="${bold_cyan?}$(scm_char)"
|
||||||
PS1+="${green}$(scm_prompt_info) "
|
PS1+="${green?}$(scm_prompt_info) "
|
||||||
PS1+="${green}→${reset_color} "
|
PS1+="${green?}→${reset_color?} "
|
||||||
}
|
}
|
||||||
|
|
||||||
safe_append_prompt_command prompt_command
|
safe_append_prompt_command prompt_command
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,40 @@
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
# shellcheck disable=SC2034 # Expected behavior for themes.
|
# shellcheck disable=SC2034 # Expected behavior for themes.
|
||||||
# shellcheck disable=SC2154 #TODO: fix these all.
|
|
||||||
|
|
||||||
SCM_THEME_PROMPT_DIRTY=" ${red}✗"
|
SCM_THEME_PROMPT_DIRTY=" ${red?}✗"
|
||||||
SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓"
|
SCM_THEME_PROMPT_CLEAN=" ${bold_green?}✓"
|
||||||
SCM_THEME_PROMPT_PREFIX=" ${green}|"
|
SCM_THEME_PROMPT_PREFIX=" ${green?}|"
|
||||||
SCM_THEME_PROMPT_SUFFIX="${green}|"
|
SCM_THEME_PROMPT_SUFFIX="${green?}|"
|
||||||
|
|
||||||
GIT_THEME_PROMPT_DIRTY=" ${red}✗"
|
GIT_THEME_PROMPT_DIRTY=" ${red?}✗"
|
||||||
GIT_THEME_PROMPT_CLEAN=" ${bold_green}✓"
|
GIT_THEME_PROMPT_CLEAN=" ${bold_green?}✓"
|
||||||
GIT_THEME_PROMPT_PREFIX=" ${green}|"
|
GIT_THEME_PROMPT_PREFIX=" ${green?}|"
|
||||||
GIT_THEME_PROMPT_SUFFIX="${green}|"
|
GIT_THEME_PROMPT_SUFFIX="${green?}|"
|
||||||
|
|
||||||
RVM_THEME_PROMPT_PREFIX="|"
|
RVM_THEME_PROMPT_PREFIX="|"
|
||||||
RVM_THEME_PROMPT_SUFFIX="|"
|
RVM_THEME_PROMPT_SUFFIX="|"
|
||||||
|
|
||||||
__bobby_clock() {
|
function __bobby_clock() {
|
||||||
printf '%s' "$(clock_prompt) "
|
printf '%s' "$(clock_prompt) "
|
||||||
|
|
||||||
if [ "${THEME_SHOW_CLOCK_CHAR}" == "true" ]; then
|
if [[ "${THEME_SHOW_CLOCK_CHAR:-}" == "true" ]]; then
|
||||||
printf '%s' "$(clock_char) "
|
printf '%s' "$(clock_char) "
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function prompt_command() {
|
function prompt_command() {
|
||||||
PS1="\n$(battery_char) $(__bobby_clock)"
|
PS1="\n$(battery_char) $(__bobby_clock)"
|
||||||
PS1+="${yellow}$(ruby_version_prompt) "
|
PS1+="${yellow?}$(ruby_version_prompt) "
|
||||||
PS1+="${purple}\h "
|
PS1+="${purple?}\h "
|
||||||
PS1+="${reset_color}in "
|
PS1+="${reset_color?}in "
|
||||||
PS1+="${green}\w\n"
|
PS1+="${green?}\w\n"
|
||||||
PS1+="${bold_cyan}$(scm_prompt_char_info) "
|
PS1+="${bold_cyan?}$(scm_prompt_char_info) "
|
||||||
PS1+="${green}→${reset_color} "
|
PS1+="${green?}→${reset_color?} "
|
||||||
}
|
}
|
||||||
|
|
||||||
THEME_SHOW_CLOCK_CHAR=${THEME_SHOW_CLOCK_CHAR:-"true"}
|
: "${THEME_SHOW_CLOCK_CHAR:="true"}"
|
||||||
THEME_CLOCK_CHAR_COLOR=${THEME_CLOCK_CHAR_COLOR:-"$red"}
|
: "${THEME_CLOCK_CHAR_COLOR:=${red?}}"
|
||||||
THEME_CLOCK_COLOR=${THEME_CLOCK_COLOR:-"$bold_cyan"}
|
: "${THEME_CLOCK_COLOR:=${bold_cyan?}}"
|
||||||
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%Y-%m-%d %H:%M:%S"}
|
: "${THEME_CLOCK_FORMAT:="%Y-%m-%d %H:%M:%S"}"
|
||||||
|
|
||||||
safe_append_prompt_command prompt_command
|
safe_append_prompt_command prompt_command
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,14 @@
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
# shellcheck disable=SC2034 # Expected behavior for themes.
|
# shellcheck disable=SC2034 # Expected behavior for themes.
|
||||||
# shellcheck disable=SC2154 #TODO: fix these all.
|
|
||||||
|
|
||||||
function prompt_command() {
|
function prompt_command() {
|
||||||
PS1="${green}\u@\h $(clock_prompt) ${reset_color}${white}\w${reset_color}$(scm_prompt_info)${blue} →${bold_blue} ${reset_color} ${normal}"
|
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=${THEME_CLOCK_COLOR:-"$blue"}
|
: "${THEME_CLOCK_COLOR:=${blue?}}"
|
||||||
THEME_CLOCK_FORMAT=${THEME_CLOCK_FORMAT:-"%I:%M:%S"}
|
: "${THEME_CLOCK_FORMAT:="%I:%M:%S"}"
|
||||||
|
|
||||||
safe_append_prompt_command prompt_command
|
safe_append_prompt_command prompt_command
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,22 @@
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
# shellcheck disable=SC2034 # Expected behavior for themes.
|
# shellcheck disable=SC2034 # Expected behavior for themes.
|
||||||
# shellcheck disable=SC2154 #TODO: fix these all.
|
|
||||||
|
|
||||||
SCM_THEME_PROMPT_PREFIX="${bold_green}[ ${normal}"
|
SCM_THEME_PROMPT_PREFIX="${bold_green?}[ ${normal?}"
|
||||||
SCM_THEME_PROMPT_SUFFIX="${bold_green} ] "
|
SCM_THEME_PROMPT_SUFFIX="${bold_green?} ] "
|
||||||
SCM_THEME_PROMPT_DIRTY=" ${red}✗"
|
SCM_THEME_PROMPT_DIRTY=" ${red?}✗"
|
||||||
SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓"
|
SCM_THEME_PROMPT_CLEAN=" ${bold_green?}✓"
|
||||||
|
|
||||||
prompt_command() {
|
function prompt_command() {
|
||||||
if [ "$(whoami)" = root ]; then
|
local scm_prompt_info
|
||||||
cursor_color="${bold_red}"
|
if [ "${USER:-${LOGNAME?}}" = root ]; then
|
||||||
user_color="${green}"
|
cursor_color="${bold_red?}"
|
||||||
|
user_color="${green?}"
|
||||||
else
|
else
|
||||||
cursor_color="${bold_green}"
|
cursor_color="${bold_green?}"
|
||||||
user_color="${white}"
|
user_color="${white?}"
|
||||||
fi
|
fi
|
||||||
PS1="${user_color}\u${normal}@${white}\h ${bold_black}\w\n${reset_color}$(scm_prompt_info)${cursor_color}❯ ${normal}"
|
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
|
safe_append_prompt_command prompt_command
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue