Macos – How to create a terminal shortcut to this path

.bash-profilemacosshortcutsterminal

So I'm having a problem creating a shortcut to a deep folder. None of the examples I've seen on Superuser have helped 🙁

This is my path: cd / Applications / MAMP / htdocs / whoat / solr / whoat

I would like to create the shortcut solr to reach that directory

I have to use cd / to get into my computer from the desktop, because I can't navigate into my Applications folder otherwise.


UPDATE

I was able to get into my .bash_profile via VIM

sudo vi ~/.bash_profile

This is what I currently have inside of it, I added the last 3 lines, however none of the shortcuts work:

export PATH="/usr/local/bin:$PATH:/usr/local/share/python"
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/mysql/lib"
alias sublime="/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl"
alias edit="/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl"
alias solr="/Applications/MAMP/htdocs/website/WhoAt/solr/whoat/"

When I type solr enter, or sublime enter, nothing happens

Best Answer

Here is defined an alias solr which will cd to the named directory-:

alias solr='cd /Applications/MAMP/htdocs/whoat/solr/whoat'

Note the use of single quotes - double quotes will cause the cd to go to to the home directory.

I sometimes prefer to add a pwd to the alias as a check and reminder of what the current working directory is-:

alias solr='cd /Applications/MAMP/htdocs/whoat/solr/whoat;pwd'

Ideally you would put this alias in your .bash_profile in your home directory. You can use a text editor such as TextEdit or vim to add the alias command to .bash_profile. Then to load the new alias into your shell type-:

source .bash_profile
Related Question