1

I have started from this question: How to run bash commands and leave prompt open?

However, apparently, bash and Git-Bash are quite different. Git-Bash is a wrapper that behaves differently.

I have a shortcut that starts this Git-Bash shell. After starting it, I want it to source start.sh automatically, and then to leave the shell open.

The Short-Cut

The Properties of the Short-Cut

Whatever I have tried so far did not work.

This is my start.sh Shell-Script:

#!/bin/bash

# The File-Editor.
alias n='"C:\\Program Files\\Notepad++\\notepad++.exe"'

# The Build Commands.
alias gp='/c/DGSante/Git/dg-sante-new-cpms/gp.sh'

# The 'Docker' Commands.
alias dd='docker-compose down -v'
alias db='docker-compose build'
alias du='docker-compose up'

UPDATE:

Thanks everyone for commenting.

This is an example of one of my attempts to solve this problem:

The shortcut starts the following one-liner:

/c/Progra~1/Git/git-bash.exe -c 'exec /c/Progra~1/Git/git-bash.exe --cd=/c/DGSante/Git/dg-sante-new-cpms/ --init-file /c/DGSante/Git/dg-sante-new-cpms/start.sh -i'

However, although the first Git-Bash interactively starts the second Git-Bash in the necessary working folder and uses the start.sh as an init-file, the secondary Git-Bash is terminated and it does not remain open.

SOLUTION:

Great thanks to @muru for clarifications.

The working solution looks like the following one-liner:

"C:\Program Files\Git\bin\bash.exe" --cd=C:\DGSante\Git\dg-sante-new-cpms\ --init-file C:\DGSante\Git\dg-sante-new-cpms\start.sh

I have removed the usage of the Git-Bash wrapper. I am relying entirely on the Bash port to the Microsoft Windows Operating-System.

I absolutely agree to @Marcus Müller's comments. However, this is the only place where I have found help.

Thanks everyone.

RESULT:

The Shell with its sourced Script

7
  • 1
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Jun 8, 2023 at 9:59
  • 1
    What exactly have you tried so far? How did you configure Git Bash to source this file at startup?
    – muru
    Jun 8, 2023 at 10:00
  • 5
    I’m voting to close this question because this is explicitly not about a shell running on Linux/UNIX, but about a shell running on Windows. Jun 8, 2023 at 10:12
  • 3
    (asking this here is like asking here why firefox on windows misbehaves in a Windows-specific way: though firefox, just as bash, are natively available for UNIX systems, the problems here are specific to a concrete version for Windows. You're just reaching the wrong community here) Jun 8, 2023 at 10:13
  • 2
    If you want, you can post the solution as an answer.
    – muru
    Jun 8, 2023 at 12:39

1 Answer 1

0

As advised by @muru, maybe it is a good idea to write the answer to this question here.

This does not solve the Git-Bash problem, however.

It is just a workaround that is based on the Bash port to the Microsoft Windows Operating-System.

The following one-liner does start the Shell, which executes the Shell-Script, and also leaves the terminal running:

"C:\Program Files\Git\bin\bash.exe" --cd=C:\DGSante\Git\dg-sante-new-cpms\ --init-file C:\DGSante\Git\dg-sante-new-cpms\start.sh
2
  • 1
    By "Bash port to the Microsoft Windows Operating-System" do you mean the Windows Subsystem for Linux? It doesn't look like you're using WSL here
    – muru
    Jun 8, 2023 at 13:04
  • You are right, @muru. I also have the Microsoft Windows Subsystem for Linux, but this bash.exe executable is described in its properties as Git for Windows. Also, in its details, the original filename is marked as git.exe. The product name is Git, with the file version 2.41.0.1, and with the product version 2.41.0.windows.1. So, I guess that this is actually still Git-Bash, but not the wrapper itself. Jun 8, 2023 at 13:28

Not the answer you're looking for? Browse other questions tagged .