Last active
August 13, 2021 05:24
-
-
Save MauricevanLeeuwen/c51a0a9acfdf5b63e65c58afec3228a5 to your computer and use it in GitHub Desktop.
Use a nodejs repl socket with socat, with correct behaviour of terminal colors, arrow keys, tab key, \r\n on stdout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const repl = require('repl'); | |
const net = require('net'); | |
net.createServer((socket)=>{ | |
var r= repl.start({ | |
prompt: '> ', | |
input: socket, | |
output: socket, | |
terminal: true, | |
useGlobal: false | |
} | |
).on('exit', ()=>{ | |
socket.end(); | |
}) | |
r.context.socket = socket; | |
}).listen('/tmp/some-nodejs-repl.sock'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
socat stdin,rawer!!stdout,rawer,crnl unix-client:/tmp/some-nodejs-repl.sock |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment