Skip to content

Instantly share code, notes, and snippets.

Created January 11, 2016 17:10
Show Gist options
  • Save anonymous/8b6495910a037a27ab84 to your computer and use it in GitHub Desktop.
Save anonymous/8b6495910a037a27ab84 to your computer and use it in GitHub Desktop.
pipe something to ruby and print terminal-width
#!/bin/ruby
require 'pp' # equivalent to data::dumper
# require 'terminfo'
# TermInfo.control("cuf", 7) # cursor forward 7 columns
# p TermInfo.screen_size # use TIOCGWINSZ, LINES/COLUMNS env. or terminfo lines#/cols#
# puts STDIN.winsize
require 'readline';
puts Readline.get_screen_size
puts ENV['COLUMNS']
require 'io/console';
puts STDIN.winsize
require 'curses';
puts Curses.cols
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment