iTranslated by AI
iTerm2 for Beginners: A Cheat Sheet of Essential Features and Recommended Settings for Better Productivity
Quick Guide to iTerm2 Basics + Cheat Sheet
Introduction
iTerm2 is a command-line tool similar to the standard Mac Terminal.
iTerm2 has many excellent points: (1) it's free, (2) it has many useful features, and (3) it features a beautiful design! Switching from the standard Terminal is easy too!
Try downloading it from this page.
In this article, I've summarized the basic functions and keyboard shortcuts of iTerm2. I plan to add more information over time!
Note: This is a repost by the author from this Qiita article.
Pointer Functions
- Click Selection
In iTerm2, simply dragging to select text with your mouse copies it to the clipboard[1].
| Action | Description |
|---|---|
| Double-click | Select word |
| Triple-click | Select line |
| Quadruple-click | Smart selection (selects URLs, email addresses, etc.) |
For those who want to master it further, you can configure custom pointers in Preferences (open with cmd + ,) -> Pointer.
As recommended in the documentation, I set "Three-finger tap on trackpad" to "Smart Selection" in Bindings. (If you want to revert, press Load Defaults.)
- Selection using shift and cmd
| Action | Description |
|---|---|
| Click anywhere + Shift + Click elsewhere | Range selection |
| Cmd + Drag repeatedly in arbitrary places | Non-contiguous range selection |
| Cmd + Click on URL/filename | Open URL/file |
| Note: If there is a colon + number after the filename, that line will be opened. Files are only searched for in the directory where the prompt was located. |
- Number Conversion
| Action | Description |
|---|---|
| Right-click decimal | Display converted hex value |
| Right-click hex | Display converted decimal value |
| Right-click Unix timestamp | Display converted local time |
Screen/Cursor Operations
iTerm2 tabs can be handled just like in a browser (like Safari or Chrome)! For example, you can reorder tabs (using drag and drop), move tabs in and out of different windows, and so on.
- Tab Operations
| Action | Description |
|---|---|
| cmd + t | Create new tab |
| cmd + right arrow / left arrow | Switch tabs |
| cmd + number | Move directly to the tab with that number |
| cmd + w | Close tab |
| Middle-click on a tab | Close tab |
- Window Operations
| Action | Description |
|---|---|
| cmd + n | Create new window |
| cmd + enter | Maximize window / Restore (transparency is turned off when maximized) |
| cmd + u | Turn window transparency off / Restore |
| cmd + opt + number | Move directly to the window with that number |
- Split Operations
| Action | Description |
|---|---|
| cmd + d | Open a vertically split[2] pane[3] |
| cmd + shift + d | Open a horizontally split pane |
| cmd + shift + enter | Maximize pane / Restore |
| cmd + w | Close split pane |
| cmd + opt + right arrow / left arrow | Move between split panes |
| cmd+ ] / [ | Move between split panes |
- Location Marks/Jumps
| Action | Description |
|---|---|
| cmd + shift + m | Mark location |
| cmd + shift + k | Kill (delete) mark |
| cmd + shift + j | Jump to marked location |
| cmd + shift + down arrow | Jump to marked location (use this if multiple locations are marked) |
It's handy to mark before running tree so you can jump back!
I prefer using set -o vi in my .bash_profile for vi-like keybindings, so I don't use the following "Cursor Movement" and "Text Editing" sections, but I'll include them just in case. (I do use Copy Mode, though.)
- Cursor Movement/Editing
| Action | Description |
|---|---|
| ctrl + f | Move forward one character |
| ctrl + b | Move backward one character |
| ctrl + a | To beginning |
| ctrl + e | To end |
| ctrl + d | Delete character under cursor (also esc + d) |
| cmd + shift + c | Copy Mode (allows vi-like cursor movement and copying) |
By the way, Copy Mode can also be accessed via Edit → Copy Mode. It allows you to move the cursor and copy text.
History/State Saving
- Search/History/Commands
| Action | Description |
|---|---|
| cmd + f | Search (navigate with tab or shift + tab) |
| cmd + shift + h | Check paste history |
| tab twice | Autocomplete |
| ctrl + r | Same as clear (clears the prompt) |
- Saving, Restoring, and Deleting Arrangements
| Action | Description |
|---|---|
| cmd + shift + s | Save arrangement |
| cmd + shift + r | Restore an arrangement with a configured shortcut |
| Window > Restore Window Arrangement | View list of saved arrangements / click to restore |
| Preferences > Arrangements | Delete a specific arrangement with the minus (-) button |
| Preferences > Arrangements | Set Default to make it the arrangement opened by cmd + shift + r |
By the way, an "arrangement" refers to the state of the windows at that specific time.
In iTerm2, you can save snapshots of these arrangements and restore them later.
If you want to master key operations further, you can configure global keyboard shortcuts in Preferences > Keys.
Additionally, you can set shortcuts that only affect specific profiles in Preferences > Profiles > Keys.
You can also remap the functions of the Option and Command keys, and even choose not to apply remapping under specific conditions.
For now, you should be fine just setting up the Hotkey.
(Refer to the "Recommended Settings" section below for the setup method.)
Recommended Settings
- Hotkey
Preferences > Keys > Hotkey
| Action | Description |
|---|---|
| cmd + i | Instantaneously show or hide the iTerm2 window |
| Note: cmd + i is just my recommendation; you can of course use other keybindings. | |
| With this, you can easily toggle the terminal screen using only your keyboard! |
- Visual Bell
Preferences > Profiles > Terminal > Check "Flash visual bell"
This makes the bell warning flash across the entire screen for a moment.
(This feature is helpful since you might not hear the beep if you're listening to music, etc.)
- Making Fonts Readable (Including Ricty Diminished!)
Preferences > Profiles > Text > Font
You can customize the font and size as you like in the path above.
I set my font to Ricty Diminished and the size to 16.
I recommend this because it clearly displays when you've accidentally entered full-width characters, as shown in the image below.
By the way, Ricty Diminished is likely not a font pre-installed on Mac, so you will need to install it. To easily install Ricty Diminished using Homebrew, I recommend this Qiita article as it is very clear! Please check it out.
- Enabling Clipboard Usage even when using tmux
Preferences > Selection
Check the box for "Applications in terminal may access clipboard."
Notable Features to Keep in Mind
These are features that I, the author, haven't quite mastered during development. But they're probably useful!! (`・ω・´)
- Instant Replay Function
| Action | Description |
|---|---|
| cmd + opt + b | Check what was previously displayed on the window by stepping back |
- Undo Close
| Action | Description |
|---|---|
| cmd + z | Reopen a closed tab within a certain time limit |
Note: You can set the time limit for Undo in Preferences > Profiles > Session.
- Password Manager
iTerm2 also has a function to save passwords within the keychain.
You can open the Password Manager from the Window > Password Manager menu and enter your password.
| Action | Description |
|---|---|
| cmd + shift + f | Open Password Manager |
- Timestamps
Displays timestamps for each line, allowing you to see how long it took to display a message.
| Action | Description |
|---|---|
| cmd + shift + e | Show timestamps (View > Show Timestamps) |
- Expose Tabs Function
A feature to search all tabs simultaneously, which seems useful when you have too many tabs open!
| Action | Description |
|---|---|
| cmd + opt + e | Search all tabs simultaneously |
There are many other features/settings that I haven't fully grasped yet, such as the "Trigger" feature for highlighting user-defined regular expressions, the "Minimum Contrast" feature for color-blind users, and Shell Integration. I encourage everyone to challenge themselves by reading the documentation!
Note: Regarding Shell Integration, I may add it here later or summarize it in a separate article depending on the volume.
References / Recommended Sites
- General Usage / iTerm2 Official Documentation
- Highlights for New Users / iTerm2 Official Documentation
Reliable and trustworthy official documentation.
It's an English YouTube video, but even if you can't understand it, it's not a problem because they show terminal operations with a keyboard next to it! The sequel also looks good (haven't seen it yet).
This was the reason I switched to iTerm2. The article clearly describes how the author was impressed by iTerm2's useful features, which also helps boost motivation.
A recently recommended programming learning site with clear and easy-to-understand explanations. It's currently in a free period. It also includes explanations for tools like VS Code, iTerm2, and Docker.
Discussion