All I want to do is open my terminal and type cd htdocs so that I can work from there.
A simpler approach is probably to ignore the links and add the parent directory of your htdocs directory to the htdocs environment CDPATH . bash(1) checks the contents of the CDPATH environment CDPATH when entering cd foo to find the foo directory in one of the directories listed. This will work no matter what your current working directory is, and it will be easier than setting up symbolic links.
If the path to your htdocs is located /srv/www/htdocs/ , you can use CDPATH=/srv/www . Then cd foo will first look for /srv/www/foo/ and change it if it exists; if not, then it will look for foo in the current working directory and change it if it exists. (This can be confusing if your system has several htdocs directories, in which case CDPATH=.:/srv/www will allow you to easily go to the child directory, but use the /srv/www/htdocs/ version if there is no directory ./htdocs .)
You can add the line CDPATH=/srv/www to your ~/.bashrc so that it works every time you start the terminal.
sarnold Oct 16 2018-11-11T00: 00Z
source share