piotrmurach
tty-screen
Ruby

Terminal screen detection - cross platform, major ruby interpreters

Last updated Apr 29, 2026
91
Stars
11
Forks
1
Issues
0
Stars/day
Attention Score
19
Language breakdown
Ruby 99.7%
Shell 0.3%
โ–ธ Files click to expand
README

TTY Toolkit logo

TTY::Screen

[Gem Version][gem] [Actions CI][ghactionsci] [Build status][appveyor] [Code Climate][codeclimate] [Coverage Status][coverage]

[gitter]: https://gitter.im/piotrmurach/tty [gem]: http://badge.fury.io/rb/tty-screen [ghactionsci]: https://github.com/piotrmurach/tty-screen/actions/workflows/ci.yml [appveyor]: https://ci.appveyor.com/project/piotrmurach/tty-screen [codeclimate]: https://codeclimate.com/github/piotrmurach/tty-screen [coverage]: https://coveralls.io/r/piotrmurach/tty-screen

Terminal screen size detection that works on Linux, macOS and Windows systems
and supports Ruby MRI, JRuby, TruffleRuby and Rubinius interpreters.

TTY::Screen provides a terminal screen size detection component for the TTY toolkit.

Installation

Add this line to your application's Gemfile:

gem "tty-screen"

And then execute:

$ bundle

Or install it yourself as:

$ gem install tty-screen

1. Usage

Use the size method to detect terminal screen size. It will result in a [height, width] array:

TTY::Screen.size  # => [51, 280]

Use the width, columns or cols method to detect terminal screen width:

TTY::Screen.width    # => 280
TTY::Screen.columns  # => 280
TTY::Screen.cols     # => 280

Use the height, lines or rows method to detect terminal screen height:

TTY::Screen.height  # => 51
TTY::Screen.lines   # => 51
TTY::Screen.rows    # => 51

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

  • Fork it ( https://github.com/piotrmurach/tty-screen/fork )
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create a new Pull Request

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the TTY::Screen project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Copyright

Copyright (c) 2014 Piotr Murach. See LICENSE.txt for further details.

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท piotrmurach/tty-screen ยท Updated daily from GitHub