1
0
mirror of https://github.com/gryf/vmstrap.git synced 2025-12-19 12:28:21 +01:00

Synchronize bash prompt with local one.

This commit is contained in:
2020-11-18 14:17:37 +01:00
parent de5c677da5
commit e3144d0ae6

View File

@@ -36,10 +36,25 @@ LIGHT_GREEN="\[\033[1;32m\]"
# THRESHOLD is expressed in seconds. # THRESHOLD is expressed in seconds.
THRESHOLD=3 THRESHOLD=3
GIT_PICT="◆" # various symbols, depending on used font in urxvt
HG_PICT="☿" echo $TERM | grep -qi rxvt
PY_PICT="℗" if [[ $? == 0 ]]; then
JS_PICT="ⓙ" grep -i 'urxvt.font:' ~/.Xdefaults | grep -qi misc-fixed
if [[ $? == 0 ]]; then
GIT_PICT="◆"
HG_PICT="☿"
PY_PICT="℗"
JS_PICT="ⓙ"
fi
fi
if [[ -z $GIT_PICT ]]; then
GIT_PICT=""
HG_PICT=""
PY_PICT=""
JS_PICT=""
fi
# Detect whether the current directory is a git repository. # Detect whether the current directory is a git repository.
function is_git_repository { function is_git_repository {
@@ -67,8 +82,7 @@ function set_git_branch {
git_status="$(git status 2> /dev/null)" git_status="$(git status 2> /dev/null)"
# Set color based on clean/staged/dirty. # Set color based on clean/staged/dirty.
pat="(directory|tree) clean$" if [[ ${git_status} =~ "working tree clean" ]]; then
if [[ ${git_status} =~ $pat ]]; then
state="${GREEN}" state="${GREEN}"
elif [[ ${git_status} =~ "Changes to be committed" ]]; then elif [[ ${git_status} =~ "Changes to be committed" ]]; then
state="${YELLOW}" state="${YELLOW}"
@@ -146,7 +160,7 @@ function set_subversion_branch {
# Return the prompt symbol to use, colorized based on the return value of the # Return the prompt symbol to use, colorized based on the return value of the
# previous command. # previous command.
function set_prompt_symbol () { function set_prompt_symbol {
if test $1 -eq 0 ; then if test $1 -eq 0 ; then
PROMPT_SYMBOL="${BLUE}\$${COLOR_NONE}" PROMPT_SYMBOL="${BLUE}\$${COLOR_NONE}"
else else
@@ -155,15 +169,15 @@ function set_prompt_symbol () {
} }
# Determine active Python virtualenv details. # Determine active Python virtualenv details.
function set_virtualenv () { function set_virtualenv {
if test -z "$VIRTUAL_ENV" ; then if test -z "$VIRTUAL_ENV" ; then
PYTHON_VIRTUALENV="" PYTHON_VIRTUALENV=""
else else
PYTHON_VIRTUALENV="${LIGHT_GREEN}[${PY_PICT} `basename \"$VIRTUAL_ENV\"`]${COLOR_NONE} " PYTHON_VIRTUALENV="${CYAN}[${PY_PICT} `basename \"$VIRTUAL_ENV\"`]${COLOR_NONE} "
fi fi
} }
function set_nodevirtenv () { function set_nodevirtenv {
if test -z "$NODE_VIRTUAL_ENV" ; then if test -z "$NODE_VIRTUAL_ENV" ; then
NODE_VIRTUALENV="" NODE_VIRTUALENV=""
else else
@@ -216,7 +230,7 @@ function timer_stop {
} }
# Set the full bash prompt. # Set the full bash prompt.
function set_bash_prompt () { function set_bash_prompt {
# Set the PROMPT_SYMBOL variable. We do this first so we don't lose the # Set the PROMPT_SYMBOL variable. We do this first so we don't lose the
# return value of the last command. # return value of the last command.
set_prompt_symbol $? set_prompt_symbol $?