DEV Community

Cover image for Kept running "source .bashrc" every time I open WSL
Eden Jose
Eden Jose

Posted on • Edited on

4 2 1

Kept running "source .bashrc" every time I open WSL

I was playing around and testing some stuff in Linux when i suddenly did a tweak which changed how my WSL terminal opens up. This is what my terminal looks like - notice it doesn't the distinct green + blue colors.
image

After some searching I found two articles (links at the bottom) which describes the "sequence" which Unix follows when reading files. As summary, here's the files (in order):

  1. /etc/profile
  2. ~/.bash_profile
  3. ~/.bash_login 4 ~/.profile

I added the function for .bashrc at the top of the .bash_profile:



## Loads .bashrc
if [[ -f ~/.bashrc ]] ; then
        . ~/.bashrc
fi


Enter fullscreen mode Exit fullscreen mode

Closed terminal and reopened it
Voila! It now shows the green and blue colors.
image

Adding this great explanation from the reference link:

By default, Terminal starts the shell via /usr/bin/login, which makes the shell a login shell. On every platform (not just Mac OS X) bash does not use .bashrc for login shells (only /etc/profile and the first of .bash_profile, .bash_login, .profile that exists and is readable). This is why "put source ~/.bashrc in your .bash_profile" is standard advice


References

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly — using the tools and languages you already love!

Learn More

Top comments (0)

AI Agent image

How to Build an AI Agent with Semantic Kernel (and More!)

Join Developer Advocate Luce Carter for a hands-on tutorial on building an AI-powered dinner recommendation agent. Discover how to integrate Microsoft Semantic Kernel, MongoDB Atlas, C#, and OpenAI for ingredient checks and smart restaurant suggestions.

Watch the video →

👋 Kindness is contagious

Dive into this thoughtful article, cherished within the supportive DEV Community. Coders of every background are encouraged to share and grow our collective expertise.

A genuine "thank you" can brighten someone’s day—drop your appreciation in the comments below!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found value here? A quick thank you to the author makes a big difference.

Okay