• Home
  • About
    • Richie's Blog photo

      Richie's Blog

      Science, data, biology, digital health, programming, tech

    • Learn More
    • Twitter
    • LinkedIn
    • Github
  • Posts
    • All Posts
    • All Tags
  • Projects

Shell configuration files

08 Dec 2014

Reading time ~1 minute

Where do I put that alias? What about the terminal prompt configuration? Which config file does this belong in?

There are a number of configuration files, such as .bashrc, .bash_profile, .bash_login, .login, .profile, .zsh etc.. Customising these files to your own needs can be incredibly useful. It is often not clear which to use in a given situation (and how), and although often an initial desired outcome can be achieved through a number of pathways, it is always good to be aware of the differences between the files, what their intended purposes are, and how they might best be used for your particular circumstance. A Stackoverflow thread looked at the differences, with another discussing best practices.

.bashrc is only read by a shell that is interactive and non-login, therefore .bashrc is often ready by the .bash_profile, which is called at login and thus also loads all .bashrc commands at login to set up the initial environment.


# In .bash_profile
[[ -r ~/.bashrc ]] && . ~/.bashrc

Any changes to system configuration files (e.g. .bashrc, .bash_profile) can be easily reloaded using the source command, for example:


$ source ~/.bashrc



Like Tweet +1