From 128dd8d6cb9f1e9ba240e78e8a0d243dcb4a079a Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Mon, 29 Apr 2019 10:04:09 +0300
Subject: [PATCH] Fix bug, now the exit status is shown only once after a
 failed command.

---
 .bashrc | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/.bashrc b/.bashrc
index fcd7bb5..785fa37 100644
--- a/.bashrc
+++ b/.bashrc
@@ -223,7 +223,8 @@ __prompt () {
         endtime="$(date +%s)"
         runduration="$(( endtime - starttime))"
         [ "$runduration" -lt '10' ] || PS1="\\[\\e[1;96m[Run duration: $runduration]\\e[0m\\] $PS1"
-        [ "$exitstatus" -eq '0' ] || PS1="\\[\\e[1;91m[Exit status: $exitstatus]\\e[0m\\] $PS1"
+        [ "$exitstatus" -eq '0' ] || [ -z "${run_command:-}" ] || PS1="\\[\\e[1;91m[Exit status: $exitstatus]\\e[0m\\] $PS1"
+        unset run_command
     fi
     last_command='__prompt'
     unset starttime
@@ -239,6 +240,10 @@ __command_notifier () {
         starttime="$(date +%s)"
     elif [ -n "${last_finish:-}" ]
     then
+        if [ "${last_command:-}" != '_direnv_hook' ]
+        then
+            run_command='1'
+        fi
         runduration="$(( endtime - last_finish ))"
         if [ "$runduration" -gt '10' ]
         then
-- 
GitLab