From 39894df7d3a85cff2e09dbacb68838dbb491d79c Mon Sep 17 00:00:00 2001 From: Meutel Date: Mon, 1 May 2017 12:51:38 +0200 Subject: [PATCH] Variables color, prompt --- _bashrc | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/_bashrc b/_bashrc index 070ac8d..fd1b4a9 100644 --- a/_bashrc +++ b/_bashrc @@ -29,6 +29,16 @@ if [ "$TERM" != "dumb" ]; then [ -x /usr/bin/dircolors ] && eval "`dircolors -b`" fi +GREEN='\[\033[0;32m\]' +GREENB='\[\033[1;32m\]' +RED='\[\033[0;31m\]' +REDB='\[\033[1;31m\]' +BLUE='\033[0;34m\]' +BLUEB='\033[1;34m\]' +WHITE='\[\033[0;37m\]' +WHITEB='\[\033[1;37m\]' +RESET='\[\033[0;00m\]' + ##### FUNCTIONS ##### # status indicator @@ -36,11 +46,10 @@ prompt_status() { if [[ "$?" == "0" ]] then - echo -n '\[\033[1;32m\]>' + echo -n "${GREENB}-" else - echo -n '\[\033[1;31m\]X' + echo -n "${REDB}X" fi - echo -n '\[\033[1;31m\]' } ##### INCLUDES ##### @@ -89,9 +98,15 @@ export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock ##### PROMPT ##### -PS1_pre="\[\033[1;31m\]>> \[\033[01;37m\](\[\033[0;37m\]\u@\[\033[0;32m\]\h\[\033[01;37m\]) \[\033[01;34m\]\w\[\033[00m\]" -PS1_post="\[\033[1;31m\]$(prompt_status)>\[\033[0;37m\] " -PS1="${PS1_pre}\n${PS1_post}" +__ps1() +{ + ps1pre="$1" + ps1post="$2" + PS1="$ps1pre$ps1post" +} +PS1pre='"${REDB}>> ${WHITEB}(${WHITE}\u@${GREEN}\h${WHITEB}) ${BLUEB}\w${RESET}"' +PS1post='"\n$(prompt_status)${REDB}>${WHITE} "' +PROMPT_COMMAND="__ps1 $PS1pre $PS1post" ##### GIT ##### @@ -110,6 +125,6 @@ if [ -e /usr/local/share/git-core/contrib/completion/git-prompt.sh ] || [ -e /us export GIT_PS1_SHOWUNTRACKEDFILES=1 export GIT_PS1_SHOWUPSTREAM="auto" export GIT_PS1_SHOWCOLORHINTS=1 - export PROMPT_COMMAND='__git_ps1 "$PS1_pre" "\n$PS1_post"' + PROMPT_COMMAND="__git_ps1 $PS1pre $PS1post" fi