mirror of
https://github.com/Microsoft/vscode
synced 2024-10-06 03:17:00 +00:00
Merge pull request #208960 from cpendery/feat/git-bash-shell-integration
feat: add git-bash support to shell integration
This commit is contained in:
commit
ff1fc119df
|
@ -500,7 +500,7 @@ class UnixPtyHeuristics extends Disposable {
|
|||
}
|
||||
|
||||
const enum AdjustCommandStartMarkerConstants {
|
||||
MaxCheckLineCount = 5,
|
||||
MaxCheckLineCount = 10,
|
||||
Interval = 20,
|
||||
MaximumPollCount = 50,
|
||||
}
|
||||
|
@ -896,6 +896,15 @@ class WindowsPtyHeuristics extends Disposable {
|
|||
}
|
||||
}
|
||||
|
||||
// Bash Prompt
|
||||
const bashPrompt = lineText.match(/^(?<prompt>.*\$)/)?.groups?.prompt;
|
||||
if (bashPrompt) {
|
||||
const adjustedPrompt = this._adjustPrompt(bashPrompt, lineText, '$');
|
||||
if (adjustedPrompt) {
|
||||
return adjustedPrompt;
|
||||
}
|
||||
}
|
||||
|
||||
// Python Prompt
|
||||
const pythonPrompt = lineText.match(/^(?<prompt>>>> )/g)?.groups?.prompt;
|
||||
if (pythonPrompt) {
|
||||
|
|
|
@ -161,6 +161,20 @@ export function getShellIntegrationInjection(
|
|||
envMixin['VSCODE_SUGGEST'] = '1';
|
||||
}
|
||||
return { newArgs, envMixin };
|
||||
} else if (shell === 'bash.exe') {
|
||||
if (!originalArgs || originalArgs.length === 0) {
|
||||
newArgs = shellIntegrationArgs.get(ShellIntegrationExecutable.Bash);
|
||||
} else if (areZshBashLoginArgs(originalArgs)) {
|
||||
envMixin['VSCODE_SHELL_LOGIN'] = '1';
|
||||
addEnvMixinPathPrefix(options, envMixin);
|
||||
newArgs = shellIntegrationArgs.get(ShellIntegrationExecutable.Bash);
|
||||
}
|
||||
if (!newArgs) {
|
||||
return undefined;
|
||||
}
|
||||
newArgs = [...newArgs]; // Shallow clone the array to avoid setting the default array
|
||||
newArgs[newArgs.length - 1] = format(newArgs[newArgs.length - 1], appRoot);
|
||||
return { newArgs, envMixin };
|
||||
}
|
||||
logService.warn(`Shell integration cannot be enabled for executable "${shellLaunchConfig.executable}" and args`, shellLaunchConfig.args);
|
||||
return undefined;
|
||||
|
@ -310,16 +324,18 @@ shellIntegrationArgs.set(ShellIntegrationExecutable.PwshLogin, ['-l', '-noexit',
|
|||
shellIntegrationArgs.set(ShellIntegrationExecutable.Zsh, ['-i']);
|
||||
shellIntegrationArgs.set(ShellIntegrationExecutable.ZshLogin, ['-il']);
|
||||
shellIntegrationArgs.set(ShellIntegrationExecutable.Bash, ['--init-file', '{0}/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh']);
|
||||
const loginArgs = ['-login', '-l'];
|
||||
const pwshLoginArgs = ['-login', '-l'];
|
||||
const shLoginArgs = ['--login', '-l'];
|
||||
const shInteractiveArgs = ['-i', '--interactive'];
|
||||
const pwshImpliedArgs = ['-nol', '-nologo'];
|
||||
|
||||
function arePwshLoginArgs(originalArgs: string | string[]): boolean {
|
||||
if (typeof originalArgs === 'string') {
|
||||
return loginArgs.includes(originalArgs.toLowerCase());
|
||||
return pwshLoginArgs.includes(originalArgs.toLowerCase());
|
||||
} else {
|
||||
return originalArgs.length === 1 && loginArgs.includes(originalArgs[0].toLowerCase()) ||
|
||||
return originalArgs.length === 1 && pwshLoginArgs.includes(originalArgs[0].toLowerCase()) ||
|
||||
(originalArgs.length === 2 &&
|
||||
(((loginArgs.includes(originalArgs[0].toLowerCase())) || loginArgs.includes(originalArgs[1].toLowerCase())))
|
||||
(((pwshLoginArgs.includes(originalArgs[0].toLowerCase())) || pwshLoginArgs.includes(originalArgs[1].toLowerCase())))
|
||||
&& ((pwshImpliedArgs.includes(originalArgs[0].toLowerCase())) || pwshImpliedArgs.includes(originalArgs[1].toLowerCase())));
|
||||
}
|
||||
}
|
||||
|
@ -333,6 +349,9 @@ function arePwshImpliedArgs(originalArgs: string | string[]): boolean {
|
|||
}
|
||||
|
||||
function areZshBashLoginArgs(originalArgs: string | string[]): boolean {
|
||||
return originalArgs === 'string' && loginArgs.includes(originalArgs.toLowerCase())
|
||||
|| typeof originalArgs !== 'string' && originalArgs.length === 1 && loginArgs.includes(originalArgs[0].toLowerCase());
|
||||
if (typeof originalArgs !== 'string') {
|
||||
originalArgs = originalArgs.filter(arg => !shInteractiveArgs.includes(arg.toLowerCase()));
|
||||
}
|
||||
return originalArgs === 'string' && shLoginArgs.includes(originalArgs.toLowerCase())
|
||||
|| typeof originalArgs !== 'string' && originalArgs.length === 1 && shLoginArgs.includes(originalArgs[0].toLowerCase());
|
||||
}
|
||||
|
|
|
@ -183,6 +183,9 @@ __vsc_continuation_end() {
|
|||
}
|
||||
|
||||
__vsc_command_complete() {
|
||||
if [[ -z "$__vsc_first_prompt" ]]; then
|
||||
builtin return
|
||||
fi
|
||||
if [ "$__vsc_current_command" = "" ]; then
|
||||
builtin printf '\e]633;D\a'
|
||||
else
|
||||
|
@ -213,6 +216,7 @@ __vsc_precmd() {
|
|||
__vsc_command_complete "$__vsc_status"
|
||||
__vsc_current_command=""
|
||||
__vsc_update_prompt
|
||||
__vsc_first_prompt=1
|
||||
}
|
||||
|
||||
__vsc_preexec() {
|
||||
|
|
Loading…
Reference in a new issue