fix annoying prompt flakyness master
authorIan Kelling <ian@iankelling.org>
Tue, 26 May 2026 22:36:59 +0000 (18:36 -0400)
committerIan Kelling <ian@iankelling.org>
Tue, 26 May 2026 22:36:59 +0000 (18:36 -0400)
.gitignore
brc

index f703ec9dbb056f482169110ef1e8040373586de3..bbc86a12142f9b8298e59b8d6d2380ccc4f8a711 100644 (file)
@@ -8,3 +8,4 @@
 # bash script for testing things
 /ms
 /ms2
+/subdir_files/.config/konsolerc
diff --git a/brc b/brc
index 1abad36f261acf523a872cbe0b95a5bd8251cf9f..e33ac4b48fa48624fc8867427401a2044367988b 100644 (file)
--- a/brc
+++ b/brc
@@ -4082,8 +4082,7 @@ if [[ $- == *i* ]]; then
   # so I've thrown a bunch of things at the wall to speed it up.
   prompt-command() {
     local return=$? # this MUST COME FIRST
-    local h
-    local jobs_char
+    local h jobs_char prtmp
 
     PS1='\w'
     if [[ $SSH_CLIENT ]]; then
@@ -4104,7 +4103,6 @@ if [[ $- == *i* ]]; then
 
     local ps_char ps_color col tmp h
 
-
     # note, I tried reading the current column here in order to add a
     # space if there was non-newline terminated output from the last
     # command. However, I found that it made ssh escape char not
@@ -4139,16 +4137,14 @@ if [[ $- == *i* ]]; then
             # history which won't actually get saved.
             if [[ $h != "$_sl_last_history" && $h =~ $cmd_regex  ]]; then
               _sl_last_history="$h"
-              ("${_sl_hist_cmd[@]}" <<<"$h" &)
+              ( "${_sl_hist_cmd[@]}" <<<"$h" &  )
             fi
           else
-            _sl_last_history="$(history 1)"
+            _sl_last_history="$(history 1 | sed -r 's/^ *([^ ]+ +){4}//')"
             _did_ssh_prompt1=t
           fi
         fi
       fi
-
-
       # if we aren't in ssh, maybe indicate history file
       if [[ ! $SSH_CLIENT ]]; then
         if [[ -e $HOME/.iank-stream-on ]]; then
@@ -4186,11 +4182,16 @@ if [[ $- == *i* ]]; then
     if [[ $MAIL_HOST && $MAIL_HOST != "$HOSTNAME" ]]; then
       ps_char="@ $ps_char"
     fi
-    if [[ $(jobs -p) ]]; then
-      jobs_char='j\j '
+    # trivia: without -r or -s, jobs will print jobs listed as Done
+    # (they dont exist as of a short time ago). And strangely, this will
+    # happen for jobs that bash never reported as existing before that,
+    # eg ( sleep 10 & ).
+    prtmp=$(jobs -s; jobs -r)
+    if (( ${#prtmp} != 0  )); then
+      #  printf "prtmp'%s'\n" "$prtmp" # # debug
+      jobs_char="j\j "
     fi
 
-
     # allow a function to specify a command to run after we run the next
     # command. Use case: a function makes a persistent notification. If
     # we happen to be using that terminal, we can just keep working by
@@ -4221,6 +4222,7 @@ if [[ $- == *i* ]]; then
     if [[ $(type -t ps-extra 2>/dev/null) == function ]]; then
       ps-extra
     fi
+
     PS1="$PS1 $jobs_char$psudo\[$ps_color\]$ps_char\[$term_nocolor\] "
 
     # copy of what is automatically added by guix.