ZSH Shell history not working

I recently switched from bash to zshell but my history does not seem to be working. When I press the up arrow I don't get the previous commands. Is the shortcut different?

Also how do I enable shared history through tabs and new windows? I am on Lion, and using the standard Terminal


Solution 1:

Up arrow should work, you can check what the shortcut is with this command:

bindkey | grep up-line

Depending on what your up-arrow sends to the terminal you might need to adjust it, use Ctrl-vUp to check. Use:

bindkey "KEYS" up-line-or-history

or

bindkey "KEYS" up-line-or-search

to fix it.

Shared history is enabled with:

setopt share_history

There may be some other options you want to set to avoid duplicates etc., see zshoptions(1).

Here's what I use:

setopt hist_expire_dups_first
setopt hist_find_no_dups
setopt hist_ignore_all_dups
setopt hist_ignore_dups
setopt hist_ignore_space
setopt hist_no_store
setopt hist_reduce_blanks
setopt hist_save_no_dups
setopt hist_verify
setopt inc_append_history
setopt no_hist_allow_clobber
setopt no_hist_beep
setopt share_history

They've been added incrementally, so some of them might be redundant.