{"id":3821,"date":"2014-01-06T15:51:30","date_gmt":"2014-01-06T06:51:30","guid":{"rendered":"http:\/\/www.techscore.com\/blog\/?p=3821"},"modified":"2018-11-14T16:33:52","modified_gmt":"2018-11-14T07:33:52","slug":"sigwinch%e3%81%a8tput%e3%81%a7%e9%81%8a%e3%82%93%e3%81%a7%e3%81%bf%e3%82%8b","status":"publish","type":"post","link":"https:\/\/www.techscore.com\/blog\/2014\/01\/06\/sigwinch%e3%81%a8tput%e3%81%a7%e9%81%8a%e3%82%93%e3%81%a7%e3%81%bf%e3%82%8b\/","title":{"rendered":"SIGWINCH\u3068tput\u3067\u904a\u3093\u3067\u307f\u308b"},"content":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u6cb3\u91ce\u3067\u3059\u3002\u65b0\u5e74\u65e9\u3005\u5c0f\u30cd\u30bf\u3067\u3059\u3002<\/p>\n<p>\u5148\u65e5\u4f55\u304b\u306e\u30ed\u30b0\u3092\u773a\u3081\u3066\u3044\u308b\u3068\u304d\u306b\u3001SIGWINCH\u3068\u3044\u3046\u306e\u3092\u898b\u304b\u3051\u307e\u3057\u305f\u3002\u4f55\u304b\u306e\u30b7\u30b0\u30ca\u30eb\u3063\u307d\u3044\u3067\u3059\u3002<\/p>\n<h2>SIGWINCH\u3068\u306f\uff1f<\/h2>\n<p>\u4f55\u304b\u3068\u601d\u3063\u3066\u8abf\u3079\u3066\u307f\u305f\u3089\u3001\u30bf\u30fc\u30df\u30ca\u30eb\u306e\u30b5\u30a4\u30ba\u5909\u66f4\u3092\u77e5\u3089\u305b\u308b\u30b7\u30b0\u30ca\u30eb\u3067\u3057\u305f\u3002<\/p>\n<h2>\u52d5\u4f5c\u78ba\u8a8d\u3057\u3066\u307f\u308b<\/h2>\n<p>bash,zsh\u306b\u306f<\/p>\n<ul>\n<li>LINES<\/li>\n<li>COLUMNS<\/li>\n<\/ul>\n<p>\u3068\u3044\u3046\u74b0\u5883\u5909\u6570\u304c\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u3057\u305f\u3089\u4e0a\u624b\u304f\u53d6\u5f97\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002<\/p>\n<p>\u306a\u306e\u3067\u3001tput\u3068\u3044\u3046\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u3044\u307e\u3059\u3002tput\u3067\u306f\u30bf\u30fc\u30df\u30ca\u30eb\u306e\u60c5\u5831\u304c\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u52d5\u4f5c\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"lang:sh decode:true\">#!\/bin\/bash\r\n\r\nfunction echo_term_size() {\r\n  lines=$(tput lines)\r\n  columns=$(tput cols)\r\n  echo \"SIZE: $lines * $columns\"\r\n}\r\n\r\ntrap 'echo_term_size' SIGWINCH\r\n\r\necho_term_size\r\nwhile true; do\r\n  sleep 1\r\ndone<\/pre>\n<p>\u5b9f\u884c\u3057\u3066\u3001\u30a6\u30a3\u30f3\u30c9\u30a6\u30b5\u30a4\u30ba\u3092\u5909\u66f4\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"lang:sh decode:true\">$ .\/sigwinch_trap.sh\r\nSIZE: 58 * 268\r\nSIZE: 51 * 109\r\nSIZE: 50 * 59\r\nSIZE: 22 * 114\r\nSIZE: 24 * 223\r\nSIZE: 36 * 184\r\n^C<\/pre>\n<p>sleep\u4e2d\u3067\u3082trap\u306f\u5b9f\u884c\u3055\u308c\u308b\u3088\u3046\u3067\u30011\u79d2\u304a\u304d\u306b\u30b5\u30a4\u30ba\u304c\u8868\u793a\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>\u5177\u4f53\u7684\u306a\u4f7f\u3044\u9053\u306f\u5168\u7136\u601d\u3044\u6d6e\u304b\u3070\u306a\u3044\u306e\u3067\u3059\u304c\u3001CUI\u306e\u30a2\u30d7\u30ea\u306a\u3069\u4f5c\u308b\u3068\u304d\u306b\u306f\u4f55\u304b\u4f7f\u3048\u308b\u304b\u3082\u77e5\u308c\u307e\u305b\u3093\u306d\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u6cb3\u91ce\u3067\u3059\u3002\u65b0\u5e74\u65e9\u3005\u5c0f\u30cd\u30bf\u3067\u3059\u3002<\/p>\n<p>\u5148\u65e5\u4f55\u304b\u306e\u30ed\u30b0\u3092\u773a\u3081\u3066\u3044\u308b\u3068\u304d\u306b\u3001SIGWINCH\u3068\u3044\u3046\u306e\u3092\u898b\u304b\u3051\u307e\u3057\u305f\u3002\u4f55\u304b\u306e\u30b7\u30b0\u30ca\u30eb\u3063\u307d\u3044\u3067\u3059\u3002<br \/>\nSIGWINCH\u3068\u306f\uff1f<br \/>\n\u4f55\u304b\u3068\u601d\u3063\u3066\u8abf\u3079\u3066\u307f\u305f\u3089\u3001\u30bf\u30fc\u30df\u30ca\u30eb\u306e\u30b5\u30a4\u30ba\u5909\u66f4\u3092\u77e5\u3089\u305b\u308b\u30b7\u30b0\u30ca\u30eb\u3067\u3057\u305f\u3002<br \/><a href=\"https:\/\/www.techscore.com\/blog\/2014\/01\/06\/sigwinch%e3%81%a8tput%e3%81%a7%e9%81%8a%e3%82%93%e3%81%a7%e3%81%bf%e3%82%8b\/\">\u7d9a\u304d\u3092\u8aad\u3080...<\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[18],"tags":[87,103],"_links":{"self":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/3821"}],"collection":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/comments?post=3821"}],"version-history":[{"count":1,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/3821\/revisions"}],"predecessor-version":[{"id":17888,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/3821\/revisions\/17888"}],"wp:attachment":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/media?parent=3821"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/categories?post=3821"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/tags?post=3821"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}