The truth is rarely pure and never simple

How to keep specific commands out of the bash history

As I use the same console for editing source code and commiting to svn, I accidently may issue a commit when using the bash history feature. In order to avoid this issue, I wanted to keep all svn commands from being recorded in the bash history. Add the following lines to your .bashrc and it is done:

hideworkaround() {
    "$@"; history -d $(($HISTCMD-1))
}
alias svn='hideworkaround svn'

The additional function is necessary as bash does not accept aliases with parameters. However, you will only need one workaround function, as the basic command is the first parameter of the alias. Happy hacking 😉

Leave a comment

Your email address will not be published.