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

Re: is there a mix of history-search-backward and history-beginning-search-backward



On Sep 8,  3:02pm, Andy Spiegl wrote:
} Subject: Re: is there a mix of history-search-backward and history-beginni
}
} Hi again!

Hello ...

} A while ago I asked:
} > 
} > I want to bind to ^P a widget that acts like
} > history-beginning-search-backward, but always moves the cursor to the end
} > of the line, like history-search-backward does.  Or said the other way:
} > I want history-search-backward to look at more than the first word.
} > 
} > Do you know a way to get this behavior?
} 
} Does noone have any idea about this?

Everyone is probably waiting for everyone else to answer.  Now you'll
probably get this answer several times.

In 3.0.6, there really is no satisfactory way to get this behavior.  The
closest you can come is to use this kind of binding:

	bindkey '^Xp' history-beginning-search-backward
	bindkey -s '^P' '^X^X^Xp^E'

The first binding is just something to hang the real thing you want to
execute on, so that you can refer to it in the second binding.  The second
binding maps ctrl-P to the sequence exchange-point-and-mark (^X^X) followed
by history-beginning-search-backward (^Xp) followed by end-of-line (^E).
The problem is that you have to remember to set the mark with ctrl-space
(or whatever you have bound to set-mark-command) before you begin to press
ctrl-P repeatedly, or exchange-point-and-mark will jump to the wrong place:
zsh resets the mark each time a new prompt is displayed.

In 3.1.6, you can create a custom widget as I just saw that PWS has already
explained, so I won't repeat him.

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



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