Skip to content

Tip #8: Einfache Suche in der History mit den Pfeiltasten

Jörg wartete gestern bei unserem Stammtisch mit einem netten Schnipsel auf:


autoload -U history-search-end                                                  
zle -N history-beginning-search-backward-end history-search-end                 
zle -N history-beginning-search-forward-end history-search-end                  
bindkey “\e[A”  history-beginning-search-backward-end                           
bindkey “\e[B”  history-beginning-search-forward-end

Dieser Fünfzeiler sorgt dafür, dass man mit den Pfeil-Hoch- und -Runter-Tasten die History durchsuchen kann. Beispiel:


$ ls
$ less abc
$ vim xyz
$ ssh example.org
$ man zsh
$ less foo

Dies sei ein Ausschnitt der History. Nun gibt man l und Pfeil nach oben ein. Beim ersten Druck erscheint less foo, beim zweiten less abc und beim dritten ls. Die Eingabe von le und der Pfeiltaste würde hier nur die less-Befehle erscheinen lassen.

Ich finde das recht nützlich und habe das gleich mit in meine .zshrc aufgenommen.

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

Tim Daniel on :

Mir fällt das jetzt erst ein, aber hatte Sven das nicht schon auf seinem zsh-Vortrag erwähnt? Ich meine mich dunkel da an etwas zu erinnern.

Jens Kubieziel on :

Oje, Sven hat soviel (interessantes) erzählt, dass ich mich nicht mehr an alles und speziell auch nicht an das erinnern kann.

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
BBCode format allowed
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.
Form options
cronjob