1
0
mirror of https://github.com/gryf/vmstrap.git synced 2025-12-18 20:10:28 +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=3
GIT_PICT="◆"
HG_PICT="☿"
PY_PICT="℗"
JS_PICT="ⓙ"
# various symbols, depending on used font in urxvt
echo $TERM | grep -qi rxvt
if [[ $? == 0 ]]; then
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.
function is_git_repository {
@@ -67,8 +82,7 @@ function set_git_branch {
git_status="$(git status 2> /dev/null)"
# Set color based on clean/staged/dirty.
pat="(directory|tree) clean$"
if [[ ${git_status} =~ $pat ]]; then
if [[ ${git_status} =~ "working tree clean" ]]; then
state="${GREEN}"
elif [[ ${git_status} =~ "Changes to be committed" ]]; then
state="${YELLOW}"
@@ -146,7 +160,7 @@ function set_subversion_branch {
# Return the prompt symbol to use, colorized based on the return value of the
# previous command.
function set_prompt_symbol () {
function set_prompt_symbol {
if test $1 -eq 0 ; then
PROMPT_SYMBOL="${BLUE}\$${COLOR_NONE}"
else
@@ -155,15 +169,15 @@ function set_prompt_symbol () {
}
# Determine active Python virtualenv details.
function set_virtualenv () {
function set_virtualenv {
if test -z "$VIRTUAL_ENV" ; then
PYTHON_VIRTUALENV=""
else
PYTHON_VIRTUALENV="${LIGHT_GREEN}[${PY_PICT} `basename \"$VIRTUAL_ENV\"`]${COLOR_NONE} "
PYTHON_VIRTUALENV="${CYAN}[${PY_PICT} `basename \"$VIRTUAL_ENV\"`]${COLOR_NONE} "
fi
}
function set_nodevirtenv () {
function set_nodevirtenv {
if test -z "$NODE_VIRTUAL_ENV" ; then
NODE_VIRTUALENV=""
else
@@ -216,7 +230,7 @@ function timer_stop {
}
# 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
# return value of the last command.
set_prompt_symbol $?