Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: $history index in prompt_bart_precmd



I finally exceeded my $HISTSIZE in one window and noticed that my prompt
was no longer updating.  $history behaves as an assoc indexed on the
current history number, which means it gets leading empty elements as
things fall off the front -- but $#history reflects the actual number of
non-empty elements, e.g. it's never more than $HISTSIZE-1.

There is, however, some kind of bug with interpretation of the keys for
$history, because e.g. $history[3-1] == $history[3].  (It should yield
the empty string, as there isn't any hash table value for key "3-1".)

Index: Functions/Prompts/prompt_bart_setup
===================================================================
@@ -57,8 +57,8 @@
     setopt localoptions noxtrace extendedglob noksharrays
 
     # Using psvar here protects against unwanted promptsubst expansions.
-    psvar[8]="$history[$#history]"	# Use history text, not just number
-    psvar[9]=''				# Padding before upper right prompt
+    psvar[8]="$history[$[${(%):-%h}-1]]" # Use history text, not just number
+    psvar[9]=''				 # Padding before upper right prompt
 
     repeat $[COLUMNS-${#${(%%f)${PS1//[%]\{[^%]#%\}/}}[1]}-1]
     do

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



Messages sorted by: Reverse Date, Date, Thread, Author