How to Make Git-Bash Command Line Start Up with Home Directory

How to enable Git terminal begin with home directory in Windows?

If you are on Windows, do this

  • Right click on the Windows shortcut that you use to launch git bash terminal i.e git-bash.exe, and click Properties.
  • Go to tab named Shortcut
  • Change the value of Start in: label to your desired workspace path i.e. C:\Users\Kedar maybe in your case

Then you should run the application as administrator!

How to make Git-bash command line start up with home directory?

If you are on Windows, do this
Right click on the Windows shortcut that you use to launch git bash, and click Properties. Change the value of "Start In" to your desired workspace path i.e.
Replace the start in values with "C:\Users\GodCoder"

For more information go to this link: https://classroom.udacity.com/courses/ud775/lessons/2980038599/concepts/33417185870923
It may help you in setting up your enviroment further and also, make sure you restart the application or even the pc and try running in admin or different user modes too!

How do I change the default location for Git Bash on Windows?

After installing msysgit I have the Git Bash here option in the context menu in Windows Explorer. So I just simply navigate to the directory and then open Bash right there.

I also copied the default Git Bash shortcut to the desktop and edited its Start in property to point to my project directory. It works flawlessly.

Windows 7x64, msysgit.

Change the location of the ~ directory in a Windows install of Git Bash

I don't understand, why you don't want to set the $HOME environment variable since that solves exactly what you're asking for.

cd ~ doesn't mean change to the root directory, but change to the user's home directory, which is set by the $HOME environment variable.

Quick'n'dirty solution

Edit C:\Program Files (x86)\Git\etc\profile and set $HOME variable to whatever you want (add it if it's not there). A good place could be for example right after a condition commented by # Set up USER's home directory. It must be in the MinGW format, for example:

HOME=/c/my/custom/home

Save it, open Git Bash and execute cd ~. You should be in a directory /c/my/custom/home now.

Everything that accesses the user's profile should go into this directory instead of your Windows' profile on a network drive.

Note: C:\Program Files (x86)\Git\etc\profile is shared by all users, so if the machine is used by multiple users, it's a good idea to set the $HOME dynamically:

HOME=/c/Users/$USERNAME

Cleaner solution

Set the environment variable HOME in Windows to whatever directory you want. In this case, you have to set it in Windows path format (with backslashes, e.g. c:\my\custom\home), Git Bash will load it and convert it to its format.

If you want to change the home directory for all users on your machine, set it as a system environment variable, where you can use for example %USERNAME% variable so every user will have his own home directory, for example:

HOME=c:\custom\home\%USERNAME%

If you want to change the home directory just for yourself, set it as a user environment variable, so other users won't be affected. In this case, you can simply hard-code the whole path:

HOME=c:\my\custom\home

How to set the startup directory in Git Bash?

Right click on the shortcut, and select properties. Navigate to the "shortcut" tab.

There are two things you need to change here. First, by default, the Target field will end in --cd-to-home - remove it. Once you've done that, you can edit the Start in field and give it any directory you want.

E.g., this is how the shortcut looks on my machine:

Sample Image

After editing, you'll have:

Sample Image

You could also, of course, create multiple Git Bash shortcuts to start in each directory you're interested in.

How to default to other directory instead of home directory

Just write that line to a file "cd.sh", then do this from your shell prompt:

. ./cd.sh

Or you can create an alias or function in your $HOME/.bashrc file:

foo() { cd /d/work_space_for_my_company/project/code_source ; }

If the directory name includes spaces or other shell metacharacters, you'll need quotation marks; it won't hurt to add them even if they're not necessary:

foo() { cd "/d/Work Space/project/code_source" ; }

(Note that I've omitted the ../../..; you don't need it.)

EDIT: If you add a line

foo

to your .bashrc after the function definition, your shell will start in that directory. Or you can just use the cd command directly in your .bashrc if you aren't going to need to use the function later.

(The name foo is just an example; you should pick a more meaningful name.)



Related Topics



Leave a reply



Submit