I run a MacBook Pro with yosemite OSX. I'm trying to create shortcuts to go to certain directories, run script files, etc. This is my first attempt at creating shortcuts/aliases. I'm asking in this forum because when I type

cd ~
ls -la

I get a list of files/folders like .bash_profile and .bash_history (but no .bashrc yet).

Here is the content I put in the file:

alias run-vagrant = "cd ~/vagrant-dev/v104 && vagrant up"

But when i enter run-vagrant on command line I get a message

-bash: run-vagrant: command not found

What is the solution for this?

closed as unclear what you're asking by Kusalananda, msp9011, X Tian, Mr Shunz, roaima Mar 18 at 10:25

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Apart from the error is the syntax of the alias command (there should be no spaces around =), it is unclear what file you are adding this command into. Bash is by default started as a login shell on macOS, so .bash_profile will be used. I'm voting to close this as unclear until such time that it is clarified. – Kusalananda Mar 15 at 19:30

I found an answer to this. Use .bash_profile vs. .bashrc

Additionally, you may need to type in

source ~/.bash_profile

to reload.

Also, here are two helpful links I found:

https://www.moncefbelyamani.com/create-aliases-in-bash-profile-to-assign-shortcuts-for-common-terminal-commands/ and this - https://community.linuxmint.com/tutorial/view/891 - but don't follow the advice on .bashrc (I guess - as this didn't work for me) - use .bash_profile instead.

Also, look at the comments on the 2nd link - requiring .bash_aliases in .bash_profile is a more elegant way to roll..

Not the answer you're looking for? Browse other questions tagged or ask your own question.