How to move up a level from an symbolic link in OSX

86 views Asked by At

I've created a symbolic link to my WordPress theme root from my system root - so in / I have

mytheme -> /Applications/MAMP/htdocs-wordpress/wp-content/themes/mytheme

I use this all the time to quickly get to my theme root in Terminal. But I very often also want to navigate from there up to a higher directory in the WordPress hierarchy, like wp-content. When I run cd .. Terminal takes me back up to /. Is there any easy way to jump up the file hierarchy instead of to the "parent" of the symbolic link? Or any way to get an alias of my theme root that will allow this?

1

There are 1 answers

0
jhoepken On BEST ANSWER

I would go with an alias, it makes things easier. Put this into your $HOME/.bashrc or $HOME/.bash_profile file:

alias mytheme="cd /Applications/MAMP/htdocs-wordpress/wp-content/themes/mytheme"

After that, either source it in your current terminal source $HOME/.bashrc or open a new Terminal window. This is available for any Terminal window you open and you can navigate easily from there. Another advantage is, that you don't have this symlink in your / directory.

Jumping into the directory of your theme is done by calling the name of the alias:

user@machine> mytheme

And if you want to navigate one directory back, just do it the usual way:

user@machine> cd ..
user@machine> pwd
/Applications/MAMP/htdocs-wordpress/wp-content/themes