5

When running git bash, I can open a new bash window at my root with Alt+F2

I can open a windows explorer window at the current directory path

$ explorer .

Trying

$ sh

to open a new terminal window at my location just returns

sh: __git_ps1: command not found

and opens the shell in the current window without git running.

How can I quickly open a new bash shell at my location?

  • Which version do you use? – Biswapriyo Apr 17 '18 at 8:51
  • @Biswapriyo MINGW64, GNU bash, version 4.4.12(2)-release (x86_64-pc-msys) – StuperUser Apr 17 '18 at 9:00
  • 1
    The feature that you've requested is available from mintty 2.8.5 which is not added in git-for-windows latest release. So wait for future release. – Biswapriyo Apr 17 '18 at 9:11
  • @Biswapriyo looking into running $ mintty, I can add "git-bash.exe" to my path and run $ git-bash to do exactly what I want – StuperUser Apr 17 '18 at 9:17
4

StuperUser answer are correct, but I want to add that besides adding shell script in a PATH environment it's also possible to use a simple bash alias in .bashrc or .bash_profile files.

Something like that:

alias git-bash='/git-bash.exe & > /dev/null 2&>1'
1

Since this is specifically for a git-bash terminal, add the Git directory (C:\Program Files\Git) to your path (https://www.howtogeek.com/118594/how-to-edit-your-system-path-for-easy-command-line-access/)

Then run

$ git-bash

to open a new git-bash at the current location.

But to avoid blocking the current terminal it will be necessary to use & > /dev/null 2&>1 to run in the background and pipe the result into null (see https://superuser.com/a/1314830/641), so added the command to a .sh in the directory to call it simply.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.