Tmux Usage Details, tmux details

Source: Internet
Author: User

Tmux Usage Details, tmux details
Text giant three: zsh, tmux and vim reference: Linux terminal killer, programmer tool-Tmux github. tmux configuration shortcut key summary more detailed tmux command principle you can quit at any time or enter any Session. Each Session has several windows, and each Window can be divided into multiple Pane sessions for full recovery! However, shutdown is not acceptable, but you can write a script to restore the tmux-> session-> window-> pane. A Session can contain multiple windows and one Window) you can install Tmuxapt-get install tmux sudo port install tmux sudo brew install tmux sudo yum install tmux. Other systems can install the tar package of Tmux directly, tmux depends on libevent and libevent-devel packages. after Tmux is installed, no configuration file is generated by default. /Etc/tmux. conf Global File ,~ /. Tmux. conf User Environment File

# Vim ~ /. Tmux. confset-g prefix ^ g #
Activate the console (Ctrl + B by default) unbind ^ B # unbind Ctrl + bset-option-g status-utf8 on # enable UTF-8 support for the status bar # cp modeset-window-option-g mode-keys vi # default keyboard layout in copy mode use vibind h select-pane-L # h to move the cursor to the left bind j select-pane-D # j move the cursor down bind k select-pane-U # k move the cursor up bind l select-pane-R # l move the cursor to the right
  
  
  • 12345678910
