# BASH startup files /private/etc/profile # login shell ~/.bash_profile ~/.bash_login ~/.profile /private/etc/bashrc # non-login shell ~/.bashrc # list your BASH startup files ls -a ~ | grep \.bash ls /private/etc | grep -E "bash|profile" # backup the existing BASH startup files sudo cp -p /private/etc/profile /private/etc/profile.orig sudo cp -p /private/etc/bashrc /private/etc/bashrc.orig cp -p ~/.bash_profile ~/.bash_profile.orig cp -p ~/.bash_login ~/.bash_login.orig cp -p ~/.profile ~/.profile.orig cp -p ~/.bashrc ~/.bashrc.orig # /private/etc/profile should contain: # if [[ -f /private/etc/bashrc ]]; then source /private/etc/bashrc; fi sudo sh -c 'echo "if [[ -f /private/etc/bashrc ]]; then source /private/etc/bashrc; fi" >> /private/etc/profile' sudo nano /private/etc/profile # ~/.bash_profile or ~/.bash_login or ~/.profile should contain: # if [[ -f ~/.bashrc ]]; then source ~/.bashrc; fi echo 'if [[ -f ~/.bashrc ]]; then source ~/.bashrc; fi' >> ~/.bash_login nano ~/.bash_login # then add a simple 'echo' command to the existing BASH startup files sudo sh -c 'echo "echo \"... running /private/etc/profile ...\"" >> /private/etc/profile' sudo sh -c 'echo "echo \"... running /private/etc/bashrc ...\"" >> /private/etc/bashrc' echo 'echo "... running ~/.bash_profile ..."' >> ~/.bash_profile echo 'echo "... running ~/.bash_login ..."' >> ~/.bash_login echo 'echo "... running ~/.profile ..."' >> ~/.profile echo 'echo "... running ~/.bashrc ..."' >> ~/.bashrc # check added lines sudo nano /private/etc/profile sudo nano /private/etc/bashrc nano ~/.bash_profile nano ~/.bash_login nano ~/.profile nano ~/.bashrc exit # now relaunch Terminal.app and play around with ... bash echo $SHLVL exec bash echo $SHLVL exec bash -$- exec env -i /bin/bash exec bash --login exec bash -l echo $0 echo $BASH_ENV exec bash -norc bash bash --init-file file bash --rcfile file open-x11 xterm ssh some_other_user@internal_IP_address # cf. http://textsnippets.com/posts/show/1326 ...
Further information:
- Controlling Bash At Startup
- Make X11 Xterm Launch Login Shells
- Initialisation Scripts
- Difference between .bashrc and .bash_profile
- Fun and profit by modifying your Bash startup files in OS X, Linux, and other fine unices
- bash shell aliases
- A Sample .bashrc File
- Theming Bash
- .bash_profile
- .bashrc