From 3b0fcfa346f8114f9c82700cdac47d30d2964bc8 Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Sun, 19 Nov 2023 13:23:51 +0100 Subject: bashrc: include exit status in prompt --- bashrc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'bashrc') diff --git a/bashrc b/bashrc index 916ad2b..5c58c9e 100644 --- a/bashrc +++ b/bashrc @@ -49,6 +49,7 @@ esac # prompt __prompt_command() { + local exit_code=$? PS1='${TITLE}' local reset='\[\033[0m\]' @@ -81,6 +82,11 @@ __prompt_command() { PS1+=" [\j]" fi + # exit code + if [ $exit_code -gt 0 ]; then + PS1+=" <$red_b$exit_code$reset>" + fi + PS1+=" $red\$$reset > " } PROMPT_COMMAND=__prompt_command -- cgit v1.2.3