From: Ian Kelling Date: Tue, 26 May 2026 22:36:59 +0000 (-0400) Subject: fix annoying prompt flakyness X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=distro-setup fix annoying prompt flakyness --- diff --git a/.gitignore b/.gitignore index f703ec9..bbc86a1 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ # bash script for testing things /ms /ms2 +/subdir_files/.config/konsolerc diff --git a/brc b/brc index 1abad36..e33ac4b 100644 --- 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.