0

Imagine that I enter these commands in Konsole (Manjaro KDE terminal):

python3 script.py
clear
clear

Normally when I hit arrow UP key, I am able to scroll through recent commands: If I hit arrow UP key three times I should have these commands

clear
clear
python3 script.py

Is there a way to avoid having similar commands when hitting arrow UP key?
What I want here is to have

clear
python3 script.py
ctrl-alt-delor
  • 27,473
  • 9
  • 58
  • 102
  • FYI, this is a function of your shell (`bash`), not a function of the terminal (`konsole`). – Stewart Nov 29 '20 at 16:19
  • If you are using `bash` (in the terminal), then yes. Look up `history`. There is an option to remove adjacent duplicates. – ctrl-alt-delor Nov 29 '20 at 17:30
  • 1
    Does this answer your question? [How can I remove duplicates in my .bash\_history, preserving order?](https://unix.stackexchange.com/questions/48713/how-can-i-remove-duplicates-in-my-bash-history-preserving-order) The first answer is to clean the existing history file, the second to configure history to ignore duplicates. – thanasisp Nov 29 '20 at 17:46

1 Answers1

0

Add the following to your ~/.bashrc if you're using bash:

export HISTCONTROL=ignoreboth:erasedups

If you're using zsh, you can try this in your ~/.zshrc(untested):

setopt HIST_IGNORE_DUPS
Bobbbay
  • 401
  • 3
  • 16