Skip to content

Commit d44edd0

Browse files
committed
Support \033 and \x1b when parsing OSC syntax, too
1 parent d473333 commit d44edd0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/lib/promptParser.ts

+8
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ const unparameterized = PROMPT_ELEMENT_TYPES.filter((element) => element.paramet
3535
* @returns The prompt element that was read and the cursor position after that element, or `null` on failure.
3636
*/
3737
function readUnparameterized(ps1: string, cursor: number): { element: PromptElement; newCursor: number } | null {
38+
// manual handling of the 'Set Window Title' element if it uses octal or hexadecimal escape syntax instead of '\e'
39+
if (ps1.startsWith('\\[\\033]0;', cursor) || ps1.startsWith('\\[\\x1b]0;', cursor)) {
40+
return {
41+
element: new PromptElement(getPromptElementTypeByNameUnsafe('Set Window Title')),
42+
newCursor: cursor + 9,
43+
};
44+
}
45+
3846
// eslint-disable-next-line no-restricted-syntax
3947
for (const elementType of unparameterized) {
4048
const char = elementType.char({});

0 commit comments

Comments
 (0)