-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What is the rational? #4
Comments
I came here to point this out too. Note that it's also possible to query the dimensions of terminal windows other than the current one: $ stty -f /dev/ttys001 size
$ stty -f "`tty`" size |
"Rationale"? Not (just) trying to be an a**hat, I seriously couldn't figure out what the title meant before opening and thought it was math related. Nonetheless, up-voted. |
I needed it for // x.js
const childProcess = require('child_process');
childProcess.execFile('stty', ['size'], (error, stdout) => {
console.log(error || stdout);
});
|
Try this: const childProcess = require("child_process");
const {stdout: tty} = childProcess.spawnSync("tty", {
stdio: ["inherit", "pipe", "inherit"],
encoding: "utf8",
});
childProcess.execFile("stty", ["-f", tty.trim(), "size"], (error, stdout) => {
console.log(error || stdout);
}); However, it's much easier to use the getters that Node.js provides natively: const size =
process.stdout.isTTY ? [process.stdout.columns, process.stdout.rows] :
process.stderr.isTTY ? [process.stderr.columns, process.stderr.rows] :
process.stdin.isTTY ? [process.stdin.columns, process.stdin.rows] :
null; |
The point of this binary is to get the columns and rows no matter what. |
Not if you're const {stdout: tty} = childProcess.spawnSync("tty", {
- stdio: ["inherit", "pipe", "inherit"],
+ stdio: ["inherit", "pipe", "pipe"],
encoding: "utf8",
}); The |
Closing as this is no longer used by |
I'm curious what use case you had where the terminal size was needed but not available, such as in a non-interactive shell?
BTW, you can use the POSIX standard utility
stty
, on everything but Windows from what I can tell, to get the terminal size.Subwindow of KiTTY
If you just want the cols
iTerm2
tmux in iTerm2
Apple Terminal
The text was updated successfully, but these errors were encountered: