You are not logged in.

#1 2017-12-09 15:01:14

xtian
Member
Registered: 2013-08-25
Posts: 179

zsh history grep search not working as expected

I'm migrating to new system, and I'm using zsh instead of bash.
My settings are simple and I've added about what I had in bashrc.

I was looking thorough history to find the path to `intel_backlight`, which I worked on yesterday.

    - I type `$ history | grep tee`, and I get nothing.
    - I try `$ history | egrep 'tee'`, and I get my history search

But, I can arrow up to see the commands from yesterday.

    - If I just type `history`, then I get 16 lines of history, and this is all that a search looks through.

Here are my config files. They span `/etc` and `~/`.

# /etc/zsh/zshenv

HISTFILE=~/.histfile

# ~/.zshenv

HISTSIZE=10000
SAVEHIST=10000
setopt INC_APPEND_HISTORY
setopt hist_ignore_dups

Offline

#2 2017-12-24 20:28:50

chr0mag
Member
From: Vancouver, Canada
Registered: 2017-02-02
Posts: 94

Re: zsh history grep search not working as expected

The default behaviour of ZSH's built-in history command is different than that of BASH.  history in ZSH is actually an alias for fc -l or more precisely fc -l -16 -1, which shows the most recent 16 commands, as you've noticed. So to search farther back in your command history you could try:

fc -l -100 -1 | grep <pattern>

I use CTRL-R to invoke the reverse command search since by default this searches the complete command history.

More info at man fc or here: http://zsh.sourceforge.net/Doc/Release/ … mands.html

Offline

Board footer

Powered by FluxBB