Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git for Windows: .bashrc or equivalent configuration files for Git Bash shell

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?

like image 250
iftheshoefritz Avatar asked Jul 30 '11 14:07

iftheshoefritz


People also ask

Where is bashrc file in Windows git Bash?

~/. 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 .

Does Windows have a bashrc?

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.

What is .bashrc file in Windows?

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.

Does git for Windows include git Bash?

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.


2 Answers

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.

like image 150
Charles Ma Avatar answered Oct 21 '22 00:10

Charles Ma


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.

like image 25
harsel Avatar answered Oct 21 '22 00:10

harsel