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

Re: I broke my !$



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