#!/bin/bash
-# When bash is invoked as an interactive login shell, or as a non-interac-
-# tive shell with the --login option, it first reads and executes commands
-# from the file /etc/profile, if that file exists. After reading that
-# file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in
-# that order, and reads and executes commands from the first one that
-# exists and is readable.
-
-if [ -f /etc/profile ];
-then
- source /etc/profile
-fi
+function load_login_configs {
+ # When bash is invoked as an interactive login shell, or as a non-interac-
+ # tive shell with the --login option, it first reads and executes commands
+ # from the file /etc/profile, if that file exists. After reading that
+ # file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in
+ # that order, and reads and executes commands from the first one that
+ # exists and is readable.
+
+ if [ -f /etc/profile ]; then
+ source /etc/profile
+ fi
+
+ if [ -f ~/.bash_profile ]; then
+ source ~/.bash_profile
+ else
+ if [ -f ~/.bash_login ]; then
+ source ~/.bash_login
+ else
+ if [ -f ~/.profile ]; then
+ source ~/.profile
+ fi
+ fi
+ fi
+}
-if [ -f ~/.bash_profile ];
-then
- source ~/.bash_profile
+function load_interactive_configs {
+ if [ -f ~/.bash_profile ]; then
+ source ~/.bashrc
+ fi
+}
+
+if [ `shopt -q login_shell` ]; then
+ load_login_configs
else
- if [ -f ~/.bash_login ]
- then
- source ~/.bash_login
- else
- if [ -f ~/.profile ]
- then
- source ~/.profile
- fi
- fi
+ load_interactive_configs
fi
-
# mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
bind '"\e\e[C":forward-word'
bind '"\e\e[D": backward-word'