What would be the correct pattern for ignoring commands such as:
history 10
history 104
history .. #whatever may be the number here
I tried:
HISTIGNORE='history\s+\d*'
but that doesn't work.
The value of HISTIGNORE is a list of shell patterns. Not a list of regular expressions. As such the regular expressions will not work.
This pattern 'history *[0-9]*' should do what is needed here.
Edit: Pulling in added information from the comments.
To also ignore history by itself the simplest solution is to just add history to the value of HISTIGNORE.
But, when extglob is enabled (and assuming HISTIGNORE honors it) this pattern should cover that as well:
'history?( *[0-9]*)'
'history?( \*[0-9]*) to match history too I think. But that's not exactly a satisfactory answer.
Aug 27, 2014 at 13:30
! is triggered a little bit by disabling !( as a context for history expansion). But you could just add history to HISTIGNORE also.
Aug 27, 2014 at 13:38
! in a !( pair from being considered for expansion I believe. The man page talks about it briefly. "Several characters inhibit history expansion if found immediately following the history expansion character, even if it is unquoted: space, tab, newline, carriage return, and =. If the extglob shell option is enabled, ( will also inhibit expansion."
Aug 27, 2014 at 13:44
!! and !$ I would turn it off entirely.
Aug 27, 2014 at 13:44
*code*. The correct pattern should be 'history?( *[0-9]*)'.
Aug 27, 2014 at 13:48
To have multiple patterns you can separate them with a :
Like this:
HISTIGNORE="&:exit:pwd:rm *:history *:[ \t]*"
HISTIGNORE='history [0-9]*'might work.history 20got recorded?historyonly by itself is being remembered. :) Why is that, when spaces and digits are 0 or more?