Bash - Share bashrc between Git Bash and Ubuntu Bash on Windows 10

March 05, 2018 - 1 min read

bashwindows 10

Hello all,

This is my first post in English and I hope it will be written in a correct English. So, my apologies for the possible mistakes.

Today, I’d like to share with you my small trick for using the same .bashrc file in Git Bash and in Ubuntu Bash.

That’s allow me to switch between both environments keeping my aliases, functions, …

My .bashrc in “C:\Users%USERNAME%”

if [ -z ${basePath+x} ]; then export basePath=""; echo "basePath changed! New value: \"$basePath\""; else echo "basePath value: $basePath"; fi

alias npp="$basePath/c/Program\ Files\ \(x86\)/Notepad++/notepad++.exe"

And obviously in my .bashrc in Ubuntu bash –> “/home/$USER”

# All the file
export basePath="/mnt"
. /c/Users/<username_windows>/.bashrc

Of course, I did this for sharing my .bashrc between my environments but also to adapt easily my .bashrc from Windows 10 and save it via Windows.

That’s it. I’ll share soon my .bashrc on GitHub which allows me to use my Win softwares with my aliases.

See you soon 😊


Written by Alexis GEORGES
Living in Brussels (beers, cheeses, chocolates, etc.), geek passionate by Open Source initiatives, against the censorship and careful with the privacy.
You can follow me on Twitter