The Computer Oracle

Can you share wisdom on using HISTIGNORE in bash?

-------------------------------------------------------------------------------
Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn
-------------------------------------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Music Box Puzzles

--

Chapters
00:00 Question
00:46 Accepted answer (Score 38)
01:35 Answer 2 (Score 21)
01:57 Thank you

--

Full question
https://superuser.com/questions/232885/c...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#bash #terminal

#avk47



ACCEPTED ANSWER

Score 40


I ignore ls without commands, bg, fg, exit, pwd, clear, mount and umount:

If you include this in your HISTIGNORE string you can suppress anything as you wish by adding a space at the front of the command:

"[ \t]*" 

This is my HISTIGNORE:

HISTIGNORE="&:ls:[bf]g:exit:pwd:clear:mount:umount:[ \t]*"

I've excluded some other stuff that I have in there that are repetitive commands that are unique to my server. Anything you do that is simple is a good thing to exclude.

I have other stuff which I have forgotten to add but I'm miles away from my Linux box so I am going off of memory.




ANSWER 2

Score 21


Don't save trivial one and two character commands on the history list:

HISTIGNORE='?:??'

If the extglob option is enabled, you can also use extended patterns, e.g.

HISTIGNORE='a*( )'