Tmux uses Ctrl + B by default. The reason why it is changed to Ctrl + g is that Ctrl + B moves the cursor to the left in the Bash environment. now the tmux and vim operations are the same. You can also use h, j, k, and l to move the cursor during replication. Tmux relies entirely on shortcuts to use its functions. The Ctrl + g just set is a prerequisite for these functions, such as opening a clock: press Ctrl + g + t to press Ctrl + g and then press Ctrl + g to open Tmux: press Ctrl + g and then press t. A digital clock is displayed on the terminal. The function of tmux is nothing more than the key of Ctrl + g +, all the buttons are the same as the clock example above. To obtain help from Tmux, press Ctrl + g +? (The question mark is equal to: Shift +/) The help information of Tmux will appear. In the message, 'Bind-key' refers to Ctrl + g, or directly man tmux. The tmux new-s myname command can specify the Session name [PREFIX-:] new-s creates a session tmux attach-session-t myname in tmux to reconnect this session tmux attach-t basic tmux a-t basic tmux list-session tmux ls [PREFIX -s] view the session List in tmux and switch to tmux new-session <session Name> tmux attach-session-t <session Name> tmux rename-session-t <session Name> tmux choose-session-t <session Name> tmux kill-session-t <session Name> when you temporarily disconnect multiple tmux sessions, you can specify to recover a session:
# Tmux ls # view all sessions 0: 4 windows (created Tue Jan 22 00:42:16 2013) [177x48] 1: 1 windows (created Tue Jan 22 00:51:30 2013) [177x48]
Tmux a-t 0 restore the first Session Shortcut Key + $ rename the current Session d detach separate Session t big clock? List shortcuts: common features of promptTmux split terminal window + "split a window horizontally in the current window of the cursor + % in the current window of the cursor, vertically split a window + h ............ Jump the cursor to the Left window + j ............, Jump to the bottom of the window + k ............ Jump to the window above + j ............, Jump to the right window +! Close all split windows + x close the current window of the cursor. (Or press Ctrl + d directly) + {Replace the current Panel with forward +} Replace the current Panel with backward + q query panel number using different windows. Multiple small windows are opened in one terminal, still not enough? + C create a new window + p switch to the previous window + n switch to the next window + f list all windows + w list the currently created windows, you can see the window number, in the direct switch by number window, see Figure 2 + 0-9 to directly switch to the specified number window +, modify the current window name, see Figure 3 + d to temporarily disconnect all sessions, before using the command # tmux attach to restore the session + & close the window, you need to confirm that the window is divided into many panels. Sometimes you need to view the log file while working in the editor. Tracking logs while editing is really helpful. Tmux allows us to divide the window into multiple panels. For example, we can create a console to monitor our server and construct a complex development environment with the editor so that compilation and debugging can be performed at the same time. Tmux new-s panes + "horizontally splits the original + % of a window and vertically splits the original + direction keys to move and hold them between them, and then presses the direction keys, we can change the size between panes. o swap panes q show pane numbers x kill pane break pane into window (e.g. to select text by mouse to copy) restore pane from window? Space-toggle between layouts q (Show pane numbers, when the numbers show up type the key to goto that pane) {(Move the current pane left)} (the Move current pane right) z toggle pane zoom splits the original unmodified key bit by re ing [PREFIX-%] and [PREFIX-"] to [PREFIX-]/[PREFIX-] to close a panel, confirm [PREFIX-x] or exit [execute in panel] switch [PREFIX-hjkl] Move Between pane [Ctrl-hjkl] Move Between pane [Ctrl-] recently use between two windows switch [PREFIX-q] to display the window number, and select to jump to [PREFIX-o] to switch the cycle size. [Ctrl-HJKL] adjust pane size [PREFIX-z] trigger temporarily closes the window and moves [PREFIX-x] to close the current pane, you need to confirm that [PREFIX-}] The current pane is moved to the left [PREFIX-{] The current pane is moved to the other [PREFIX-!] Currently, when pane opens [PREFIX-space] in a new window, these la s are automatically switched and used in turn (several la s are switched in turn) copy and paste [PREFIX-[] to enter the copy mode => operation space/v to start selecting Ctrl-v entire block select hjkl direction key move w/B move forward and backward a word fx/Fx move the row to the next character location ctrl-B/f in the buffer to flip g/G to the top/Bottom of the buffer /? Next to n/N, and copy [PREFIX-] to the previous Enter/y to paste other enhancements:
# Copy the entire visible pane region [PREFIX-:] capture-pane # view the buffer content [PREFIX-:] show-buffer # list the buffer list [PREFIX-:] list-buffers # select from the buffer list and insert it to the current Panel [PREFIX-:] choose-buffer => press ENTER
Other shortcut keys

[PREFIX-?]

Enter command mode
[PREFIX-:] commands in some command modes # new window new-window-n console # new and execute the new-window-n processes "top" command"
TmuxinatorTmuxinator is a Ruby gem package that can be used to create a Tmux session. It works by defining session details in the configuration file, and then using one command to create these sessions
Gem install tmuxinatortmuxinator new project_a => ~ /. Tmuxinator/project_a.yml => Configuration start: tmuxinator start project_a can be an alias: mux start project_a
Vim plug-in: christoomey/vim-tmux-navigator. Install a more convenient navigation switch to view the window history. When you perform some operations in a small window, there are too many output content. How can we roll back? + PgUP roll up + PgDn roll down in terminal window copy in one terminal split up multiple small windows, you may copy some code or command lines in a small window to another small window. In this case, you cannot use the red dot, mouse, or touchpad. It regards the entire terminal window as a copy area object without isolating the small window copy [enter the copy mode, move the cursor to the text area to be copied, and press the Space key to start selecting the content to be copied, use h, j, k, l, $, and 0 (same as in vim) to press enter to confirm the selected content. ] Paste some of the more practical functions described above, proficient in vim's skilled application. (The shortcut key combination of the control key: Ctrl + B also said the disadvantage, and then changed to Ctrl + n to find that the command cannot be turned down in the terminal, after changing to Ctrl + m, the carriage return is useless. Calculate the tmux clear-historygithub tmux. The default tmux style of some personalized configurations is simple or ugly. If you want to make some beautification and personalized configuration, we recommend that you use the tmux configuration of gpakosz. It is essentially a tmux configuration file and implements the following functions: powerline-based beautification shows that the keyboard shortcut Ctrl + A is the backup prefix for the notebook battery and Mac communication clipboard and vim are more similar. You can jump to the beginning of the line twice.
cdrm -rf .tmuxgit clone https://github.com/gpakosz/.tmux.gitln -s .tmux/.tmux.confcp .tmux/.tmux.conf.local .
Sessions, windows, and panels according to the definition of tmux, after the tmux server is enabled, a session is created first, and this session is created first, which contains only one panel; that is to say, the so-called terminal console is called a panel of tmux, although it is used in the same way as the terminal console. Tmux is built using the C/S model and mainly includes the following unit modules: server. When you enter the tmux command, a server is enabled. Session. A server can contain multiple session windows. A session can contain multiple windows. Pane panel. A window can contain multiple panels. Let's take a look at several configurations first. These configurations are the reason why I cannot leave tmux :-). The configuration file of tmux is ~ /. Tmux. conf. This file may not exist. You can create it yourself. First, do you think it is too inconvenient to press the tmux prefix? ctrl is too far away from the B key. Many people map it to C +, that is, in the configuration file (~ /. Tmux. conf) Add the following statement: Set the prefix to Ctrl +
set -g prefix C-a
At the same time, cancel the default prefix button: remove the correspondence between Ctrl + B and the prefix
unbind C-b
After the configuration is complete, restart tmux to take effect, or press C + B, then enter: To enter the command line mode, and enter source-file ~ in command line mode ~ /. You can add the following sentence to the configuration file like me. After changing it, you only need to add the prefix + r. Set r to load the configuration file and display "reloaded !" Information
bind r source-file ~/.tmux.conf \; display "Reloaded!"
Many people like to change the prefix to Ctrl + a, but I personally prefer Ctrl + x. If you are a vim user, you must understand it. In addition, it is inconvenient to switch the Panel. You must first press the prefix and then press the direction key. Do you still remember how to switch the panels in vim? Tmux can also be used because it supports ing. Change the prefix ing to Ctrl + x and add the following statements. Now, the switching window is the same as that of vim, and I feel a lot more friendly.
upbind-key k select-pane -U#downbind-key j select-pane -D#leftbind-key h select-pane -L#rightbind-key l select-pane -R
The last statement above will change the C-x l function. I like this function very much, because we usually switch between two windows or these two panels, so I add the following statement: select last window
bind-key C-l select-window -l
Now, I cannot press the l key. Ctrl + x l is to switch the panel, Ctrl + x Ctrl + l to switch the window, And Ctrl + l to clear the screen. Copy-mode prefix in copy mode [Enter copy mode Start copy by space, move cursor select copy area press Enter copy and exit copy-mode. Move the cursor to the specified position and press PREIFX]. If we compare tmux to vim, most of the time we are in editing mode. Can we move the cursor like vim during copying? You only need (~ /. Tmux. conf. Copy-mode: Set the shortcut key to vi mode.
setw -g mode-keys vi
View the Session C-x s in the menu and select Session C-x: new-session create a new session C-x d Exit and save the session terminal run tmux attach return session name session tmux new-s session-d # create a session tmux in the background ls # list sessions tmux attach-t sessions # enter a session to maximize the current pane from using vim, I believe that some people in this world know more about what you want than yourself, so old Joe can make products that make the world scream, so I often browse experts. vimrc file, I used tmux in less than three days and found that, how can it not maximize the current pane? Just like the ZommWinPlugin. vim plug-in vim, you press a key to maximize the current window and obtain the maximum visual interface. So far, I have not found any other people who do not have a requirement. Similarly, the solution has been found by our predecessors. The scrolling screen should enter copy-mode, that is, the prefix + [, then, you can use the up and down keys to scroll the screen. With the vi shortcut mode configured, you can scroll the screen like vi, which is very convenient. Exit and press 'q.

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.