對終端視窗大小的變化做出反應

有一個訊號 WINCH(WINdowCHange),當調整終端視窗大小時會觸發。

declare -x rows cols
 
update_size(){
  rows=$(tput lines) # get actual lines of term
  cols=$(tput cols)  # get actual columns of term
  echo DEBUG terminal window has no $rows lines and is $cols characters wide
}

trap update_size WINCH