Bash – Zsh: make the up arrow skip identical commands

bashcommand historyzsh

In most Unix shells, the arrow-up key replaces the command that is being edited by the previous command in the history.
The history can be seen using the command history.

can be pressed more than one time to climb up in the history.

My question is:

How can I configure my shell so that skips all commands identical to the current one?

Indeed I often enter many make in a row. When I want to enter again (or modify slightly) an older command I have to hit many times just to skip all the make commands.

I know that is far from being the only tip that increase shell productivity.

bonus:

  • give a configuration working for the Bash shell.
  • preserve the history (knowing that you typed a command many times in a row can be useful)

Best Answer

For zsh put this in your configuration:

setopt histignoredups

What it does, it will ignore duplicated history entries during search.

The equivalent setting for bash is

HISTCONTROL=$HISTCONTROL:ignoredups
Related Question