@microsoft/inshellisense 0.0.1-rc.20 → 0.0.1-rc.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  ### Requirements
10
10
 
11
- - Node.js 22.X, 20.X, 18.X, 16.X (16.6.0 >=)
11
+ - Node.js 22.X, 20.X, 18.X
12
12
 
13
13
  ### Installation
14
14
 
@@ -14,7 +14,7 @@ const action = (program) => async (shell, options) => {
14
14
  program.error(`Unsupported shell: '${shell}', supported shells: ${supportedShells}`, { exitCode: 1 });
15
15
  }
16
16
  const config = getShellSourceCommand(shell);
17
- process.stdout.write(`\n\n${config}`);
17
+ process.stdout.write(`\n\n${config}\n`);
18
18
  };
19
19
  const cmd = new Command("init");
20
20
  cmd.description(`generates shell configurations and prints the source command for the specified shell`);
@@ -1,34 +1,28 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
3
  import convert from "color-convert";
4
- import os from "node:os";
5
4
  import { getShellPromptRewrites, Shell } from "../utils/shell.js";
6
5
  import log from "../utils/log.js";
7
- const maxPromptPollDistance = 10;
8
6
  export class CommandManager {
9
7
  #activeCommand;
10
8
  #terminal;
11
- #previousCommandLines;
9
+ #acceptedCommandLines;
12
10
  #maxCursorY;
13
11
  #shell;
14
12
  #promptRewrites;
15
- #supportsProperOscPlacements = os.platform() !== "win32";
16
- promptTerminator = "";
17
13
  constructor(terminal, shell) {
18
14
  this.#terminal = terminal;
19
15
  this.#shell = shell;
20
16
  this.#activeCommand = {};
21
17
  this.#maxCursorY = 0;
22
- this.#previousCommandLines = new Set();
18
+ this.#acceptedCommandLines = new Set();
23
19
  this.#promptRewrites = getShellPromptRewrites(shell);
24
- if (this.#supportsProperOscPlacements) {
25
- this.#terminal.parser.registerCsiHandler({ final: "J" }, (params) => {
26
- if (params.at(0) == 3 || params.at(0) == 2) {
27
- this.handleClear();
28
- }
29
- return false;
30
- });
31
- }
20
+ this.#terminal.parser.registerCsiHandler({ final: "J" }, (params) => {
21
+ if (params.at(0) == 3 || params.at(0) == 2) {
22
+ this.handleClear();
23
+ }
24
+ return false;
25
+ });
32
26
  }
