The Computer Oracle

Can you share wisdom on using HISTIGNORE in bash?

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Life in a Drop

--

Chapters
00:00 Can You Share Wisdom On Using Histignore In Bash?
00:36 Accepted Answer Score 40
01:14 Answer 2 Score 21
01:28 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*( )'