I want to make permanent aliases in Terminal, and I have read this answer on how to do it:
But I have got a small problem, I have found the code:
if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases
fiAs refereed to in the answer. But I cannot actually find the .bash_aliases file which I can set these permanent aliases in.
So my question is, where is the location of this file, and if I need to create it, do I just create it in my home user directory directory?
I am running on Ubuntu 14.10.
12 Answers
Yes, just create it in your home directory.
touch ~/.bash_aliases or open an empty file in a text editor, e.g.,
gedit ~/.bash_aliases
This should be one of your first aliases..
##### ea - alias for editing aliases
#
#When setting up a new aliases file, or having creating a new file.. About every time after editing an aliases file, I source it. This alias makes editing alias a
#bit easier and they are useful right away. Note if the source failed, it will not echo "aliases sourced".
#
#Sub in gedit for your favorite editor, or alter for ksh, sh, etc.
#
alias ea='gedit ~/.bash_aliases; source ~/.bash_aliases && source $HOME/.bash_aliases && echo "aliases sourced --ok."'
#When you run across something that would be a good alias, enter ea, a text editor opens. Add your new alias. Close the editor. The alias automagically sources; makes the new alias immediately available; and you're on your way.
~/.bash_aliases is a full path already. The tilde (~) is expanded by the shell (and many other applications) to your full home path (aka $HOME, usually /home/$USER).
It doesn't exist by default, so just create one.