Ho to start Git Bash profile in Windows Terminal from bat file and pass in an executable command to run #11282

Closed
opened 2026-01-31 02:43:19 +00:00 by claunia · 5 comments
Owner

Originally created by @sud0bug on GitHub (Nov 4, 2020).

0

I am trying to start 2 applications (client and server of a MERN stack app) in Git Bash using command-line arguments for Windows Terminal. Below given is my command:
wt -M; new-tab -p "Git Bash" -d D:\ws\user-management\server cmd /k "npm run dev" ; split-pane -p "Git Bash" -H -d D:\ws\user-management\client cmd /k "npm run dev"
But this starts the application in windows cmd rather than in bash as I have given cmd /k. If I change the above command to wt -M; new-tab -p "Git Bash" -d D:\ws\user-management\server npm run dev it throws this error

[error 0x80070002 when launching `npm run dev']

How do I run my npm run dev from git bash itself rather than cmd

Originally created by @sud0bug on GitHub (Nov 4, 2020). 0 I am trying to start 2 applications (client and server of a MERN stack app) in Git Bash using command-line arguments for Windows Terminal. Below given is my command: `wt -M; new-tab -p "Git Bash" -d D:\ws\user-management\server cmd /k "npm run dev" ; split-pane -p "Git Bash" -H -d D:\ws\user-management\client cmd /k "npm run dev"` But this starts the application in windows cmd rather than in bash as I have given `cmd /k`. If I change the above command to `wt -M; new-tab -p "Git Bash" -d D:\ws\user-management\server npm run dev` it throws this error > [error 0x80070002 when launching `npm run dev'] How do I run my npm run dev from git bash itself rather than cmd
claunia added the Issue-QuestionNeeds-Tag-FixResolution-Answered labels 2026-01-31 02:43:19 +00:00
Author
Owner

@DHowett commented on GitHub (Nov 4, 2020):

you can use bash -c provided that you supply the path to git's bash.exe.

@DHowett commented on GitHub (Nov 4, 2020): you can use `bash -c` provided that you supply the path to git's bash.exe.
Author
Owner

@johnsoncherian commented on GitHub (Nov 5, 2020):

did u mean like this
wt -M; new-tab -p "Git Bash" -d D:\ws\user-management\server bash -c "npm run dev"
Which I tried and not working. Isn't -p "Git Bash" suppose to open a git bash terminal without supplying the path to bash.exe

@johnsoncherian commented on GitHub (Nov 5, 2020): did u mean like this `wt -M; new-tab -p "Git Bash" -d D:\ws\user-management\server bash -c "npm run dev"` Which I tried and not working. Isn't `-p "Git Bash"` suppose to open a git bash terminal without supplying the path to bash.exe
Author
Owner

@DHowett commented on GitHub (Nov 5, 2020):

Nope. -p "Git Bash" means "use the settings from the profile named Git Bash" -- the colors, the keyboard settings, etc. Then you specify a commandline which overrides the commandline in Git Bash (which is on purpose).

@DHowett commented on GitHub (Nov 5, 2020): Nope. `-p "Git Bash"` means "use the settings from the profile named Git Bash" -- the colors, the keyboard settings, etc. Then you specify a commandline which _overrides the commandline in `Git Bash`_ (which is on purpose).
Author
Owner

@johnsoncherian commented on GitHub (Nov 5, 2020):

Yes got it. But how do I run npm run dev without overriding the command line in Git Bash (which is BTW bash.exe).? Sorry If am getting confused here. Also if default command line is Git Bash, why should I supply the path to git's bash.exe. as you mentioned in your first comment.?

@johnsoncherian commented on GitHub (Nov 5, 2020): Yes got it. But how do I run `npm run dev` without overriding the command line in `Git Bash` (which is BTW bash.exe).? Sorry If am getting confused here. Also if default command line is `Git Bash`, why should I _supply the path to git's bash.exe._ as you mentioned in your first comment.?
Author
Owner

@zadjii-msft commented on GitHub (Nov 9, 2020):

@johnson-byjus Sorry for the miscommunication - there's not a good way of doing that currently, unfortunately. You can either use the commandline from the profile, or the one provided on the commandline, but there's not a way of appending arguments to the profile's commandline currently. That's work that's being tracked over in #5528. Right now, you'll manually need to copy the entire "Git Bash" profile's commandline into the WT command to achieve what you want - e.g.

wt -M; new-tab -p "Git Bash" -d -d D:\ws\user-management\server -- "C:\Program Files\Git\bin\bash.exe" -li -c "npm run dev"

(though, I of course have no idea what you're actual Git Bash commandline is, so that's a guess)

@zadjii-msft commented on GitHub (Nov 9, 2020): @johnson-byjus Sorry for the miscommunication - there's not a good way of doing that currently, unfortunately. You can _either_ use the `commandline` from the profile, _or_ the one provided on the commandline, but there's not a way of appending arguments to the profile's `commandline` currently. That's work that's being tracked over in #5528. Right now, you'll manually need to copy the entire "Git Bash" profile's commandline into the WT command to achieve what you want - e.g. ``` wt -M; new-tab -p "Git Bash" -d -d D:\ws\user-management\server -- "C:\Program Files\Git\bin\bash.exe" -li -c "npm run dev" ``` (though, I of course have no idea what you're actual Git Bash commandline is, so that's a guess)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#11282