Bash: How to Use Multiple .bashrc Scripts

bashshell-script

(I have seen this question, but not sure, if it's the same)

I use a lot of alias in my .bashrc script.
Is there any way, to use many different .bashrc scripts?

for example
git.bashrc

alias gpull='git pull'
alias gcom='git commit -a -m '
alias gpush='git push'
alias gstat='git status'
alias gco='git checkout'

ide.bashrc

alias idea='/home/myname/dev/ide/idea/bin/idea.sh'
alias idea='/home/myname/dev/eclipse/eclipse/bin/eclipse.sh'

normal .bashrc should include something like

include ide.bashrc
include git.bashrc
# normal stuff like:
if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

I want to use version control to have them on all my computers, but I can't really use the complete bashrc file for it.
Thanks a lot!

Best Answer

The keyword for this is source (or simply .) instead of include.

Add this to your .bashrc:

# Include more scripts
source /path/to/ide.bashrc
source /path/to/git.bashrc

or

# Include more scripts
. /path/to/ide.bashrc
. /path/to/git.bashrc

or include all from one directory:

if [ -d /path/to/includes ]; then
    for f in /path/to/includes/*.bashrc; do
        . "$f"
    done
fi

Read:

Related Question