Sometimes I misunderstand the syntax of a command:# mysql -d testmysql: unknown option '-d'# echo $?2I try again and get it right:# mysql --database testWelcome to the MySQL monitor.mysql >...How do I prevent the first command, with error code different than 0, to enter the history?
Keep only successful commands in BASH history
bash;command history
I don't think you really want that. My usual workflow goes like this:Type a commandRun itNotice it failingPress UP keyEdit the commandRun it againNow, if the failed command weren't saved into history I couldn't get it easily back to fix and run again.