3

I was trying to setup a permanent alias. but ~/.bash_aliases file not found on my system. I have checked the bashrc file and it shows bash_aliases are enabled. I tried creating a new file in the same name in home directory and putting the aliases. But it also didn't work. Any solution to set a permanent alias?

Also i would like to know whether I can set an alias for shell that I created and it is residing in some other path. Thanks in advance.

Anandu M Das
  • 2,303

1 Answers1

6

The lines

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

mean if the file .bash_aliases exists then use it. In your case it doesn't exist so it's ignored.

If you want to add to it just create the file. How you do that is up to you but I'd suggest gedit ~/.bash_aliases from the terminal. Add in any aliases you want, then save the file and open a new terminal. Your new aliases should be working.

If you want the new aliases in an existing terminal use source ~/.bash_aliases.

EDIT: I've just noticed you've referred to the file by both bash_aliases and bashrc_aliases. It doesn't matter which you use as long as the filename matches the line in .bashrc.

Holloway
  • 188
  • 8