go back in bash

I’ve been interested in making a way to go back through directories you were in before in a bash shell.

(You can already go back to the previous directory with cd -, but it only remembers the directory you were just in. You can also use pushd and popd, but that takes some extra work.)

A Google search confirmed that someone else (see comments) did it basically the same way I was thinking. Add the following to ~/.bashrc:
function cd {
    if [ -n "$1" ]; then pushd $1 > /dev/null
     else pushd $HOME > /dev/null
    fi
}
alias bd='popd > /dev/null'

After doing source ~/.bashrc, you can go back simply by tying bd. Now, I bet it would be fairly easy to implement a complementary fd:-)