exclude saving commands in history

Hello.
How to exclude saving commands in history?
And duplicate commands that repeat.
shell csh.

In Linux me use:
shell bash.
Code:
HISTCONTROL=ignoredups
HISTIGNORE="date:pwd:id:uptime:resize:clear:history:df *:w:ifconfig:apt update:apt upgrade:exit:reboot:uname *🇲🇨"
So as not to pollute the command history in the shell.
 
How to exclude saving commands in history?
No such option is in the C shells. That's why programs like mc flood the history if you run it from a C shell.
And duplicate commands that repeat.
This does exist but only if invoked as tcsh(1) (it's an additional feature). But it's honestly quite annoying.

Code:
       histdup (+)
               Controls handling of duplicate entries in the history list.  If
               set to `all' only unique history events are entered in the
               history list.  If set to `prev' and the last history event is
               the same as the current command, then the current command is
               not entered in the history.  If set to `erase' and the same
               event is found in the history list, that old event gets erased
               and the current one gets inserted.  Note that the `prev' and
               `all' options renumber history events so there are no gaps.
 
It's sad, it could have been done.
It is convenient so that the history is not clogged with duplicates and unnecessary commands.
 
I do use history -S and history -L frequently. Muscle memory hits ctrl-alt-A (auto-type feature of Keepass) often, and it types my password on the command line. Which then ends up getting saved in the history and I have to fish it out :rolleyes:

Yes, it's the same executable. But it behaves differently if invoked as csh or tcsh. The additional "tcsh" features aren't available if invoked as csh.
 
I can’t find information about what these command combinations do?
history -S
and
history -L
 
I can’t find information about what these command combinations do?
They're shell builtins. They are explained in the csh(1) man page. Short, short version; history -S saves the history (to ~/.history for C shells), history -L loads the history (from ~/.history).

So, if you want to take something out of the history, you history -S save it, then edit ~/.history and load it again with history -L.
 
Not very efficient.
alias precmd "history -S /tmp/hist;awk '"'{t=$0;getline} /^(date|pwd|id)/ {next} {printf "%s\n%s\n",t,$0}'"' /tmp/hist>/tmp/hist1;history -L /tmp/hist1"
 
Isn't precmd executed before the command is added to the history? Or is the intention to remove the previously entered command from the history?
 
I switched from csh to zsh about 30 years ago. It does most everything csh does and a whole lot more. Is there a strong reason to use csh/tcsh?
 
They're shell builtins. They are explained in the csh(1) man page. Short, short version; history -S saves the history (to ~/.history for C shells), history -L loads the history (from ~/.history).

So, if you want to take something out of the history, you history -S save it, then edit ~/.history and load it again with history -L.
It's confusing.
 
Back
Top