Location of "~/.bash_aliases"

29,887

Solution 1

~/.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.

Solution 2

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.

Share:
29,887

Related videos on Youtube

Community
Author by

Community

Updated on September 18, 2022

Comments

  • Community
    Community almost 2 years

    I want to make permanent aliases in Terminal, and I have read this answer on how to do it: https://askubuntu.com/a/5278/364819

    But I have got a small problem, I have found the code:

    if [ -f ~/.bash_aliases ]; then
        . ~/.bash_aliases
    fi
    

    As 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.

    • fiatux
      fiatux over 9 years
      If it's not there in your home directory, feel free to create the file. That's why the code snipped first tests for file existence before trying to source it.