Since you can use environment variables in a settings.json, as illustrated here, you can use the new (Q3 2023) GIT_SHELL_PATH
variable:
"terminal.integrated.shell.windows": "${env:GIT_SHELL_PATH}"
With Git 2.42 (Q3 2023), add more "git var
"(man) for toolsmiths to learn various locations Git is configured with either via the configuration or hard-coded defaults.
See commit ed773a1, commit 576a37f, commit 15780bb, commit cdd489e, commit f74c90d, commit 1e65721, commit d6546af (27 Jun 2023) by brian m. carlson (bk2204
).
See commit 4db16f5 (27 Jun 2023) by Jeff King (peff
).
(Merged by Junio C Hamano -- gitster
-- in commit 89d62d5, 04 Jul 2023)
var
: add support for listing the shell
Signed-off-by: brian m. carlson
On most Unix systems, finding a suitable shell is easy: one simply uses "sh" with an appropriate PATH value.
However, in many Windows environments, the shell is shipped alongside Git, and it may or may not be in PATH
, even if Git is.
In such an environment, it can be very helpful to query Git for the shell it's using, since other tools may want to use the same shell as well.
To help them out, let's add a variable, GIT_SHELL_PATH,
that points to the location of the shell.
On Unix, we know our shell must be executable to be functional, so assume that the distributor has correctly configured their environment, and use that as a basic test.
On Git for Windows, we know that our shell will be one of a few fixed values, all of which end in "sh
" (such as "bash
").
This seems like it might be a nice test on Unix as well, since it is customary for all shells to end in "sh
", but there probably exist such systems that don't have such a configuration, so be careful here not to break them.
git var
now includes in its man page:
GIT_SHELL_PATH
The path of the binary providing the POSIX shell for commands which use the shell.