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

Re: search through alternative HISTFILE



Dear Peter,

Thank you very much for your answer. Your use case is indeed similar, if slightly more complex. I had hoped I could reuse the existing history-incremental-search-backward widget, only changing the history before calling it. The relevant command (which you also use in your widget) seems to be "fc -p <NEWHISTFILE>". As I understand it, this pushes the current history and replaces it with a new history, read from <NEWHISTFILE>. This approach actually works when I use the fc -p command on the command line before hitting Ctrl-R, but when I wrap it in a widget it does not work:

# Define shell function to be used as widget:

function accumulated-history-incremental-search-backward () {
    fc -p "${HOME}/.accumulated-history"
    zle .history-incremental-search-backward
}

# Tell zsh to use the function as a widget:

zle -N accumulated-history-incremental-search-backward

# Bind Ctrl-i to the widget:

bindkey "^I" accumulated-history-incremental-search-backward

Is there any particular reason why calling fc -p inside the widget does not affect the history search?

Maarten



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