Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include additional files in .bashrc

I have some stuff I want to perform in .bashrc which I would prefer to exist in another file on the system. How can I include this file into .bashrc?

like image 323
Fragsworth Avatar asked Feb 10 '11 00:02

Fragsworth


People also ask

Can you have multiple bashrc files?

bashrc files or any files which has your environment variables or even other data which you want in them, for example you can have three . bashrc files at your home directory.

What should bashrc contain?

bashrc file is a script file that's executed when a user logs in. The file itself contains a series of configurations for the terminal session. This includes setting up or enabling: coloring, completion, shell history, command aliases, and more.

How do you source an RC file?

Download and source the OpenStack RC fileOn the Project tab, open the Compute tab and click Access & Security. On the API Access tab, click Download OpenStack RC File and save the file. The filename will be of the form PROJECT-openrc.sh where PROJECT is the name of the project for which you downloaded the file.


2 Answers

Add source /whatever/file (or . /whatever/file) into .bashrc where you want the other file included.

like image 161
Jeremiah Willcock Avatar answered Oct 11 '22 12:10

Jeremiah Willcock


To prevent errors you need to first check to make sure the file exists. Then source the file. Do something like this.

# include .bashrc if it exists if [ -f $HOME/.bashrc_aliases ]; then     . $HOME/.bashrc_aliases fi 
like image 32
Nick Avatar answered Oct 11 '22 13:10

Nick