1

By using the arrow keys one can fill the command line with the last called commands. However, Bash does call all the previous commands, not just unique commands.

$./a.out       //oldest command called
$ gcc main.c
$ gcc main.c
$ gcc main.c   //latest command called
$              //4 strokes required to call ./a.out, altough 2 would be sufficient

Is there a way to ignore past commands in the history list if they are identical and automatically call/fill in the next unique command in history?

Thank you!

1 Answer 1

3

Yes, there is. You can control how commands are saved in the history with the shell variable HISTCONTROL, all you have to do is put the line

HISTCONTROL=erasedups

in your .bashrc. (I prefer erasedups over ignoredups, as it places the last command I typed always on top of the history. This way I don't have to look when I want to repeat the last command I typed.)

1
  • Thank you, exactly what I was looking for and works like a charm! Commented Jan 7, 2015 at 12:46

You must log in to answer this question.

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