Or in zsh:
setopt cdablevars
nm=/path/to/whatever
cd nm setopt cdablevars
nm=/path/to/whatever
cd nm touch ~/.zshmarks && source ~/.zshmarks
function b() {
echo "hash -d $1=\"`pwd`\"" >> ~/.zshmarks && source ~/.zshmarks
} shopt -s cdable_vars foo=/etc/
cd $foo