If I'm typing a bunch of unix command line stuff trying to figure out the right solution, and I eventually DO figure out the solution, one thing I do when possible is re-run the command with a comment like
$ doing-the-thing.sh # This is the one that actually works
So when I inevitably search my shell command history later, I have nice little notes