You should know how to use iTerm2--MAC terminal tool

iTerm2

iTerm2  is the best terminal tool under MAC. It can be simply considered that iTerm2 is tmux that is configured out of the box. But tmux has the following disadvantages:

  • To find the output history of terminal, you need to switch to vim mode. In this mode, the copy and use of vim search increases the cognitive burden;
  • Compatibility with various tools is relatively poor, especially the powerline of vim and emacs;
  • Own style conflicts with system style.

Some features of iTerm2 are as follows:

Label discoloration

The color of the iTerm2 tab will change to indicate the current status of the tab. When the label has a new output, the label will turn to magenta; if the new output has not been viewed for a long time, the label will turn red. This function can be turned off in the settings.

Smart selection

In iTerm2, double-click to select, three-click to select the entire row, four-click to select intelligently (smart rules can be configured ), which can identify URLs, strings caused by quotation marks, email addresses, etc. (In many cases, the double-click selection is already very smart)

In iTerm2, select and copy. That is, any character string in the selected state is placed in the system clipboard.

Use the Command key cleverly

Hold down the ⌘ key:

  • You can drag the selected string;
  • Click url: call the default browser to visit the website;
  • Click on the file: call the default program to open the file;
  • If the file name is filename:42 and the default text editor is Macvim, Textmate or BBEdit, it will open directly to this line;
  • Click on the folder: open the folder in finder;
  • Hold down the option key at the same time to select a rectangle, similar to the ctrl v operation in vim.

Meta 键

In emacs, the meta key is used very frequently, and the OSX system does not provide the meta key. In iTerm2, you can select the left and right Option keys as meta keys. The official recommended configuration is shown in the figure below. The right Option key is still the default function of OSX (input special characters).

 

iTerm2 meta key iTerm2 meta key

 

Q: How do I make the option/alt key act like Meta or send escape codes?

A: Go to Preferences->Profiles tab. Select your profile on the left, and then open the Keyboard tab. At the bottom is a set of buttons that lets you select the behavior of the Option key. For most users, Esc+ will be the best choice.

Commonly used shortcut keys

  • Switch tab: ⌘+←, ⌘+→, ⌘+{, ⌘+}. ⌘+number directly locate the tab;
  • New tab: ⌘+t;
  • Switch pane in order: ⌘+[, ⌘+];
  • Switch pane by direction: ⌘+Option+direction key;
  • Split screen: ⌘+d split horizontally, ⌘+Shift+d split vertically;
  • Smart search, support regular search: ⌘+f.

 

iTerm2 find iTerm2 find

 

automatic completion

iTerm2 can automatically complete commands. Enter a few characters and press ⌘+; to pop up an automatic completion window listing the commands that have been used.

 

iTerm2 autocomplete iTerm2 autocomplete

 

iTerm2 can also use history records, press ⌘+Shift+h to pop up the history paste record window, ⌘+Shift+; pop up the history command record window.

 

iTerm2 copy history iTerm2 copy history

 

Exposé Tabs

⌘+Option+e displays all tabs in full screen and can be searched.

 

iTerm2 exposed iTerm2 exposed

 

Highlight the current mouse position

There are too many windows open in a tab, sometimes the current mouse cannot be found, ⌘+/find it.

 

iTerm2 highlight iTerm2 highlight

 

Color scheme

You can freely customize the color scheme you like. There are  a large collection of iTerm2 themes, which you can choose to use. I use Zenburn. Download the corresponding xxx.itermcolors file in its github repo, and double-click to install it.

 

iTerm2 color iTerm2 color

 

mosh

mosh  is a better ssh tool for all platforms, more robust, supports intermittent connections, and supports almost any platform except iPhone. (The advantages of iOS that make people love it, and it's the shortcomings that make people hate it)

Install brew install mobile-shell under OSX. For other platforms, please refer to the official tutorial .

 

mosh mosh

 

From the above point of view, the main advantage of mosh is that the connection to mosh will not be broken if the network is disconnected or hibernated. I tested a mosh connection for several months and it hasn't been broken.

Guess you like

Origin blog.csdn.net/smilejiasmile/article/details/108807099