Show HN: Oh-heck, a terminal command for when you forget other terminal commands
I have a simpler solution. The use case is not precisely the same, but for many scenarios, it's effectively the same.<p>Simply, like many, I have bash set up to record commands in .bash_history. I have it flush all the time, so .bash_history is always current.<p><pre><code>  # keep persistent bash history across sessions
  export PROMPT_COMMAND='history -a;history -n'
  export HISTCONTROL=ignoredups
  shopt -s histappend
</code></pre>
Next, I have a simple cron job running every minute.<p><pre><code>  file=/tmp/work.$$
  cat ~/.bash_history ~/.unique_bash | grep -v findcmd | sort -u > $file
  mv $file ~/.unique_bash
</code></pre>
Then, I have a script called "findcmd" that simply greps my .unique_bash file.<p><pre><code>  for var in "$@"
  do
      cmd="| grep \"$var\" $cmd"
  done
  cmd="cat ~/.unique_bash $cmd"
  eval $cmd
</code></pre>
In the end, when I need to figure something out, I head to the internet. Those commands are then captured for posterity in the .unique_bash file. If I want to know how to post a JSON file to an endpoint using Curl, then<p><pre><code>  $ findcmd curl json
</code></pre>
And all those curl commands show up.<p>It won't let me do something I don't know, but it make my memory much, much longer.<p>And, yea, I admit there have been instances where I've completely forgotten the command, and had to head back to the web. But when I've done that, I can hit my history and see how I used it.<p>If, sometimes, a "bad command", a command done wrong, too many of the same thing, just lingers, I can go edit it out. But most of the time I don't bother.