I'm working on a project that requires compilation for each test run. Every time I want to test it out again I press Up
to get the last command and Enter
to run it. The issue is that it fills my History up, so if I want to use a command from before I started a coding session, it's completely buryed in hundreds of the same exact command.
How can I run a command without it filling up my History?
And if there isn't a way to do that, is there some way to skip over repeats when going back in History?
I am not totally certain what shell I am using. I am running Terminal, on OSX. But I would like the answer for as many different shells as is known, because that would make this question more valuable for others later.
$ echo $0
-bash
EDIT: After a short discussion in comments and some additions to the original text of the question, better search results have appeared in the sidebar, showing this is a duplicate of How to stop Bash appending history. I'll be marking it as so and closing it.
bash
– EightBitTony Nov 14 '17 at 07:34echo $0
and do not put this stuff in comments. [edit] your question to improve it. – JdeBP Nov 14 '17 at 07:35.bash_history
. So, you can just type a space followed by!!
to rerun the previous command without an additional entry in the history. – m0dular Nov 15 '17 at 00:04!!
(that is "space bang bang") - space prevents adding to history and double bang repeats last command. – cprn Nov 06 '20 at 13:40