[Literacy post] Do you know about the Linux Window Management Program Tmux?

Source: Internet
Author: User

[Literacy post] Do you know about the Linux Window Management Program Tmux?

Introduction

Tmux is a program for window management in linux. Unlike iTerm2, tmux provides a Session storage and restoration function at any time (the Session concept will be introduced later ), detach Session (keep the Session running in the background) and attach the Session again.

In common scenarios, multiple tags and files are opened in the company's Terimal. When I got home from work, I suddenly got inspiration and wanted to continue writing. I used ssh to remotely connect to the company's computer, then we found that the tabs and files should be re-opened. If Tmux is used, the current Session of detach will be closed. After going home to ssh remote connection, after attach Session, the scenario will be restored and the programming will continue happily...

Install
 
 
  1. # Install the lost package management Homebrew under Mac OS X
  2. $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  3. # Install Tmux
  4. $ brew install tmux
Basic
 
 
  1. # Start Tmux
  2. $ tmux
  3. # Disable Tmux
  4. $ ctrl + d
  5. # Or exit
  6. $ exit

Tmux has three basic concepts: Session, Window, and panel ). After you enter tmux, what tmux actually does is to first create a Session and then create a Window in this Session. You can continue to create multiple windows ), each window contains only one panel. After you continue to split the screen, multiple panels (Pane) will appear. The terminals you see in the window actually belong to a panel of tmux.

Further, the Session can contain multiple windows, and each Window can contain multiple Pane.

Basic operations

How to execute all shortcut keys:

Presscontrol + bCombine the two buttons and release them.control + b(To tell Tmux that I want to use the Tmux shortcut key), and then trigger various actions by the shortcut key.

For example:C-b ?The execution process is as follows:control + bCombine the two buttons and release them.control + bAnd then press '? 'Key, the list of all Shortcut Keys is displayed.

  • C-b ?List all shortcut keys and press q or Esc to return
  • C-b dDetach the current session. You can return to the Shell Interface temporarily and enter tmux attach to re-enter the previous session.
  • C-b sSelect and switch sessions.
Shortcut Key Window operation
  • C-b cCreate a new window
  • C-b &Close current window
  • C-b wList all window selections
  • C-b pSwitch to the previous window
  • C-b nSwitch to the next window
  • C-B window numberUse the window number to switch the window (for example, if the window number is 1C-b 1)
  • C-b ,Rename the current window for easy identification of each window
Pane operation
  • C-b %Horizontal Terminal
  • C-b "Vertically split Terminal
  • C-B direction keyThe Panel is selected freely.
  • C-b xClose current pane
  • C-b qDisplay Panel number
Session operation
 
 
  1. # Create a new session
  2. $ tmux new -s <name-of-my-session>
  3. # Create a new session in the current Session and ensure that the previous session still exists
  4. # C-B: Enter the following command:
  5. new -s <name-of-my-new-session>
  6. # Enter the session named test
  7. $ tmux attach -t test
  • C-b sList all sessions
  • C-b dDetach the current session (which can be considered as running in the background)
Advanced Beautify Tmux

Use the Tmux configuration of gpakosz for beautification.

Advantages

  • UseC-aIt is easier to use as a prefix and savesC-bTrigger prefix
  • Powerline status bar beautification (familiar with vim)
  • Display laptop battery status

Installation and Use

 
 
  1. $ cd
  2. $ rm -rf .tmux
  3. $ git clone https://github.com/gpakosz/.tmux.git
  4. $ ln -s .tmux/.tmux.conf
  5. $ cp .tmux/.tmux.conf.local .
Reference
  • Official Tmux website
  • A Tmux crash course: tips and tweaks
  • Tmux getting started
  • Tmux-essential tool for Linux practitioners
  • Tmux conf
  • Tmux, a tool for Linux Terminals

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.