How do I find the width & height of a terminal window?

前端 未结 9 1086
滥情空心
滥情空心 2020-12-04 04:33

As a simple example, I want to write a CLI script which can print = across the entire width of the terminal window.

#!/usr/bin/env php


        
9条回答
  •  北荒
    北荒 (楼主)
    2020-12-04 05:20

    In bash, the $LINES and $COLUMNS environmental variables should be able to do the trick. The will be set automatically upon any change in the terminal size. (i.e. the SIGWINCH signal)

提交回复
热议问题