33
27
  handlePromptStart() {
34
28
  this.#activeCommand = { promptStartMarker: this.#terminal.registerMarker(0), hasOutput: false, cursorTerminated: false };
@@ -36,110 +30,25 @@ export class CommandManager {
36
30
  handlePromptEnd() {
37
31
  if (this.#activeCommand.promptEndMarker != null)
38
32
  return;
33
+ if (this.#hasBeenAccepted()) {
34
+ this.#activeCommand = {};
35
+ return;
36
+ }
39
37
  this.#activeCommand.promptEndMarker = this.#terminal.registerMarker(0);
40
38
  if (this.#activeCommand.promptEndMarker?.line === this.#terminal.buffer.active.cursorY) {
41
39
  this.#activeCommand.promptEndX = this.#terminal.buffer.active.cursorX;
42
40
  }
43
- if (this.#supportsProperOscPlacements) {
44
- this.#activeCommand.promptText = this.#terminal.buffer.active.getLine(this.#activeCommand.promptEndMarker?.line ?? 0)?.translateToString(true);
45
- this.#previousCommandLines.add(this.#activeCommand.promptEndMarker?.line ?? -1);
46
- }
41
+ this.#activeCommand.promptText = this.#terminal.buffer.active.getLine(this.#activeCommand.promptEndMarker?.line ?? 0)?.translateToString(true);
42
+ }
43
+ #hasBeenAccepted() {
44
+ const commandLine = this.#activeCommand.promptStartMarker?.line ?? -1;
45
+ const hasBeenAccepted = this.#acceptedCommandLines.has(commandLine) && commandLine != -1;
46
+ return this.#promptRewrites && hasBeenAccepted; // this is a prompt + command that was accepted and is now being re-written by the shell for display purposes (e.g. nu)
47
47
  }
48
48
  handleClear() {
49
49
  this.handlePromptStart();
50
50
  this.#maxCursorY = 0;
51
- this.#previousCommandLines = new Set();
52
- }
53
- _getWindowsPrompt(y) {
54
- const line = this.#terminal.buffer.active.getLine(y);
55
- if (!line) {
56
- return;
57
- }
58
- const lineText = line.translateToString(true);
59
- if (!lineText) {
60
- return;
61
- }
62
- // dynamic prompt terminator
63
- if (this.promptTerminator && lineText.trim().endsWith(this.promptTerminator)) {
64
- const adjustedPrompt = this._adjustPrompt(lineText, lineText, this.promptTerminator);
65
- if (adjustedPrompt) {
66
- return adjustedPrompt;
67
- }
68
- }
69
- // User defined prompt
70
- if (this.#shell == Shell.Bash) {
71
- const bashPrompt = lineText.match(/^(?<prompt>\$\s?)/)?.groups?.prompt;
72
- if (bashPrompt) {
73
- const adjustedPrompt = this._adjustPrompt(bashPrompt, lineText, "$");
74
- if (adjustedPrompt) {
75
- return adjustedPrompt;
76
- }
77
- }
78
- }
79
- if (this.#shell == Shell.Fish) {
80
- const fishPrompt = lineText.match(/(?<prompt>.*>\s?)/)?.groups?.prompt;
81
- if (fishPrompt) {
82
- const adjustedPrompt = this._adjustPrompt(fishPrompt, lineText, ">");
83
- if (adjustedPrompt) {
84
- return adjustedPrompt;
85
- }
86
- }
87
- }
88
- if (this.#shell == Shell.Nushell) {
89
- const nushellPrompt = lineText.match(/(?<prompt>.*>\s?)/)?.groups?.prompt;
90
- if (nushellPrompt) {
91
- const adjustedPrompt = this._adjustPrompt(nushellPrompt, lineText, ">");
92
- if (adjustedPrompt) {
93
- return adjustedPrompt;
94
- }
95
- }
96
- }
97
- if (this.#shell == Shell.Xonsh) {
98
- let xonshPrompt = lineText.match(/(?<prompt>.*@\s?)/)?.groups?.prompt;
99
- if (xonshPrompt) {
100
- const adjustedPrompt = this._adjustPrompt(xonshPrompt, lineText, "@");
101
- if (adjustedPrompt) {
102
- return adjustedPrompt;
103
- }
104
- }
105
- xonshPrompt = lineText.match(/(?<prompt>.*>\s?)/)?.groups?.prompt;
106
- if (xonshPrompt) {
107
- const adjustedPrompt = this._adjustPrompt(xonshPrompt, lineText, ">");
108
- if (adjustedPrompt) {
109
- return adjustedPrompt;
110
- }
111
- }
112
- }
113
- if (this.#shell == Shell.Powershell || this.#shell == Shell.Pwsh) {
114
- const pwshPrompt = lineText.match(/(?<prompt>(\(.+\)\s)?(?:PS.+>\s?))/)?.groups?.prompt;
115
- if (pwshPrompt) {
116
- const adjustedPrompt = this._adjustPrompt(pwshPrompt, lineText, ">");
117
- if (adjustedPrompt) {
118
- return adjustedPrompt;
119
- }
120
- }
121
- }
122
- if (this.#shell == Shell.Cmd) {
123
- return lineText.match(/^(?<prompt>(\(.+\)\s)?(?:[A-Z]:\\.*>)|(> ))/)?.groups?.prompt;
124
- }
125
- // Custom prompts like starship end in the common \u276f character
126
- const customPrompt = lineText.match(/.*\u276f(?=[^\u276f]*$)/g)?.[0];
127
- if (customPrompt) {
128
- const adjustedPrompt = this._adjustPrompt(customPrompt, lineText, "\u276f");
129
- if (adjustedPrompt) {
130
- return adjustedPrompt;
131
- }
132
- }
133
- }
134
- _adjustPrompt(prompt, lineText, char) {
135
- if (!prompt) {
136
- return;
137
- }
138
- // Conpty may not 'render' the space at the end of the prompt
139
- if (lineText === prompt && prompt.endsWith(char)) {
140
- prompt += " ";
141
- }
142
- return prompt;
51
+ this.#acceptedCommandLines.clear();
143
52
  }
144
53
  _getFgPaletteColor(cell) {
145
54
  if (cell?.isFgDefault())
@@ -170,6 +79,7 @@ export class CommandManager {
170
79
  };
171
80
  }
172
81
  clearActiveCommand() {
82
+ this.#acceptedCommandLines.add(this.#activeCommand.promptEndMarker?.line ?? -1);
173
83
  this.#activeCommand = {};
174
84
  }
175
85
  _getCommandLines() {
@@ -241,7 +151,6 @@ export class CommandManager {
241
151
  return;
242
152
  }
243
153
  const globalCursorPosition = this.#terminal.buffer.active.baseY + this.#terminal.buffer.active.cursorY;
244
- const withinPollDistance = globalCursorPosition < this.#activeCommand.promptEndMarker.line + 5;
245
154
  this.#maxCursorY = Math.max(this.#maxCursorY, globalCursorPosition);
246
155
  if (globalCursorPosition < this.#activeCommand.promptStartMarker.line || globalCursorPosition < this.#maxCursorY) {
247
156
  this.handleClear();
@@ -250,21 +159,6 @@ export class CommandManager {
250
159
  }
251
160
  if (this.#activeCommand.promptEndMarker == null)
252
161
  return;
253
- // if we haven't fond the prompt yet, poll over the next 5 lines searching for it
254
- if (this.#activeCommand.promptText == null && withinPollDistance) {
255
- for (let i = globalCursorPosition; i < this.#activeCommand.promptEndMarker.line + maxPromptPollDistance; i++) {
256
- if (this.#previousCommandLines.has(i) && !this.#promptRewrites)
257
- continue;
258
- const promptResult = this._getWindowsPrompt(i);
259
- if (promptResult != null) {
260
- this.#activeCommand.promptEndMarker = this.#terminal.registerMarker(i - globalCursorPosition);
261
- this.#activeCommand.promptEndX = promptResult.length;
262
- this.#activeCommand.promptText = promptResult;
263
- this.#previousCommandLines.add(i);
264
- break;
265
- }
266
- }
267
- }
268
162
  // if the prompt is set, now parse out the values from the terminal
269
163
  if (this.#activeCommand.promptText != null) {
270
164
  const commandLines = this._getCommandLines();
@@ -41,6 +41,8 @@ export class ISTerm {
41
41
  rows,
42
42
  cwd: process.cwd(),
43
43
  env: { ...convertToPtyEnv(shell, underTest, login), ...env },
44
+ useConpty: true,
45
+ useConptyDll: true,
44
46
  });
45
47
  this.pid = this.#pty.pid;
46
48
  this.cols = this.#pty.cols;
@@ -112,19 +114,6 @@ export class ISTerm {
112
114
  }
113
115
  break;
114
116
  }
115
- case IstermOscPt.Prompt: {
116
- const prompt = data.split(";").slice(1).join(";");
117
- if (prompt != null) {
118
- const sanitizedPrompt = this._sanitizedPrompt(this._deserializeIsMessage(prompt));
119
- const lastPromptLine = sanitizedPrompt.substring(sanitizedPrompt.lastIndexOf("\n")).trim();
120
- const promptTerminator = lastPromptLine.substring(lastPromptLine.lastIndexOf(" ")).trim();
121
- if (promptTerminator) {
122
- this.#commandManager.promptTerminator = promptTerminator;
123
- log.debug({ msg: "prompt terminator", promptTerminator });
124
- }
125
- }
126
- break;
127
- }
128
117
  default:
129
118
  return false;
130
119
  }
@@ -10,7 +10,12 @@ const platform = os.platform();
10
10
  const executeShellCommand = await buildExecuteShellCommand(5000);
11
11
  const loadBashAliases = async () => {
12
12
  const shellTarget = platform == "win32" ? await gitBashPath() : Shell.Bash;
13
- const { stdout, stderr, status } = await executeShellCommand({ command: shellTarget, args: ["-i", "-c", "alias"], cwd: process.cwd(), env: { ISTERM: "1" } });
13
+ const { stdout, stderr, status } = await executeShellCommand({
14
+ command: `'${shellTarget}'`,
15
+ args: ["-i", "-c", "alias"],
16
+ cwd: process.cwd(),
17
+ env: { ISTERM: "1" },
18
+ });
14
19
  if (status !== 0) {
15
20
  log.debug({ msg: "failed to load bash aliases", stderr, status });
16
21
  return;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6
+ return new (P || (P = Promise))(function (resolve, reject) {
7
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
8
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
9
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
10
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
11
+ });
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.getDiffVersionedSpeclist = exports.getSpeclist = void 0;
15
+ let speclist = undefined;
16
+ let versionedSpeclist = undefined;
17
+ const getSpeclist = () => __awaiter(void 0, void 0, void 0, function* () {
18
+ if (!speclist) {
19
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
20
+ // @ts-ignore
21
+ const autocomplete = yield import("@withfig/autocomplete/build/index.js");
22
+ speclist = autocomplete.default;
23
+ }
24
+ return speclist;
25
+ });
26
+ exports.getSpeclist = getSpeclist;
27
+ const getDiffVersionedSpeclist = () => __awaiter(void 0, void 0, void 0, function* () {
28
+ if (!versionedSpeclist) {
29
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
30
+ // @ts-ignore
31
+ const autocomplete = yield import("@withfig/autocomplete/build/index.js");
32
+ versionedSpeclist = autocomplete.diffVersionedCompletions;
33
+ }
34
+ return versionedSpeclist;
35
+ });
36
+ exports.getDiffVersionedSpeclist = getDiffVersionedSpeclist;
@@ -6,7 +6,7 @@ import chalk from "chalk";
6
6
  import log from "../utils/log.js";
7
7
  import { getBackspaceSequence } from "../utils/shell.js";
8
8
  import isterm from "../isterm/index.js";
9
- import { eraseLinesBelow } from "../utils/ansi.js";
9
+ import { eraseLinesBelow, resetToInitialState } from "../utils/ansi.js";
10
10
  import { SuggestionManager, MAX_LINES } from "./suggestionManager.js";
11
11
  export const renderConfirmation = (live) => {
12
12
  const statusMessage = live ? chalk.green("live") : chalk.red("not found");
@@ -17,6 +17,7 @@ export const render = async (program, shell, underTest, login) => {
17
17
  const suggestionManager = new SuggestionManager(term, shell);
18
18
  let hasActiveSuggestions = false;
19
19
  let previousSuggestionsRows = 0;
20
+ const stdinStartedInRawMode = process.stdin.isRaw;
20
21
  if (process.stdin.isTTY)
21
22
  process.stdin.setRawMode(true);
22
23
  readline.emitKeypressEvents(process.stdin);
@@ -129,6 +130,9 @@ export const render = async (program, shell, underTest, login) => {
129
130
  }
130
131
  });
131
132
  term.onExit(({ exitCode }) => {
133
+ if (!stdinStartedInRawMode)
134
+ process.stdin.setRawMode(false);
135
+ process.stdout.write(resetToInitialState);
132
136
  process.exit(exitCode);
133
137
  });
134
138
  process.stdout.on("resize", () => {
@@ -11,7 +11,6 @@ export var IstermOscPt;
11
11
  IstermOscPt["PromptStarted"] = "PS";
12
12
  IstermOscPt["PromptEnded"] = "PE";
13
13
  IstermOscPt["CurrentWorkingDirectory"] = "CWD";
14
- IstermOscPt["Prompt"] = "PROMPT";
15
14
  })(IstermOscPt || (IstermOscPt = {}));
16
15
  export const IstermPromptStart = IS_OSC + IstermOscPt.PromptStarted + BEL;
17
16
  export const IstermPromptEnd = IS_OSC + IstermOscPt.PromptEnded + BEL;
@@ -21,6 +20,7 @@ export const cursorNextLine = CSI + "E";
21
20
  export const eraseLine = CSI + "2K";
22
21
  export const resetColor = CSI + "0m";
23
22
  export const resetLine = CSI + "2K";
23
+ export const resetToInitialState = ESC + "c"; // RIS - Reset to Initial State
24
24
  export const cursorBackward = (count = 1) => CSI + count + "D";
25
25
  export const cursorForward = (count = 1) => CSI + count + "C";
26
26
  export const cursorTo = ({ x, y }) => {
@@ -18,18 +18,6 @@ const bindingSchema = {
18
18
  },
19
19
  required: ["key"],
20
20
  };
21
- const promptPatternsSchema = {
22
- type: "array",
23
- nullable: true,
24
- items: {
25
- type: "object",
26
- properties: {
27
- regex: { type: "string" },
28
- postfix: { type: "string" },
29
- },
30
- required: ["regex", "postfix"],
31
- },
32
- };
33
21
  const specPathsSchema = {
34
22
  type: "array",
35
23
  items: { type: "string" },
@@ -49,19 +37,6 @@ const configSchema = {
49
37
  acceptSuggestion: bindingSchema,
50
38
  },
51
39
  },
52
- // DEPRECATED: prompt patterns are no longer used
53
- prompt: {
54
- type: "object",
55
- nullable: true,
56
- properties: {
57
- bash: promptPatternsSchema,
58
- pwsh: promptPatternsSchema,
59
- powershell: promptPatternsSchema,
60
- xonsh: promptPatternsSchema,
61
- nu: promptPatternsSchema,
62
- fish: promptPatternsSchema,
63
- },
64
- },
65
40
  specs: {
66
41
  type: "object",
67
42
  nullable: true,
@@ -109,14 +84,6 @@ export const loadConfig = async (program) => {
109
84
  acceptSuggestion: config?.bindings?.acceptSuggestion ?? globalConfig.bindings.acceptSuggestion,
110
85
  dismissSuggestions: config?.bindings?.dismissSuggestions ?? globalConfig.bindings.dismissSuggestions,
111
86
  },
112
- prompt: {
113
- bash: config.prompt?.bash ?? globalConfig?.prompt?.bash,
114
- powershell: config.prompt?.powershell ?? globalConfig?.prompt?.powershell,
115
- xonsh: config.prompt?.xonsh ?? globalConfig?.prompt?.xonsh,
116
- pwsh: config.prompt?.pwsh ?? globalConfig?.prompt?.pwsh,
117
- nu: config.prompt?.nu ?? globalConfig?.prompt?.nu,
118
- fish: config.prompt?.fish ?? globalConfig?.prompt?.fish,
119
- },
120
87
  specs: {
121
88
  path: [...(config?.specs?.path ?? []), ...(config?.specs?.path ?? [])],
122
89
  },
@@ -82,8 +82,9 @@ export const checkShellConfigPlugin = async () => {
82
82
  const profilePath = await getProfilePath(shell);
83
83
  if (profilePath != null && fs.existsSync(profilePath)) {
84
84
  const profile = await fsAsync.readFile(profilePath, "utf8");
85
- const profileContainsSource = profile.includes(getShellSourceCommand(shell));
86
- const profileEndsWithSource = profile.trimEnd().endsWith(getShellSourceCommand(shell));
85
+ const shellSourceCommand = getShellSourceCommand(shell).trim();
86
+ const profileContainsSource = profile.includes(shellSourceCommand);
87
+ const profileEndsWithSource = profile.trimEnd().endsWith(shellSourceCommand);
87
88
  if (!profileContainsSource) {
88
89
  shellsWithoutPlugin.push(shell);
89
90
  }
@@ -243,16 +244,17 @@ export const getPathDirname = (dir, shell) => {
243
244
  const pathSep = getPathSeparator(shell);
244
245
  return dir.endsWith(pathSep) || path.dirname(dir) == "." ? dir : addPathSeparator(path.dirname(dir), shell);
245
246
  };
246
- // nu fully re-writes the prompt every keystroke resulting in duplicate start/end sequences on the same line
247
- export const getShellPromptRewrites = (shell) => shell == Shell.Nushell;
247
+ // nu fully re-writes the prompt every keystroke resulting in duplicate start/end sequences on the same line & re-writes the prompt after accepting a command
248
+ // xonsh re-writes the prompt after accepting a command
249
+ export const getShellPromptRewrites = (shell) => shell == Shell.Nushell || shell == Shell.Xonsh;
248
250
  export const getShellSourceCommand = (shell) => {
249
251
  switch (shell) {
250
252
  case Shell.Bash:
251
253
  return `[ -f ~/.inshellisense/bash/init.sh ] && source ~/.inshellisense/bash/init.sh`;
252
254
  case Shell.Powershell:
253
- return `if ( Test-Path '~/.inshellisense/powershell/init.ps1' -PathType Leaf ) { . ~/.inshellisense/powershell/init.ps1 } `;
255
+ return `if ( Test-Path '~/.inshellisense/powershell/init.ps1' -PathType Leaf ) { . ~/.inshellisense/powershell/init.ps1 }`;
254
256
  case Shell.Pwsh:
255
- return `if ( Test-Path '~/.inshellisense/pwsh/init.ps1' -PathType Leaf ) { . ~/.inshellisense/pwsh/init.ps1 } `;
257
+ return `if ( Test-Path '~/.inshellisense/pwsh/init.ps1' -PathType Leaf ) { . ~/.inshellisense/pwsh/init.ps1 }`;
256
258
  case Shell.Zsh:
257
259
  return `[[ -f ~/.inshellisense/zsh/init.zsh ]] && source ~/.inshellisense/zsh/init.zsh`;
258
260
  case Shell.Fish:
@@ -260,7 +262,7 @@ export const getShellSourceCommand = (shell) => {
260
262
  case Shell.Xonsh:
261
263
  return `p"~/.inshellisense/xonsh/init.xsh".exists() && source "~/.inshellisense/xonsh/init.xsh"`;
262
264
  case Shell.Nushell:
263
- return `if ( '~/.inshellisense/nu/init.nu' | path exists ) { source ~/.inshellisense/nu/init.nu } `;
265
+ return `if ( '~/.inshellisense/nu/init.nu' | path exists ) { source ~/.inshellisense/nu/init.nu }`;
264
266
  }
265
267
  return "";
266
268
  };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@microsoft/inshellisense",
3
- "version": "0.0.1-rc.20",
3
+ "version": "0.0.1-rc.21",
4
4
  "description": "IDE style command line auto complete",
5
5
  "type": "module",
6
6
  "engines": {
7
- "node": ">=16.6.0 <23.0.0"
7
+ "node": ">=18.0 <23.0.0"
8
8
  },
9
9
  "bin": {
10
10
  "inshellisense": "./build/index.js",
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "homepage": "https://github.com/microsoft/inshellisense#readme",
44
44
  "dependencies": {
45
- "@homebridge/node-pty-prebuilt-multiarch": "^0.11.14",
45
+ "@homebridge/node-pty-prebuilt-multiarch": "0.12.1-beta.0",
46
46
  "@withfig/autocomplete": "2.675.0",
47
47
  "@xterm/addon-unicode11": "^0.8.0",
48
48
  "@xterm/headless": "^5.5.0",
@@ -60,16 +60,6 @@ __is_update_cwd() {
60
60
  builtin printf '\e]6973;CWD;%s\a' "$(__is_escape_value "$PWD")"
61
61
  }
62
62
 
63
- __is_report_prompt() {
64
- if ((BASH_VERSINFO[0] >= 4)); then
65
- __is_prompt=${__is_original_PS1@P}
66
- else
67
- __is_prompt=${__is_original_PS1}
68
- fi
69
- __is_prompt="$(builtin printf "%s" "${__is_prompt//[$'\001'$'\002']}")"
70
- builtin printf "\e]6973;PROMPT;%s\a" "$(__is_escape_value "${__is_prompt}")"
71
- }
72
-
73
63
  if [[ -n "${bash_preexec_imported:-}" ]]; then
74
64
  precmd_functions+=(__is_precmd)
75
65
  fi
@@ -77,7 +67,6 @@ fi
77
67
  __is_precmd() {
78
68
  __is_update_cwd
79
69
  __is_update_prompt
80
- __is_report_prompt
81
70
  }
82
71
 
83
72
  __is_update_prompt() {
@@ -14,7 +14,6 @@ function __is_escape_value
14
14
  ;
15
15
  end
16
16
  function __is_update_cwd --on-event fish_prompt; set __is_cwd (__is_escape_value "$PWD"); printf "\e]6973;CWD;%s\a" $__is_cwd; end
17
- function __is_report_prompt --on-event fish_prompt; set __is_prompt (__is_escape_value (is_user_prompt)); printf "\e]6973;PROMPT;%s\a" $__is_prompt; end
18
17
 
19
18
  if [ "$ISTERM_TESTING" = "1" ]
20
19
  function is_user_prompt; printf '> '; end
@@ -6,21 +6,14 @@ let __is_update_cwd = {
6
6
  let pwd = do $__is_escape_value $env.PWD
7
7
  $"\e]6973;CWD;($pwd)\a"
8
8
  }
9
- let __is_report_prompt = {
10
- let __is_indicatorCommandType = $__is_original_PROMPT_INDICATOR | describe
11
- mut __is_prompt_ind = if $__is_indicatorCommandType == "closure" { do $__is_original_PROMPT_INDICATOR } else { $__is_original_PROMPT_INDICATOR }
12
- let __is_esc_prompt_ind = do $__is_escape_value $__is_prompt_ind
13
- $"\e]6973;PROMPT;($__is_esc_prompt_ind)\a"
14
- }
15
9
  let __is_custom_PROMPT_COMMAND = {
16
10
  let promptCommandType = $__is_original_PROMPT_COMMAND | describe
17
11
  mut cmd = if $promptCommandType == "closure" { do $__is_original_PROMPT_COMMAND } else { $__is_original_PROMPT_COMMAND }
18
12
  let pwd = do $__is_update_cwd
19
- let prompt = do $__is_report_prompt
20
13
  if 'ISTERM_TESTING' in $env {
21
14
  $cmd = ""
22
15
  }
23
- $"\e]6973;PS\a($cmd)($pwd)($prompt)"
16
+ $"\e]6973;PS\a($cmd)($pwd)"
24
17
  }
25
18
  $env.PROMPT_COMMAND = $__is_custom_PROMPT_COMMAND
26
19
 
@@ -21,7 +21,6 @@ function Global:Prompt() {
21
21
  $Result += $OriginalPrompt
22
22
  $Result += "$([char]0x1b)]6973;PE`a"
23
23
 
24
- $Result += "$([char]0x1b)]6973;PROMPT;$(__IS-Escape-Value $OriginalPrompt)`a"
25
24
  $Result += if ($pwd.Provider.Name -eq 'FileSystem') { "$([char]0x1b)]6973;CWD;$(__IS-Escape-Value $pwd.ProviderPath)`a" }
26
25
  return $Result
27
26
  }
@@ -18,20 +18,14 @@ def __is_escape_value(value: str) -> str:
18
18
  )
19
19
 
20
20
  def __is_update_cwd() -> str:
21
- return f"\x1b]6973;CWD;{__is_escape_value(os.getcwd())}\x07"
21
+ return f"\x1b]6973;CWD;{__is_escape_value(os.getcwd())}\x07" + "\002"
22
22
 
23
23
  __is_original_prompt = $PROMPT
24
- def __is_report_prompt() -> str:
25
- prompt = ""
26
- formatted_prompt = XSH.shell.prompt_formatter(__is_original_prompt)
27
- prompt = "".join([text for _, text in XSH.shell.format_color(formatted_prompt)])
28
- return f"\x1b]6973;PROMPT;{__is_escape_value(prompt)}\x07" + "\002"
29
24
 
30
25
  $PROMPT_FIELDS['__is_prompt_start'] = __is_prompt_start
31
26
  $PROMPT_FIELDS['__is_prompt_end'] = __is_prompt_end
32
27
  $PROMPT_FIELDS['__is_update_cwd'] = __is_update_cwd
33
- $PROMPT_FIELDS['__is_report_prompt'] = __is_report_prompt
34
28
  if 'ISTERM_TESTING' in ${...}:
35
29
  $PROMPT = "> "
36
30
 
37
- $PROMPT = "{__is_prompt_start}{__is_update_cwd}{__is_report_prompt}" + $PROMPT + "{__is_prompt_end}"
31
+ $PROMPT = "{__is_prompt_start}{__is_update_cwd}" + $PROMPT + "{__is_prompt_end}"
package/todo.md ADDED
@@ -0,0 +1,17 @@
1
+ - [x] convert source code to commonjs
2
+ - [x] convert deps to commonjs (fig/autocomplete is esm)
3
+ - [ ] convert requires to SEA requires
4
+ - [ ] swap over to node-pty
5
+ - [ ] build for SEA
6
+
7
+ esbuild build/index.js --bundle --platform=node --outdir=bundle --format=cjs --external:node-pty
8
+ node scripts/require.js
9
+
10
+
11
+ replace `../build/Debug/pty.node` with ``
12
+
13
+ node --experimental-sea-config sea-config.json
14
+ node -e "require('fs').copyFileSync(process.execPath, 'hello.exe')"
15
+ signtool remove /s hello.exe
16
+ npx postject hello.exe NODE_SEA_BLOB sea-prep.blob `
17
+ --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2