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
3
  • 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. Nov 29 '20 at 17:30
  • 1
    Does this answer your question? 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
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.