ttyd
ttyd copied to clipboard
Have window close upon disconnect
Suppose a ttyd is started and executes the 'bash' command. When the user types 'exit' the connection closes and user is prompted to hit Enter to reconnect. Instead, when user types 'exit' the window should be closed - how to accomplish this? thank you
It's not supported yet.
Ok thanks. What we do for now is apply this patch and then rebuild the 'html.h' file.
diff --git a/html/src/components/terminal/xterm/index.ts b/html/src/components/terminal/xterm/index.ts
index e6809e4..c7b377f 100644
--- a/html/src/components/terminal/xterm/index.ts
+++ b/html/src/components/terminal/xterm/index.ts
@@ -269,7 +269,9 @@ export class Xterm {
this.dispose();
// 1000: CLOSE_NORMAL
- if (event.code !== 1000 && doReconnect) {
+ if (event.code === 1000 || event.code === 1006) {
+ window.close();
+ } else if (event.code !== 1000 && doReconnect) {
overlayAddon.showOverlay('Reconnecting...');
refreshToken().then(connect);
} else {
This is from git checkout tags/1.7.3
btw: when we build 'ttyd' using latest code, the terminal does not accept any input, meaning anything you type just doesn't get sent.
btw: when we build 'ttyd' using latest code, the terminal does not accept any input, meaning anything you type just doesn't get sent.
Start ttyd with -W
option.