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

Re: I broke my !$



Picking this up... Yes, I modified zsh_add_history hook; see
thediscussion under "zshaddhistory confusion".  So what I have now
isthis:
function zshaddhistory() { print -sr -- "${1%%$'\n'}" fc -p
~/.zsh_history_detail print -sr -- "${1%%$'\n'} ### ${PWD} $(date
'+%Y-%m-%d %R')" return 1}
which seems to support the "you need print -S" theory.  I have
4.3.12,but it doesn't have -S; is that something only on trunk right
now?  Istrunk stable enough for average daily use?
I'm on zsh 4.3.12.
On Wed, Oct 5, 2011 at 12:13 PM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Oct 5,  5:48pm, Julien Nicoulaud wrote:
> }
> } Same for me, messing with zsh_add_history hook breaks history expansion:
>
> Aha.
>
> } history_strip_passwords() {
> }   # Strip out -Dgpg.passphrase option value (Maven)
> }   print -sr "${${1%%$'\n'}//(#b)(gpg.passphrase=)*[:space:]/$match[1]}"
> }   fc -p
> } }
> } add-zsh-hook zshaddhistory history_strip_passwords
> }
> } With this hook, history exapnsions like "!$" or "!!" always return the whole
> } history line...
>
> You need to either remove the double quotes or use "print -S".  With the
> quotes and the lower-case -s you are making a history entry that has
> exactly one word consisting of the entire command.
>
>    -s
>          Place the results in the history list instead of on the
>          standard output.  Each argument to the print command is
>          treated as a single word in the history, regardless of its
>          content.
>
>    -S
>          Place the results in the history list instead of on the
>          standard output.  In this case only a single argument is
>          allowed; it will be split into words as if it were a full
>          shell command line.  The effect is similar to reading the
>          line from a history file with the HIST_LEX_WORDS option
>          active.
>
> It's possible that you have a version of zsh that has the history hook
> but not the -S option of print.  In that event you probably also have a
> buggy ${(z)...} so there's no immediate workaround that comes to mind.
> Something involving writing it to a different history file and then
> reading back with "fc -R" might work.
>



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