How can I change the default directory of windows bash to a folder of my choosing?
EDIT: I guess I should have been more clear. When I startup Bash I want it the directory to be in a location of my choosing like Desktop or something. How do I go about setting a default directory?
The Easy Option: Use the Address Bar. When you want to launch bash at a specific folder, just navigate to that folder in File Explorer normally. Click the address bar while in that folder, type “bash”, and press Enter. You'll get a Bash prompt window focused in the folder you selected.
Find it by typing cd / then pwd -W . Alternatively, from the start menu, right click on the Git Bash icon and select open file location. It might be something like C:\Users\name\AppData\Local\Programs\Git , the mingw64 in this directory is your root.
If you want change the directory your bash prompt is starting in, you can edit your .bashrc
file. At the bottom, add:
cd ~
This will go into your home directory. (you can actually do just cd
, but I it's clearer to add the ~
IMO)
To edit, you can use vim
. If you don't know how to use it, you can always use nano
for the time being, but you really should have a look at it, it's really powerful.
$ nano ~/.bashrc
This will open nano in "full console". At the bottom, you have the few commands you can use (^
means control
) Do your changes, hit ctrl+o
to save the file (write the file). It'll ask you where to write, by default, it's the right location, just hit enter
and the .bashrc
file will be saved. Then, you can press ctrl+x
to exit.
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