Advertisement
Guest User

Untitled

a guest
Sep 27th, 2014
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. tput lines
  2. tput cols
  3.  
  4. echo $LINES
  5. echo $COLUMNS
  6.  
  7. stty size
  8. stty size | awk '{print $1}' # lines
  9. stty size | awk '{print $NF}' # columns
  10.  
  11. stty size | cut -d" " -f1 # lines
  12. stty size | cut -d" " -f2 # columns
  13.  
  14. stty -a | awk '/rows/ {print $4}' # lines
  15. stty -a | awk '/columns/ {print $6}' # columns
  16.  
  17. stty -a | sed -E -n -e 's/^.*[^[:digit:]]([[:digit:]]+)[[:space:]]+rows;.*$/1/p;q;'
  18. stty -a | sed -E -n -e 's/^.*[^[:digit:]]([[:digit:]]+)[[:space:]]+columns;.*$/1/p;q;'
  19.  
  20.  
  21.  
  22. # automatically resize the Terminal window if it gets smaller than the default size
  23.  
  24. # positive integer test (including zero)
  25. function positive_int() { return $(test "$@" -eq "$@" > /dev/null 2>&1 && test "$@" -ge 0 > /dev/null 2>&1); }
  26.  
  27.  
  28. # resize the Terminal window
  29. function sizetw() {
  30. if [[ $# -eq 2 ]] && $(positive_int "$1") && $(positive_int "$2"); then
  31. printf "e[8;${1};${2};t"
  32. return 0
  33. fi
  34. return 1
  35. }
  36.  
  37.  
  38. # the default Terminal window size: 26 lines and 107 columns
  39. sizetw 26 107
  40.  
  41.  
  42. # automatically adjust Terminal window size
  43. function defaultwindow() {
  44.  
  45. DEFAULTLINES=26
  46. DEFAULTCOLUMNS=107
  47.  
  48. if [[ $(/usr/bin/tput lines) -lt $DEFAULTLINES ]] && [[ $(/usr/bin/tput cols) -lt $DEFAULTCOLUMNS ]]; then
  49. sizetw $DEFAULTLINES $DEFAULTCOLUMNS
  50. elif [[ $(/usr/bin/tput lines) -lt $DEFAULTLINES ]]; then
  51. sizetw $DEFAULTLINES $(/usr/bin/tput cols)
  52. elif [[ $(/usr/bin/tput cols) -lt $DEFAULTCOLUMNS ]]; then
  53. sizetw $(/usr/bin/tput lines) $DEFAULTCOLUMNS
  54. fi
  55.  
  56. return 0
  57. }
  58.  
  59.  
  60. # SIGWINCH is the window change signal
  61. trap defaultwindow SIGWINCH
  62.  
  63.  
  64. sizetw 26 70
  65. sizetw 10 107
  66. sizetw 4 15
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement