Yuichiro_S の Twitterでは文字数が足りないもの

Twitterに書くには向いてないことを書きます。文字数制限だとか、検索に引っかからないだとか、流れてしまって読んでもらえないだとか。

tmuxでペインの表示が更新されなくなる問題と端末のリセット

バイナリファイルを標準出力に投げてしまって端末エミュレータの表示がぶっ壊れるということがありますが、 tmuxでペインの表示が更新されなくなるときにもこれは使えた、という話です。

何も表示されなくなる、完全に無反応になる(^Cを入力すると反応はありますが)、という見た目に騙されて、 なにかしら自分の知らない変なモードに入っているのだと思い込んでいましたが、単に表示がぶっ壊れているだけのようです。

そもそも変な文字を標準出力に流したりしてない不思議なシチュエーションでこの現象が発生するんですよね……謎です……

知識が偏っていて、化石のような

$ echo -e \\033c
$ echo ^[c

あたりは知っていたんですが、なんと

$ reset

を叩けばいいだけでした。resetコマンドはncursesに入っているようです。 resettsetへのsymlinkです。以下man resetより引用

When  invoked  as  reset,  tset  sets  cooked and echo modes, turns off
cbreak and raw modes, turns on newline translation and resets any unset
special  characters  to  their default values before doing the terminal
initialization described above.  This is useful after  a  program  dies
leaving a terminal in an abnormal state.  Note, you may have to type

    <LF>reset<LF>

(the  line-feed character is normally control-J) to get the terminal to
work, as carriage-return may no longer  work  in  the  abnormal  state.
Also, the terminal will often not echo the command.