Colors, fix status

This commit is contained in:
Meutel 2017-05-01 17:51:55 +02:00
parent 69c474427d
commit a8c1d21d6e

53
_bashrc
View File

@ -2,7 +2,6 @@
[ -z "$PS1" ] && return [ -z "$PS1" ] && return
##### VARIABLES ##### ##### VARIABLES #####
# don't put duplicate lines in the history. See bash(1) for more options # don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups export HISTCONTROL=ignoredups
# ... and ignore same sucessive entries. # ... and ignore same sucessive entries.
@ -29,12 +28,18 @@ if [ "$TERM" != "dumb" ]; then
[ -x /usr/bin/dircolors ] && eval "`dircolors -b`" [ -x /usr/bin/dircolors ] && eval "`dircolors -b`"
fi fi
GREEN='\[\033[0;32m\]'
GREENB='\[\033[1;32m\]'
RED='\[\033[0;31m\]' RED='\[\033[0;31m\]'
REDB='\[\033[1;31m\]' REDB='\[\033[1;31m\]'
GREEN='\[\033[0;32m\]'
GREENB='\[\033[1;32m\]'
YELLOW='\[\033[0;33m\]'
YELLOWB='\[\033[1;33m\]'
BLUE='\033[0;34m\]' BLUE='\033[0;34m\]'
BLUEB='\033[1;34m\]' BLUEB='\033[1;34m\]'
PURPLE='\[\033[0;35m\]'
PURPLEB='\[\033[1;35m\]'
CYAN='\[\033[0;36m\]'
CYANB='\[\033[1;36m\]'
WHITE='\[\033[0;37m\]' WHITE='\[\033[0;37m\]'
WHITEB='\[\033[1;37m\]' WHITEB='\[\033[1;37m\]'
RESET='\[\033[0;00m\]' RESET='\[\033[0;00m\]'
@ -84,15 +89,15 @@ fi
export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock
##### PROMPT ##### ##### PROMPT #####
# status indicator
prompt_status() prompt_status()
{ {
if [[ "$?" == "0" ]] if [[ "$exitStatus" == "0" ]]
then then
echo -n "${GREENB}-" echo -n $GREENB
echo -en '\xE2\x9a\x90'
else else
echo -n "${REDB}X" echo -n $REDB
echo -en '\xE2\x9a\x91'
fi fi
} }
prompt_root() prompt_root()
@ -106,23 +111,33 @@ prompt_root()
} }
prompt_remote() prompt_remote()
{ {
if [ -n "$SSH_CLIENT" ] if [[ -n "$SSH_CLIENT" ]]
then then
echo -n "${REDB}>>" echo -n "${RED}"
else else
echo -n "${GREENB}))" echo -n "${GREEN}"
fi fi
} }
__ps1pre()
{
export exitStatus=$?
echo -n "${WHITEB}(${WHITE}\u@$(prompt_remote)\h${WHITEB}) ${BLUEB}\w${RESET}"
}
__ps1post()
{
echo -n "\n$(prompt_status) $(prompt_root)${RESET} "
}
__ps1() __ps1()
{ {
ps1pre="$1" exitStatus=$?
ps1post="$2" PS1="$(__ps1pre)$(__ps1post)"
PS1="$ps1pre$ps1post"
} }
PS1pre='"$(prompt_remote) ${WHITEB}(${WHITE}\u@${GREEN}\h${WHITEB}) ${BLUEB}\w${RESET}"' __ps1_git()
PS1post='"\n$(prompt_status)$(prompt_root)${RESET} "' {
PROMPT_COMMAND="__ps1 $PS1pre $PS1post" exitStatus=$?
__git_ps1 "$(__ps1pre)" "$(__ps1post)"
}
PROMPT_COMMAND='__ps1'
##### GIT ##### ##### GIT #####
@ -141,6 +156,6 @@ if [ -e /usr/local/share/git-core/contrib/completion/git-prompt.sh ] || [ -e /us
export GIT_PS1_SHOWUNTRACKEDFILES=1 export GIT_PS1_SHOWUNTRACKEDFILES=1
export GIT_PS1_SHOWUPSTREAM="auto" export GIT_PS1_SHOWUPSTREAM="auto"
export GIT_PS1_SHOWCOLORHINTS=1 export GIT_PS1_SHOWCOLORHINTS=1
PROMPT_COMMAND="__git_ps1 $PS1pre $PS1post" PROMPT_COMMAND='__ps1_git'
fi fi