This commit is contained in:
tavo 2024-12-18 20:51:49 -06:00
parent a4f3d48618
commit 1512f3b23f

View file

@ -36,32 +36,36 @@ PATH="$HOME/.local/bin${PATH:+:${PATH}}"
PATH="$HOME/.local/state/nix/profile/bin${PATH:+:${PATH}}"
PATH="$HOME/.config/emacs/bin${PATH:+:${PATH}}"
git_branch() {
GIT_BRANCH="$(git branch 2>/dev/null | sed '/\*/!d;s/^\*\s*//g;s/\s*$//g')"
[ -n "$GIT_BRANCH" ] && printf "%s " "$GIT_BRANCH" || true
format_workdir() {
CODE="$?"
ROOT_DIR="$(git rev-parse --show-toplevel 2>/dev/null)"
[ -n "$ROOT_DIR" ] &&
ROOT_DIR="${ROOT_DIR##*/}" &&
printf '\033[34m%s\033[0m ' "$ROOT_DIR"
return "$CODE"
}
format_code() {
if [ "${1}" != 0 ] ; then
CODE="${1}"
printf '%s ' "${CODE}"
format_git_branch() {
CODE="$?"
GIT_BRANCH="$(git branch 2>/dev/null | sed '/\*/!d;s/^\*\s*//g;s/\s*$//g')"
[ -n "$GIT_BRANCH" ] && printf "\033[1m\033[35m%s\033[0m " "$GIT_BRANCH"
return "$CODE"
}
format_prompt() {
CODE="${1}"
if [ "${CODE}" != 0 ] ; then
printf '\033[31m\033[1m>\033[0m '
else
printf '\033[32m>\033[0m '
fi
}
[ -e "/data/data/com.termux" ] && HOSTNAME=" "
[ "${HOSTNAME:=$(hostname -s)}" = "laptop" ] && HOSTNAME="󰌢 "
[ "${HOSTNAME:=$(hostname -s)}" = "home" ] && HOSTNAME="󰒋 "
[ "${HOSTNAME:=$(hostname -s)}" = "desktop" ] && HOSTNAME="󰇅"
PROMPT_COMMAND="echo"
PS1='\[\033[31m\]\[\033[1m\]$(format_code ${?})\[\033[0m\]\
\[\033[2m\][\[\033[0m\] \
\[\033[36m\]${HOSTNAME}\[\033[0m\] \
\[\033[34m\]\W \
\[\033[1m\]\[\033[35m\]$(git_branch)\[\033[0m\]\
\[\033[2m\]] \[\033[0m\]\
\[\033[2m\]\@\[\033[0m\]\
\n\[\033[2m\]$\[\033[0m\] '
PS1='\[\033[2m\]\A\[\033[0m\] \
$(format_workdir ${?})\
$(format_git_branch ${?})\
$(format_prompt ${?})\
'
alias wget="wget --hsts-file=$XDG_DATA_HOME/wget/wget-hsts"