1

History Search Ctrl+R in my zsh cancels if I enter the dot . character.

If I hit Ctrl+R the bck-i-search: prompt appears and the history is searched according to the words I enter. But as soon as I type ., the search is canceled, the last found result is shown in the prompt and a . appeared at the cursor position.

foo@bar ~ vi footnote.txt
bck-i-search: foo

And as soon as I enter the . character this is the result:

foo@bar ~ vi .footnote.txt

Is it possible to allow the dot character to be part of the search string?

I am using zsh with "oh-my-zsh".

Edit:

After going line-for-line through my .zshrc I detected the reason for this behaviour:

## Quick ../../..
rationalise-dot() {
    if [[ $LBUFFER = *.. ]]; then
        LBUFFER+=/..
    else
        LBUFFER+=.
    fi
}
zle -N rationalise-dot
bindkey . rationalise-dot

This function is used to automatically change a series of ... into ../...

I would like to keep this feature but still allowing the . in search strings.

1
  • I did this and the problem persisted. But then I removed line for line from my .zshrc, until I closed in on the perpetrator. I updated the question detailing the result.
    – leviathan
    Commented Mar 10, 2018 at 10:28

1 Answer 1

3

By default, . is an ordinary character. If it behaves this way for you, it's because of something in your configuration, possibly something buried inside oh-my-zsh.

A binding in the main keymap overrides the behavior of the character even during incremental search. To restore the character's ordinary behavior during incremental search, you need to bind it to self-insert explicitly.

bindkey -M isearch . self-insert

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .