mac how to save alias in computer
Add the command to your .bashrc
file
echo "alias hw='cd Desktop/2015hw'" >> ~/.bashrc
Keep in mind that your alias will only work when you are in your home (as you are using a relative path)
echo "alias hw='cd ~/Desktop/2015hw'" >> ~/.bashrc
Execute the saved alias by sourcing the file
source ~/.bashrc
your can start with type
ls -la
and then if you use bash typing
nano .bash_profile
or if you use zsh typing
nano .zshrc
then make alias save with ctrl + o
for activating
use
source ~/.bash_profile
or
source ~/.zsh
When making an alias with alias
, the alias is only valid until you close the terminal window. If you open another terminal window, the alias will no longer be present.
You can make an alias be valid for all terminal windows by placing it in your ~/.bash_profile or ~/.bashrc files (bash is the name of the terminal which Mac OS X ships with by default.)
Since Mac OS X does not load .bashrc by default, I would actually do:
echo "alias hw='cd ~/Desktop/2015hw'" >> ~/.bash_profile
When you want to delete the alias, you can open your ~/.bash_profile or ~/.bashrc files and delete it manually.
To open them, do open -a TextEdit ~/.bash_profile
or open -a TextEdit ~/.bashrc
Finally, to list all your current aliases, simply type alias
in Terminal.