Control characters appear unexpectedly in tmux terminal

Run tmux exception case in iterm under Mac.

tmux is an excellent terminal tool. In the past, I was actually a screen party because it was simple enough.

After contacting tmux, I found that it is simple enough, and compared to screen, it is more practical. In screen, you cannot press ctrl+a to return to the beginning of the current command line, while tmux can, so it is shameful "Rebelled."

Compared to Screen, it is also easier to use: it supports screen splitting (cross-cutting, vertical cutting), supports opening multiple sessions in a terminal, and has a richer command line parameter.

Under macos, use iterm to log in to the remote host, enter tmux, press shift+space/back delete, or ctrl+back delete, control characters will appear.

#手速稍微快一些,就会出来好几个控制字符
[[email protected] tmp]# 7;2u  ;2u  7;5u
-bash: 7: command not found
-bash: 2u: command not found
-bash: 2u: command not found
-bash: 5u: command not found

#在mysql客户端里也会出现
[email protected] [test]>select *;2u from t1;

Just change the TERM environment variable of the remote host to ansi/vt100 and so on.

[[email protected] ~]# env | grep TERM
TERM=xterm
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]# export TERM=ansi
[[email protected] ~]#
[[email protected] ~]# tmux a -t yejr

#之后在tmux里查看TERM,并且也不会再出现控制字符了
[[email protected] ~]# env | grep TERM
TERM=screen

If it is xterm/linux, the above problems will occur.

In addition, if tmux is running in the local environment, it will not happen, only if it is connected to a remote host.

Remarks: The pictures in the article are from Netsearch. If there is any infringement, please inform and delete it immediately.

The full text is over.

Enjoy tmux :)

Teacher Ye's "MySQL Core Optimization" class has been upgraded to MySQL 8.0, scan the code to start the journey of MySQL 8.0 practice

Guess you like

Origin blog.csdn.net/n88Lpo/article/details/108877842