On Fri, 02 Aug 2013 12:38:43 +0200 Maarten Grachten wrote: > As part of an attempt to archive my command line history, I have a need > for bck-i-search (as normally invoked by Ctrl-R), but with a history > file that is not $HISTFILE, that is, a different file from that which > the current shell uses for saving its history. > > As I envision it, Ctrl-R would still search through the current shell's > history (i.e. through $HISTFILE), and another key binding would search > through an alternative but constant histfile (say > $HOME/.accumulated-history). > > Is this possible, and if so, can any of you give me a hint as to how to > achieve it? It's not quite what you want but it might provide a start since the bits underneath are pretty similar... I've attached a ZLE widget I've been using for a few years that I never quite made neat enough to post. It uses the history-beginning-search-backward interface rather than the isearch interface, but that shouldn't be too hard to change. The idea is it can search backwards both through the main history and a local history file with the name defined by a style; as an optional extra it decides by means of what's on the command line so far whether to search the local history. Your use is actually slightly simpler. For good measure, I've also attached a hook function for use with the zshaddhistory hook that decides whether to save a command locally (again, this is more than you actually asked for but might be useful). pws