Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Figure out what the heck the terminal size is

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 pkg
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 Guardfile
Octocat-spinner-32 LICENSE.txt
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 terminal-size.gemspec
README.rdoc

Terminal.size

A tiny gem to accomplish a simple task: Determining the terminal size.

Usage

p Terminal.size # ⇒ {height: 90, width: 161}
p Terminal.size! # to get 80×25 as a fallback instead of nil

Bonus Contract

One of the guarantees of this project is that it will always be exactly one file: `lib/terminal-size/terminal.rb`

So, if you want to come up with some automated way to slurp that into your codebase, it shouldn't break (and this would be better than a not-easily-updated Copy & Paste). I'm kicking around the idea of using this as an example of an automatic, namespaced fat-pack trick, but we'll see if that's really necessary.

Installation

Add this line to your application's Gemfile:

gem 'terminal-size'

And then execute:

$ bundle

Or install it yourself as:

$ gem install terminal-size
Something went wrong with that request. Please try again.