Skip to content

Commit a35e6d9

Browse files
committed
add aliases in the script in the right way
1 parent 8066e60 commit a35e6d9

File tree

8 files changed

+17
-32
lines changed

8 files changed

+17
-32
lines changed

src/vs/platform/terminal/common/terminal.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ export const IPtyService = createDecorator<IPtyService>('ptyService');
217217

218218
export const enum ProcessPropertyType {
219219
Cwd = 'cwd',
220-
Aliases = 'aliases',
221220
InitialCwd = 'initialCwd',
222221
FixedDimensions = 'fixedDimensions',
223222
Title = 'title',
@@ -245,7 +244,6 @@ export interface IProcessPropertyMap {
245244
[ProcessPropertyType.OverrideDimensions]: ITerminalDimensionsOverride | undefined;
246245
[ProcessPropertyType.FailedShellIntegrationActivation]: boolean | undefined;
247246
[ProcessPropertyType.UsedShellIntegrationInjection]: boolean | undefined;
248-
[ProcessPropertyType.Aliases]: string | undefined;
249247
}
250248

251249
export interface IFixedTerminalDimensions {

src/vs/platform/terminal/common/xterm/shellIntegrationAddon.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,3 +548,17 @@ export function parseMarkSequence(sequence: string[]): { id?: string; hidden?: b
548548
}
549549
return { id, hidden };
550550
}
551+
552+
function parseAliases(aliasString: string, shellType: string): string[][] {
553+
const aliases: string[][] = [];
554+
const rows = aliasString.split('\n');
555+
for (const row of rows) {
556+
if (shellType === 'zsh') {
557+
aliases.push(row.split('='));
558+
} else if (shellType === 'bash') {
559+
// trim off 'alias '
560+
aliases.push(row.substring(6).split('='));
561+
}
562+
}
563+
return aliases;
564+
}

src/vs/platform/terminal/node/terminalProcess.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess
8989
readonly shouldPersist = false;
9090

9191
private _properties: IProcessPropertyMap = {
92-
aliases: '',
9392
cwd: '',
9493
initialCwd: '',
9594
fixedDimensions: { cols: undefined, rows: undefined },
@@ -103,7 +102,6 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess
103102
};
104103
private static _lastKillOrStart = 0;
105104
private _exitCode: number | undefined;
106-
private _aliases: string | undefined;
107105
private _exitMessage: string | undefined;
108106
private _closeTimeout: any;
109107
private _ptyProcess: pty.IPty | undefined;
@@ -232,8 +230,6 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess
232230

233231
try {
234232
await this.setupPtyProcess(this.shellLaunchConfig, this._ptyOptions, injection);
235-
this._aliases = this._ptyOptions?.env?.['USER_ALIASES'] || undefined;
236-
this._onDidChangeProperty.fire({ type: ProcessPropertyType.Aliases, value: this._aliases });
237233
return undefined;
238234
} catch (err) {
239235
this._logService.trace('IPty#spawn native exception', err);

src/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,4 @@ if [[ -z "${bash_preexec_imported:-}" ]]; then
206206
PROMPT_COMMAND=__vsc_prompt_cmd
207207
fi
208208
fi
209-
export USER_ALIASES=$(alias)
209+
echo -ne "\x1b]633;UserAliases;$(alias)"

src/vs/workbench/contrib/terminal/browser/media/shellIntegration-rc.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,4 @@ add-zsh-hook preexec __vsc_preexec
130130
if [[ $options[login] = off && $USER_ZDOTDIR != $VSCODE_ZDOTDIR ]]; then
131131
ZDOTDIR=$USER_ZDOTDIR
132132
fi
133-
export USER_ALIASES=$(alias)
133+
echo -ne "\x1b]633;UserAliases;$(alias)"

src/vs/workbench/contrib/terminal/browser/media/shellIntegration.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,4 @@ function Set-MappedKeyHandlers {
9292
Set-MappedKeyHandler -Chord Shift+End -Sequence 'F12,d'
9393
}
9494
Set-MappedKeyHandlers
95+
[Console]::Write("`e]633;P;Aliases=$(Get-Alias | Select-Object Name, Definition)`a")

src/vs/workbench/contrib/terminal/browser/remotePty.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export class RemotePty extends Disposable implements ITerminalChildProcess {
3030
private _inReplay = false;
3131

3232
private _properties: IProcessPropertyMap = {
33-
aliases: '',
3433
cwd: '',
3534
initialCwd: '',
3635
fixedDimensions: { cols: undefined, rows: undefined },

src/vs/workbench/contrib/terminal/browser/terminalInstance.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -822,24 +822,6 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
822822
return xterm;
823823
}
824824

825-
private _parseAliases(aliasString: string): string[][] {
826-
const aliases: string[][] = [];
827-
const rows = aliasString.split('\n');
828-
for (const row of rows) {
829-
if (this.shellType === 'zsh') {
830-
aliases.push(row.split('='));
831-
} else if (this.shellType === 'bash') {
832-
// trim off 'alias '
833-
aliases.push(row.substring(6).split('='));
834-
}
835-
}
836-
if (aliases.length) {
837-
this._aliases = aliases;
838-
}
839-
console.log(this._aliases);
840-
return aliases;
841-
}
842-
843825
async runCommand(commandLine: string, addNewLine: boolean): Promise<void> {
844826
// Determine whether to send ETX (ctrl+c) before running the command. This should always
845827
// happen unless command detection can reliably say that a command is being entered and
@@ -1482,11 +1464,6 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
14821464
case ProcessPropertyType.UsedShellIntegrationInjection:
14831465
this._usedShellIntegrationInjection = true;
14841466
break;
1485-
case ProcessPropertyType.Aliases:
1486-
if (value) {
1487-
this._parseAliases(value);
1488-
}
1489-
break;
14901467
}
14911468
});
14921469

0 commit comments

Comments
 (0)