A stupid little program that prints the size of your terminal
- GCC
- Make
Run make
.
I just have a symlink in my scripts folder that points to target/release/winsz
.
Run winsz
in your terminal.
Yes and no.
Yes because "[w]indow sizes are kept in the kernel, but not used by the kernel", so they have to be retrieved using a system call—an ioctl to be more specific—and the ioctl for getting the size of a terminal window is TIOCGWINSZ
(Terminal Input/Output Control Get WINdow SiZe). It's all just so Unix that it feels like a parody.
No because I made this while I was bored and wanted to play around with how to structure a C project.
I definitely could have but for something so simple and fool-proof I didn't wanna make a whole new Cargo project. I figured it'd be painless enough to just do in C. Besides, calling ioctls in Rust would require 👻 unsafe code 👻
It is literally 40 lines of C. You can probably fix it yourself.
It's all in the man pages:
man ioctl
man ioctl_tty
man termios
Poke around these and their "SEE ALSO"s, Google some stuff. You know how it goes.