Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change default directory in Bash for Windows 10? [closed]

Tags:

bash

windows

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?

like image 996
diaztho1 Avatar asked Feb 19 '17 06:02

diaztho1


People also ask

How do I open a bash folder?

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.

Where is the git bash directory?

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.


1 Answers

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.

like image 170
math2001 Avatar answered Sep 21 '22 13:09

math2001