There is a program called "thefuck" that you can install and it uses python to take the last command you ran and give you ...what you probably meant. It's a cool program.
I wanted to create a script that if I was pissed I could type "[swearword]" and it would call the last command with the head of the man page, some "ps" information and more that might be related.
I'm struggling to call anything from a current shell in a bash script.
Even when I use advice in multiple other answers ...
History command inside bash script
https://stackoverflow.com/questions/6109225/bash-echoing-the-last-command-run
They call the last command from the last shell. It seems bash only saves to ".bash_history" on exit. There is a way around this, but involves clearing and re-loading the history and I don't want that just to frustratedly type "[swear word]".
For example of my issues: when I run the script based on the above, I do get the "last" command... number 497. But, I'm on #901 in my current shell.
Any ideas?