From fc2d7aa9524db4d5f85a5bd98f4bebced8017012 Mon Sep 17 00:00:00 2001 From: Meutel Date: Mon, 1 May 2017 10:37:29 +0200 Subject: [PATCH] Status indicator in prompt --- _bashrc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/_bashrc b/_bashrc index 37ddde6..f3ccf0b 100644 --- a/_bashrc +++ b/_bashrc @@ -35,10 +35,18 @@ xterm-color) ;; esac -# Comment in the above and uncomment this below for a color prompt -#PS1='${debian_chroot:+($debian_chroot)}\[\033[0;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w\[\033[00m\]\n\$ ' +prompt_status() +{ + if [[ "$?" == "0" ]] + then + echo -n '\[\033[1;32m\]>' + else + echo -n '\[\033[1;31m\]X' + fi + echo -n '\[\033[1;31m\]' +} # Prompt -PS1="\[\033[1;31m\]>> \[\033[01;37m\](\[\033[0;37m\]\u@\[\033[0;32m\]\h\[\033[01;37m\]) \[\033[01;34m\]\w\[\033[00m\]\n\[\033[1;31m\]>>\[\033[0;37m\] " +PS1="\[\033[1;31m\]>> \[\033[01;37m\](\[\033[0;37m\]\u@\[\033[0;32m\]\h\[\033[01;37m\]) \[\033[01;34m\]\w\[\033[00m\]\n\[\033[1;31m\]$(prompt_status)>\[\033[0;37m\] " # If this is an xterm set the title to user@host:dir case "$TERM" in @@ -119,7 +127,7 @@ 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 "\[\033[1;31m\]>> \[\033[01;37m\](\[\033[0;37m\]\u@\[\033[0;32m\]\h\[\033[01;37m\]) \[\033[01;34m\]\w\[\033[00m\]" "\n\[\033[1;31m\]>>\[\033[0;37m\] "' + export PROMPT_COMMAND='__git_ps1 "\[\033[1;31m\]>> \[\033[01;37m\](\[\033[0;37m\]\u@\[\033[0;32m\]\h\[\033[01;37m\]) \[\033[01;34m\]\w\[\033[00m\]" "\n\[\033[1;31m\]$(prompt_status)>\[\033[0;37m\] "' fi # Tmux + ssh agent forwarding