This isn’t a brand new trick. It’s based on a Bash function for “alias last” that I’ve seen in a few places. The original version uses history
to get the last command you ran and turn it into a temporary alias. I expanded it a little with some escaping for quotes and trimming whitespace, but it’s the same function.
This is a companion discussion topic for the original entry at https://brettterpstra.com/2013/08/30/easily-save-that-wicked-awesome-shell-command