Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to extend Ctrl+R search in zsh? It cannot find entry despite it is in history file.

Edit: My .zshrc:

setopt AUTO_CD
# History
# Keys
autoload zkbd
[[ ! -d ~/.zkbd ]] && mkdir ~/.zkbd
[[ ! -f ~/.zkbd/$TERM-${DISPLAY:-$VENDOR-$OSTYPE} ]] && zkbd
source  ~/.zkbd/$TERM-${DISPLAY:-$VENDOR-$OSTYPE}
[[ -n ${key[Home]}    ]]  && bindkey  "${key[Home]}" beginning-of-line
[[ -n ${key[End]}     ]]  && bindkey  "${key[End]}"     end-of-line
[[ -n ${key[Insert]}  ]]  && bindkey  "${key[Insert]}"  overwrite-mode
[[ -n ${key[End]}     ]]  && bindkey  "${key[End]}"     end-of-line
[[ -n ${key[Insert]}  ]]  && bindkey  "${key[Insert]}"  overwrite-mode
[[ -n ${key[Delete]}  ]]  && bindkey  "${key[Delete]}"  delete-char
[[ -n ${key[Up]}      ]]  && bindkey  "${key[Up]}" up-line-or-history
[[ -n ${key[Down]}    ]]  && bindkey  "${key[Down]}" down-line-or-history
[[ -n ${key[Left]}    ]]  && bindkey  "${key[Left]}"    backward-char
[[ -n ${key[Right]}   ]]  && bindkey  "${key[Right]}"   forward-char
# Auto completion
autoload -U compinit promptinit
prompt clint
zstyle ':completion::complete:*' use-cache 1
autoload -U zsh-mime-setup
# Calc
autoload -U zcalc
# Editor
export EDITOR=vim
# Useful
alias background="schedtool -B -e"
alias lowprio="nice -n 20 ionice -c 3"
alias blowprio="ionice -c 3 schedtool -B -e nice -n 20"

cave resolve -c should find blowprio cave resolve -c world -C a -R w --resume-file resume-world which is in .zsh/history (at least grep says so) but it finds no match.

share|improve this question
How do you want to extend it? By default, it does search entries in the history. If it doesn't work for you, post a minimal .zshrc and .zsh_history and Ctrl+R search that doesn't work. – Gilles Sep 12 '10 at 20:55
I've edited post. – Maciej Piechotka Sep 12 '10 at 21:12
I used your .zshrc, created the history entry and afterwards it is found via <kbd>CTRL+R</kbd>. So this should work. My zsh version is 4.3.10. – echox Sep 12 '10 at 21:32
I use exact same version of zsh and I had repetidly. It takes some time (like day). – Maciej Piechotka Sep 12 '10 at 21:35
up vote 4 down vote accepted

You've set SAVEHIST=10000, but you left HISTSIZE at its default value of 30. That means any session will keep at most 30 entries in memory. Due to the append_history option, the history file can contain more history than kept into memory. If the entry you're searching for is not in memory, it won't be found.

Easy fix: set SAVEHIST to be larger. Most of the time SAVEHIST and HISTSIZE should be the same value.

If you're extremely short of memory, I suppose it would make sense to keep fewer entries in memory and to load them only when you search for them. But that sounds like a lot of coding effort for a rather small benefit (10000 entries would be something like a megabyte, which is large for a shell instance but not out of the question).

You would get better mileage out of your history entries with the hist_ignore_all_dups option (instead of hist_find_no_dups).

share|improve this answer

I don't think it is possible to "extend" this search.

In a default configuration Ctrl+R is mapped to a builtin function of the ZSH Line Edtior (zle): history-incremental-search-backward

See History Control in the ZSH Manpage.

It seems that there are no possibilities to "extend" this function.

What is the entry which is not found? Any examples?

share|improve this answer
I've edited post with command that is not found despite being in .zsh/history. – Maciej Piechotka Sep 12 '10 at 21:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.