How do I create a terminal shortcut to this path?
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
Links
To create links, you use the ln
command. See man ln
.
You could do it like ln -s /Applications/MAMP/htdocs/whoat/solr/whoat /where/you/want/link
, where:
- The first path is what you are linking
- The second path is where the link will be
Directory Navigation
man cd
There are two ways to navigate with cd
, absolute and relative.
The easiest way to get from home to applications is cd /Applications/
- Capitalization matters....
Editing Files
Doing ~/.bash_profile
isn't how you edit a file.... you were trying to run the file like it was a script (even though it a config file)
Also, here is a decent article on the difference between ~/.bashrc
and ~/.bash_profile
If you want to edit it from terminal, you have to use an editor, like vim/emacs/pico etc.
vim ~/.bash_profile
emacs ~/.bash_profile
pico ~/.bash_profile
Editing on Mac
As you are on OS X, you could use open -e ~/.bash_profile
to open with TextEditor
- Don't use sudo!
Sudo
You shouldn't be using sudo
to try to 'force edit' you user's files.
- It can mess up a file's permissions to be root's
- It can lead to damaging accidents when you don't know what you are doing (so you should avoid it)
- Just because you were doing it wrong, doesn't make
sudo
a magic wand to fix commands.
In Conclusion
Please read a few unix tutorials...