Make Bash's PS1 show original directory name and not symlink?

On Linux, you can use the following:

export PS1='$( readlink -f . )'

Example:

$ export PS1='$( readlink -f . ) \$ '
/home/danielbeck $ ln -s /etc foo
/home/danielbeck $ cd foo
/etc $ _

Note that you still will be in /home/danielbeck/foo for everything else, like resolving parent directories with cd .., so, to continue the example:

/etc $ cd ..
/home/danielbeck $ _

Another option might be to replace cd with a function that enters the canonical directory instead of the symlink, something like:

function cd {
    if [[ $# -ne 1 ]] ; then
        builtin cd "$@"
    elif [[ "$1" = "-" ]] ; then
        builtin cd -
    else
        builtin cd "$( readlink -f "$1" )"
    fi
}

This might also work for any cd arguments and supports even CDPATH:

function cd {
    builtin cd "$@"
    builtin cd "$( readlink -f . )"
}