When you hit ^C during batch scripts they will ask this "Terminate batch job (Y/N)?" question which is super annoying and often the process that the batch script was running has already been killed anyway.
Clink works around this by allowing configuring to auto answer the question and it's really nice. I put together a little prototype and it feels great:

The above was done by translating the terminal line to a string whenever process data comes in and checking if it contains that text. We would want to look into faster alternatives to that and to also ensure we don't answer twice for the same line (just in case):
private _onProcessData(ev: IProcessDataEvent): void {
const messageId = ++this._latestXtermWriteData;
if (ev.trackCommit) {
ev.writePromise = new Promise<void>(r => {
this._xterm?.write(ev.data, () => {
this._latestXtermParseData = messageId;
this._processManager.acknowledgeDataEvent(ev.data.length);
const line = this._xterm?.buffer.active.getLine(this._xterm.buffer.active.baseY + this._xterm.buffer.active.cursorY)?.translateToString(true);
if (line && line.indexOf('Terminate batch job (Y/N)') >= 0) {
this._processManager.write('Y\r').then(() => {
this._onDidInputData.fire(this);
});
}
r();
});
});
} else {
this._xterm?.write(ev.data, () => {
this._latestXtermParseData = messageId;
this._processManager.acknowledgeDataEvent(ev.data.length);
const line = this._xterm?.buffer.active.getLine(this._xterm.buffer.active.baseY + this._xterm.buffer.active.cursorY)?.translateToString(true);
if (line && line.indexOf('Terminate batch job (Y/N)') >= 0) {
this._processManager.write('Y\r').then(() => {
this._onDidInputData.fire(this);
});
}
});
}
}
When you hit
^Cduring batch scripts they will ask this "Terminate batch job (Y/N)?" question which is super annoying and often the process that the batch script was running has already been killed anyway.Clink works around this by allowing configuring to auto answer the question and it's really nice. I put together a little prototype and it feels great:

The above was done by translating the terminal line to a string whenever process data comes in and checking if it contains that text. We would want to look into faster alternatives to that and to also ensure we don't answer twice for the same line (just in case):