I want to print columnar output from a ruby program, but in order to take full advantage of the available screen space, I need to determine the character width of the terminal the program is running in. How does one do this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The HighLine gem uses this function to find the dimensions of a terminal:
This method should work also on Windows, if you use Linux (or something similar) only then you can use
stty sizeto find the dimensions more easily using something like: