https://github.com/softprops/termsize
terminal size matters
https://github.com/softprops/termsize
Last synced: about 1 year ago
JSON representation
terminal size matters
- Host: GitHub
- URL: https://github.com/softprops/termsize
- Owner: softprops
- License: mit
- Created: 2015-06-26T05:12:25.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2024-07-22T14:16:12.000Z (almost 2 years ago)
- Last Synced: 2025-04-09T10:49:17.462Z (about 1 year ago)
- Language: Rust
- Homepage:
- Size: 585 KB
- Stars: 18
- Watchers: 3
- Forks: 16
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# termsize
[](https://github.com/softprops/termsize/actions/workflows/ci.yml)
[](https://crates.io/crates/termsize)
> because terminal size matters
Termsize is a rust crate providing a multi-platform interface for resolving
your terminal's current size in rows and columns. On most unix systems, this is similar invoking the [stty(1)](http://man7.org/linux/man-pages/man1/stty.1.html) program, requesting the terminal size.
## [Documentation](https://softprops.github.com/termsize)
## install
run `cargo add termsize` in your terminal or add the following to your `Cargo.toml` file
```toml
[dependencies]
termsize = "0.1"
```
## usage
Termize provides one function, `get`, which returns a `termsize::Size` struct
exposing two fields: `rows` and `cols` representing the number of rows and columns
a a terminal's stdout supports.
```rust
pub fn main() {
termsize::get().map(|{ rows, cols }| {
println!("rows {} cols {}", size.rows, size.cols)
});
}
```
Doug Tangren (softprops) 2015-2024