Solve the problem of abnormal work of tmux under putty

Source: Internet
Author: User
Tags vps putty settings

Ubuntu default System configuration file location/usr/share/byobu/profiles/tmux

From

The PC is connected to the VPS via Putty and has some minor problems when using the Tmux installed on the VPS. The main reason is that Putty is a terminal emulator that differs from a real terminal and requires some extra setup. Here are some of the problems encountered and provide solutions.

Before you begin, introduce a method to view the control sequence of the key, which is used later. Perform:

Cat >/dev/null

Then press the button you want to view to see the corresponding control sequence. The one shown ^[[A is the sequence that corresponds to the arrow keys. Press two times to exit Ctrl+d.

Problem one 1:F2\F3\F4 invalid

Configure TMUX to use shortcut keys like Byobu to control Windows: F2 new window, F3 switches to the previous window, F4 switches to the next window. The configuration file is as follows:

# # Easy-to-swich window, like Byobubind-key-n F2 new-windowbind-key-n F3 previous-windowbind-K Ey-n F4 Next-window

But found in use, press F2\F3\F4 and other function keys are not valid, only in the command line entered a tilde ~ (or other symbols).

Workaround:

Open the Putty Settings screen, and under Terminal–> keyboard, change the Function keys and keypad from the default option "esc[n~" to "Xterm R6", as shown in two. Remember to save the settings, then the function keys are available.

With the above mentioned method of viewing the control sequence, you can see that the default F2 key sequence is ^[[12~ , changed to become ^[OQ .

Problem Two: Ctrl + ARROW key is invalid

The Ctrl+b Ctrl + ARROW key is used by default in Tmux to resize the panel. In putty, however, the button produces the same effect as the "Ctrl+b Arrow key" (That is, the default selection panel shortcut).

We first enter Tmux, and then, using the previously mentioned method of viewing the control sequence, you can see that the putty is for the sequence produced directly by pressing the "↑ arrow key" and "Ctrl +↑ arrow keys" ^[[A .

After various searches, it was found that Putty changed the CTRL cursor key mode, making it difficult for Tmux to detect keys correctly. Well, I have no idea what we're talking about, it's basically about the terminfo, or the original:

Putty Inverts the sense of the cursor key mode in CTRL, which is a bit hard for tmux to detect properly.

Workaround:

Insert the following two lines of code into the configuration file. tmux.conf Finally, close Tmux and then reopen Tmux to make sure the configuration file takes effect.

" xterm "  "xterm*:klft5=\eod:krit5=\eoc:kup5=\eoa:kdn5=\eob:[email protected]:[email protected] "
Problem three: Vim Ctrl + arrow key and shift+ direction key under Tmux

VIM uses "CTRL + ARROW keys" to move by word, using "shift+ arrow keys" to select. Google a bit, found that all are asked how to let vim of these two shortcut keys can work in the Tmux.

Workaround:

This problem is more troublesome because of the problem of Putty's own code. An incomplete solution is to include in the Tmux configuration file, on the basis of the problem two solution :

Set-g Xterm-keys on

You can now use CTRL + ARROW keys to move by word, but the shift+ arrow key is also changed to move by word. Because in Tmux, Putty is the same as the encoding of the two keys, such as the "Ctrl +↑ arrow key" and the "Shift +↑ arrow key" control sequence ^[[1;5A . There is no good solution at this time, either using a third-party compiled putty version or swapping with other software. (it is said that Mintty did not have this problem, but I did not try)

Question four: Color support is not complete

When you set the status bar background color at the bottom of the Tmux, you find that some colors cannot be displayed. For example, the following code, set the status bar to colour240, but the display effect is still black.

Set-g STATUS-BG colour240

Tmux allowed colors include: black, red, green, yellow, blue, magenta, cyan, white, colour0 to colour255, and default

Workaround (Option two):

1, one solution is to export the term environment variable is xterm-256color. Execute the following code directly:

' Export Term=xterm-256color ' >> ~/~/.BASHRC

2. Another workaround is to use the-2 parameter to start Tmux, forcing Tmux to think that the terminal supports the colours:

' alias tmux= "Tmux-2" ' >> ~/~/.BASHRC

Solve the problem of abnormal work of tmux under putty

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.