From 477a1e8bcb9ffa2abef90c794f9d4609ea378a44 Mon Sep 17 00:00:00 2001 From: "flyingscorpio@arch-desktop" Date: Sun, 21 Jun 2020 16:20:33 +0200 Subject: [PATCH] Change normal prompt --- dotfiles/bash/bashrc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/dotfiles/bash/bashrc b/dotfiles/bash/bashrc index 16d24f8..155d581 100644 --- a/dotfiles/bash/bashrc +++ b/dotfiles/bash/bashrc @@ -17,6 +17,30 @@ export LESS_TERMCAP_so=$'\e[01;33m' export LESS_TERMCAP_ue=$'\e[0m' export LESS_TERMCAP_us=$'\e[1;4;31m' +# enable exit status in prompt command +PROMPT_COMMAND=__prompt_command + +__prompt_command() { + local EXIT="$?" + PS1="" + + local RCol='\[\e[0m\]' + + local Red='\[\e[0;31m\]' + local Gre='\[\e[0;32m\]' + local BYel='\[\e[1;33m\]' + local BBlu='\[\e[1;34m\]' + local Pur='\[\e[0;35m\]' + + if [ $EXIT != 0 ]; then + PS1+="${Red}\u${RCol}" + else + PS1+="${Gre}\u${RCol}" + fi + + PS1+="${RCol}@${BBlu}\h${RCol}:${Pur}\w${RCol}$ ${RCol}" +} + # Enable bash-git-prompt if [ -f "$HOME/.bash-git-prompt/gitprompt.sh" ]; then GIT_PROMPT_ONLY_IN_REPO=1