directory
One, foreword
Second, the body
1. Suspension window
1.1. Create a new Profile
1.2 background transparency and blur Settings
1.3. Window style configuration
1.4. Set hotKeys
2. Change the cursor shape
3. Set the background image
4. Customize the TAB page title
5. Customize color schemes
6, unified color matching
7. Close the startup screen
8. Use shell Integration
8.1 All Tools:
9. Use skills
9.1. Clipboard History
9.2. Smart Selection
9.3. Use Command skillfully
9.4 copy the text content to the clipboard
9.5. Open the current directory in Finder
One, foreword
For engineers who need to work with terminals for a long time, it is necessary to have a decent terminal manager, and for Windows users, the best choice is Xshell, which no one disputes. But for MacOS users, there’s still no doubt that iTerm2 is what you want, and if you don’t think it is, that’s your problem, not iTerm2’s. Today I’m going to tell you what the problem is, and what I’m going to show you is basically a recipe you’ve never seen before.
Second, the body
1. Suspension window
First, let’s solve the first problem: how do I call in and out of iTerm2 Windows on any interface and float them at the top of the interface?
I believe everyone has this scenario: you are browsing a web page in a full-screen browser, or writing code in a full-screen editor to write an article or something, suddenly think of something, or find something, want to quickly open the terminal, perform a command or two (such as open a file, start a service, etc.), and then close.
In this case, the vision is to be able to quickly open the terminal with a shortcut key, and then quickly hide it with the same shortcut key until it comes to me again when I need it. As for the implementation method, although tedious but not complicated, the following steps follow me:
1.1,Creating a New Profile
First open Preperence → Profiles and create a new profile called HotKey Window (you can call it anything).
1.2,Background transparency and blur Settings
Set it in Preperence → Profiles → Window → Window Appearance
1.3,Window Style configuration
Go to Preperence → Profiles → Window → Settings for New Windows
Explain these parameters:
- Full-width Top of Screen: This is easy to understand, so that the terminal appears at the Top of the Screen and takes up the entire Width.
- Current Spce: indicates that only the Current workspace is displayed. For example, if you have a terminal open on the Current screen, it will not follow when you switch to the next screen.
- Screen Width Cursor: This is used with the above parameter to determine which Screen belongs to the current workspace, indicating where your mouse is, and which is the current workspace.
1.4,Set the HotKey
Go to Preperence → Profiles → Keys → HotKey Window
Select A hotkey opens A dedicated window with this profile, which indicates that the profile can be opened and closed quickly by using shortcut keys.
Then click Configure Hotkey Window and set the shortcut key.
To use only one key, you can use function keys as shortcuts. I chose F12.
One caveat here is that function keys only work on macBooks without Touch Bar. For the new MacBook with Touch Bar, you can only use other combination shortcuts, such as Cmd+P. As for the reason, the function keys on the new MacBook are only displayed on the Touch Bar, so you can only open the function keys for each application, which means that the function keys are only displayed on the Touch Bar when you open the app, but we want to use the shortcut keys to call the terminal from anywhere. I can’t open terminal first and then use function keys to open terminal… It’s a chicken-and-egg problem, so stick with other shortcuts.
For a MacBook without Touch Bar, we can do this by first opening system Preferences and selecting keyboard Settings.
Select keys F1 and F2 as standard function keys.
This allows you to quickly open and close the terminal via F12.
Please note: after opening the standard function key, the special function of the function key, such as F11 to reduce the volume, F12 to increase the volume, must be combined with Fn key, for example, to increase the volume is Fn+F12.
On the new MacBook with Touch Bar, you can do this by opening system Preferences and selecting keyboard Settings.
“Press the Fn key to” select “display F1, F2 and other keys” :
This allows you to quickly open the terminal using Fn+F12.
At the same time, add iTerm application in shortcut key → function key Settings, so that you can directly use F12 key to close the iTerm2 window.
So far, the Profile on the hover terminal is configured, and you can press your HotKey to quickly open and hide the command line. If you want to create new tabs using this Profile, you can set Hotkey Window to the default Profile:
Now let’s do some optimization.
2. Change the cursor shape
Set it in Preperence → Profiles → Text.
The default cursor shape is maroon:
The cursor shape is much more pleasing to the eye after changing the Settings:
Tick Blink CURSOR to cause the cursor to blink.
3. Set the background image
Set it in Preperence → Profiles → Window.
4. Customize the TAB page title
Set it in Preperence → Profiles → General.
Deselect Applications in terminal may change the title:
Title Select Profile Name and deselect Job Name:
The title of each TAB page is displayed as the corresponding Profile Name:
5. Customize color schemes
There is a ready-made colorscheme on the web that we can use directly here: iterm2colorschemes.com/.
Download the zip package and unzip it. Open the Settings for iTerm2: Preperence → Profiles → Colors → Color Presets. Click Import and select your desired theme import from schemes in the extracted theme directory.
6, unified color matching
By default, the TAB color is black, even if you change the color scheme:
If you want a uniform color palette, you need to modify the configuration slightly. Go to Appearence → General and change the Theme to Minimal:
7. Close the startup screen
If you don’t want to open iTerm2 with the default window every time you open the program silently, you can set Appearence → General:
Check Exclude from Dock and… The next time you reopen iTerm2 after changing the Settings, it will look like this:
It no longer appears in the Dock, nor does it open a default window for you when you start up, and you can gracefully call in and out of the window with shortcut keys, perfect.
8. Use shell Integration
ITerm2 can be integrated with the Unix shell. After installing the Shell integration tool for iTerm2, you can see the command history, current working directory, host name, uploaded and downloaded files, and so on in iTerm2.
You can either go to the menu bar iTerm2 > Install Shell Integration or enter a terminal command:
# if your default shell is bash, please put the ZSH to bash $curl - L https://iterm2.com/misc/install_shell_integration.sh | ZSHCopy the code
The script automatically installs the corresponding script of the current terminal shell and writes it to the corresponding shell configuration file. For example, after executing a script in ZSH shell, the following statement is written in the middle of.zshrc:
$ test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
Copy the code
The.zshrc file is in the user directory, that is, CD ~
Then execute: vim. ZSHRC to edit
After installing iTerm2’s shell integration, there will be an extra blue triangle on the far left of the terminal interface. As shown in figure:
Tags with blue triangles indicate that the current shell supports shell Integration. To turn off the markup, you can turn off Show Mark Indicators in iTerm2 > Preferences > Profiles > (Your Profile) > Terminal bottom > Shell Integration.
8.1 All Tools:
imgcat filename
Displays the image inline.
imgls
Shows a directory listing with image thumbnails.
it2api
Command-line utility to manipulate iTerm2.
it2attention start|stop|fireworks
Gets your attention.
it2check
Checks if the terminal is iTerm2.
it2copy [filename]
Copies to the pasteboard.
it2dl filename
Downloads the specified file, saving it in your Downloads folder.
it2setcolor ...
Changes individual color settings or loads a color preset.
it2setkeylabel ...
Changes Touch Bar function key labels.
it2ul
Uploads a file.
it2universion
Sets the current unicode version.
Copy the code
For example, you can use imgCat to display images directly on the terminal:
Weixin.qq.com/r/dCgrMwrE5… (Qr code automatic recognition)
9. Use skills
Finally, a few tips on using iTerm
9.1,Clipboard history
ITerm2 allows us to quickly view the contents of the clipboard simply by using Command + Shift + H to call out the paste history, supporting fuzzy retrieval. You can also set the paste history to save on disk (Preferences -> General)
9.2,Intelligent selected
In iTerm2, double click to select, triple click to select the entire line, four click intelligent select (intelligent rules can be configured), can recognize urls, quotes caused by strings, email addresses, etc. (A lot of times the double click is already smart)
9.3,Using the Command button
Press the ⌘ key:
- You can drag and drop the selected string;
- Click on url: call the default browser to visit the url;
- Click file: call the default program to open the file;
- Click On Folder: To open the folder in Finder;
- At the same time hold down the
option
Key, which can be selected as a rectangle, similar to viMctrl v
Operation.
9.4,Copy the text content to the clipboard
$ pbcopy < text.md
Copy the code
9.5,Open the current directory in Finder
$ open .
Copy the code
\