I've just installed Git for Windows and am delighted to see that it installs Bash.
I want to customise the shell in the same way I can under Linux (e.g. set up aliases like ll
for ls -l
), but I can't seem to find .bashrc
or equivalent configuration files.
What should I be editing?
~/. bashrc is in your home directory, so it should be the directory you're in as soon as you start the git bash shell. just create a file called . bashrc and .
In windows there is no . bashrc file. But there is a way to achieve the same functionality using powershell. In this example we will download notepad++ and set an alias vim to open files in notepad++ from command prompt.
bashrc file allows you to customize certain things about your user shell by adding things like aliases, functions, different visuals, etc. A . bashrc file is really just a shell script that runs when you open a new shell so that everything is set up before you even hit the command line.
Git Bash comes included as part of the Git For Windows package. Download and install Git For Windows like other Windows applications. Once downloaded find the included .exe file and open to execute Git Bash.
Create a .bashrc
file under ~/.bashrc
and away you go. Similarly for ~/.gitconfig
.
~
is usually your C:\Users\<your user name>
folder. Typing echo ~
in the Git Bash terminal will tell you what that folder is.
If you can't create the file (e.g. running Windows), run the below command:
copy > ~/.bashrc
The window will output an error message (command not found), but the file will be created and ready for you to edit.
In newer versions of Git for Windows, Bash is started with --login
which causes Bash to not read .bashrc
directly. Instead it reads .bash_profile
.
If this file does not exist, create it with the following content:
if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
This will cause Bash to read the .bashrc
file. From my understanding of this issue, Git for Windows should do this automatically. However, I just installed version 2.5.1, and it did not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With