Created
May 9, 2014 17:38
-
-
Save TooTallNate/59089e2b9516a32c5525 to your computer and use it in GitHub Desktop.
A little script to play the ASCII Star Wars, but with a hidden cursor, since over `telnet(1)` the cursor remains visible which is annoying
This file contains 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
#!/usr/bin/env node | |
/** | |
* A little script to play the ASCII Star Wars, but with a hidden cursor, | |
* since over `telnet(1)` the cursor remains visible which is annoying. | |
*/ | |
process.title = 'starwars' | |
var net = require('net') | |
, cursor = require('ansi')(process.stdout) | |
, color = process.argv[2] | |
// enable "raw mode" so that keystrokes aren't visible | |
process.stdin.resume() | |
if (process.stdin.setRawMode) { | |
process.stdin.setRawMode(true) | |
} else { | |
require('tty').setRawMode(true) | |
} | |
// connect to the ASCII Star Wars server | |
var socket = net.connect(23, 'towel.blinkenlights.nl') | |
socket.on('connect', function () { | |
if (color in cursor.fg) { | |
cursor.fg[color]() | |
} | |
cursor.hide() | |
socket.pipe(process.stdout) | |
}) | |
process.stdin.on('data', function (data) { | |
if (data.toString() === '\u0003') { | |
// Ctrl+C; a.k.a SIGINT | |
socket.destroy() | |
process.stdin.pause() | |
} | |
}) | |
process.on('exit', function () { | |
cursor | |
.show() | |
.fg.reset() | |
.write('\n') | |
}) |
montanaflynn
commented
Oct 23, 2014
Check this:
#!/usr/bin/env bash
tput civis -- invisible && telnet towel.blinkenlights.nl 23
It does the same thing. :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment