How do I get cd to switch to the full path when following symbolic links?

you should use cd with -P option to do that.

from man pange:

 -P     Handle the operand dot-dot physically; symbolic link components shall be resolved before dot-dot components
              are processed (see step 7. in the DESCRIPTION).

small test to show how does it work:

kent@ArchT60:/tmp$ ls -ld /opt/google/picasa/
drwxr-xr-x 3 root root 4096 Aug  5  2010 /opt/google/picasa/

kent@ArchT60:/tmp$ ln -s /opt/google/picasa/ cdLink
kent@ArchT60:/tmp$ ls -l cdLink
lrwxrwxrwx 1 kent kent 19 Nov 15 21:23 cdLink -> /opt/google/picasa/

kent@ArchT60:/tmp$ cd -P cdLink
kent@ArchT60:/opt/google/picasa$ pwd
/opt/google/picasa

kent@ArchT60:/opt/google/picasa$ cd /tmp/cdLink
kent@ArchT60:/tmp/cdLink$ 
kent@ArchT60:/tmp/cdLink$ cd -P ..
kent@ArchT60:/opt/google$ 

i think the example above showed what you are looking for.


I have never found a way to do it with symlinks, but if your goal is to quickly change between directories in shell, I wrote a blog post recently on several alternatives to accomplish exactly that.

The short answer is to use alias to add something similar to the following to your ~/.bashrc:

alias sf='cd ~/SmileForward/smileforward-backend/sfsite/smileforward'

Or export all the frequently used directories as variables into your ~/.bashrc, and just invoke directly with cd $dir_1 etc:

export dir_1='~/some_long_path_name/more_path_names1`
export dir_2='~/some_long_path_name/more_path_names2`

There's also a tool for switching directories based on frequency / recency called z that I never explored fully.