Skip to content

Instantly share code, notes, and snippets.

@squarism
Last active October 27, 2025 13:29
Show Gist options
  • Save squarism/ae3613daf5c01a98ba3a to your computer and use it in GitHub Desktop.
Save squarism/ae3613daf5c01a98ba3a to your computer and use it in GitHub Desktop.
An iTerm2 Cheatsheet

Tabs and Windows

Function Shortcut
New Tab ⌘ + T
Close Tab or Window ⌘ + W (same as many mac apps)
Go to Tab ⌘ + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction ⌘ + Option + Arrow Key
Cycle iTerm Windows ⌘ + backtick (ttrue of all mac apps and works with desktops/mission control)
Splitting
Split Window Vertically (same profile) ⌘ + D
Split Window Horizontally (same profile) ⌘ + Shift + D (mnemonic: shift is a wide horizontal key)
Moving
Move a pane with the mouse ⌘ + Alt + Shift and then drag the pane from anywhere
Fullscreen
Fullscreen ⌘+ Enter
Maximize a pane ⌘ + Shift + Enter (use with fullscreen to temp fullscreen a pane!)
Resize Pane Ctrl + ⌘ + Arrow (given you haven't mapped this to something else)
Less Often Used By Me
Go to Split Pane by Order of Use ⌘ + ] , ⌘ + [
Split Window Horizontally (new profile) Option + ⌘ + H
Split Window Vertically (new profile) Option + ⌘ + V
Previous Tab ⌘+ Left Arrow (I usually move by tab number)
Next Tab ⌘+ Right Arrow
Go to Window ⌘ + Option + Number

Basic Moves

Function Shortcut
Move back one character Ctrl + B
Move forward one character Ctrl + F
Delete current character Ctrl + D
Delete previous word (in shell) Ctrl + W
Undo Ctrl + -

Moving Faster

A lot of shell shortcuts work in iterm and it's good to learn these because arrow keys, home/end keys and Mac equivalents don't always work. For example ⌘ + Left Arrow is usually the same as Home (go to beginning of current line) but that doesn't work in the shell. Home works in many apps but it takes you away from the home row.

Function Shortcut
Move to the start of line Ctrl + A or Home
Move to the end of line Ctrl + E or End
Move forward a word Option + F
Move backward a word Option + B
Set Mark ⌘ + M
Jump to Mark ⌘ + J

Copy and Paste with iTerm without using the mouse

I don't use this feature too much.

Function Shortcut
Enter Copy Mode Shift + ⌘ + C
Enter Character Selection Mode in Copy Mode Ctrl + V
Move cursor in Copy Mode HJKL vim motions or arrow keys
Copy text in Copy Mode Ctrl + K

Copy actions goes into the normal system clipboard which you can paste like normal.

Search the Command History

Function Shortcut
Search as you type Ctrl + r and type the search term; Repeat Ctrl + r to loop through result
Search the last remembered search term Ctrl + r twice
End the search at current history entry Ctrl + y
Cancel the search and restore original line Ctrl + g

Misc

Clear the screen/pane (when ctrl-l won't work) | ⌘ + k (I use this all the time)

@arvindkgs
Copy link

⌘ + o shows a dialog with all profiles and selection of a profile opens tab in specific profile

@xu20160924
Copy link

Does anyone know if there have a shortcut to show all Snippet?
image
I'd like to show all snippets, and then choose one using the up/down arrow key.

@hui-zheng
Copy link

To Undo the last changes. use Ctrl-x Ctrl-u or Ctrl-_

@ahsanfarooq3423
Copy link

Thanks

@parin13
Copy link

parin13 commented Jan 22, 2022

any option to rename a particular plane?

@xu20160924
Copy link

Does anyone know why when I use fn + delete to delete a character after the cursor, it prints tilde(~) and didn't work

@dudeinthemirror
Copy link

dudeinthemirror commented Apr 15, 2022

You can add set -o vi and export EDITOR=vi in your .zshrc (or .bashrc, or what have you). After you source it
(. .~/.zshrc), you are now in vi insert mode. Then you can do:
ESC - to exit the insert mode.
k - to move back in history
j - to move forward in history
/ pattern - to search for a command in the history containing 'pattern'
0 - to move to the beginning of the line
$ - to move to the end of the line
l - move to the right one char at a time
h - move to the left one char at a time
w - to move to the right one word at a time
b - to move to the left one word at a time
cw - to change word
dw - to delete word
C - to change to the end of line
D - to delete to the end of line
... etc ... etc ... you get the point I hope :)

@jirkadev
Copy link

if I want to undo the last text change on the command prompt in iTerm2 Ctrl+_ does not work.
If I try Ctrl+_ in the plain macOS terminal, it works. Am I missing some iTerm2 settings? Thanks!

Ctrl+_ seems to be a standard Unix terminal shortcut or something:
http://web.mit.edu/gnu/doc/html/features_7.html

Screen Shot 2022-05-12 at 10 33 33

@squarism
Copy link
Author

@jirikrepl Wow. That's a new one. I've never heard of this feature! Amazingly, it's working here like a regular undo. Wow. I'm pressing Ctrl + _ and it works in iTerm2 and Terminal.

Hmm. I don't see any Ctrl based key mappings in iTerm's profile. I was thinking maybe something is remapping. To test that it isn't the shell, maybe you could invoke bash or zsh from iTerm. There's a flag to start the shell without reading your dotfiles too IIRC. Maybe this would help isolate/troubleshoot.

@alanhe421
Copy link

⌘ + Shift + arrow-up
⌘ + Shift + arrow-down
For navigating marks. If shell integration is enabled all commands are marked automatically, and you can quickly go to previous commands and their output.
βœ…

I didn't understand that when I navigated to pre/next Mark, the cursor was still in the same position.

so what is the point of navigation?

@squarism
Copy link
Author

@AlanHg I don't know what he meant by that. I use mcfly right now but have used other history searchers in the past. You configure it and then just hit ctrl-r and start typing. Also fish (or zsh) has a thing when you type a command and hit up arrow and it will filter by what you have typed already. So like sudo journalctl<up> would get you all the journalctl commands.

@Arbyrd33
Copy link

Arbyrd33 commented Jul 27, 2022

Is there any way to duplicate a tab into a new tab with a keyboard shortcut? I find myself having to ctrl + t to make a new tab, cycle back to the original tab, right click on the tab, and then duplicate it. Catch is that the original tab has to be color coordinated or I'll accidentally delete the duplicated tab. Additionally, you can't duplicate a tab in the right-click context menu unless it's actually in tab form, not window form, which is why I need to make an arbitrary tab in the first place, and at this point I wonder if it would just save more time to manually cd into my desired directory.

EDIT: I have found a workaround, sort of. In the settings, I discovered I can show tabs even when there's only one tab. This will make duplicating them a lot easier, however, I still wasn't able to figure out how shortcuts work. To the docs..

@normand1
Copy link

moving forward or backwards is not working for me, anyone know why that might be?

@SantaHub
Copy link

SantaHub commented Dec 1, 2022

I would love an option to run a command on all the terminal.

@squarism
Copy link
Author

squarism commented Dec 21, 2022

I would love an option to run a command on all the terminal.

@SantaHub

  1. Open "all your terminals" as split panes. For example. Cmd+D two times. Now you have 3 panes in one window.
  2. Type Cmd+Option+I to enable broadcast mode. Click ok at the warning.
  3. Type your command once to all panes.
  4. Type Cmd+Option+I to disable broadcast mode.

This is very handy for cheap mass server administration at times. 🌹

@ospatil
Copy link

ospatil commented Jan 20, 2023

Thanks @squarism! It's a such a handy list.
One bash key combination I find useful:
esc + # : comment out the current command and move to next line

@pdothash
Copy link

What does Cmd+R do?

@jackyyeh5111
Copy link

Fantastic! Extremely useful.

@rprimmer
Copy link

rprimmer commented Feb 9, 2024

Good stuff!

@Warkanlock
Copy link

What does Cmd+R do?

I sum up to this: Where's the Shift+Cmd+R documented?

@ralexrdz
Copy link

I'm very used to alt + . command in Linux, which pastes the last argument from previous command. Any alternative? So far I use !$

@squarism
Copy link
Author

@ralexrdz I had muscle memory in bash for !$ as last argument when I used bash (I still use bash), which will work in every terminal. So, I would use that. It's fast and probably pretty universal. It works in zsh too.

Lately, I use fish (and this is not an endorsement of fish necessarily) and the equivalent in fish is alt + up arrow. 🐟 These are shell things, not iTerm2 things, just to be clear. πŸ˜„

@dcorking
Copy link

@ralexrdz M-. works for me in iTerm2 (3.5) in bash 5.2 and zsh 5.9. Thank you for teaching me a new shortcut πŸ˜„ Perhaps you have overridden the default binding somehow (such as with set -o vi). It is yank-last-arg from GNU readline so you'll find it in bash emacs mode, but not in many other shells.

@rtrad89
Copy link

rtrad89 commented Jul 9, 2024

Does anyone know if there have a shortcut to show all Snippet? image I'd like to show all snippets, and then choose one using the up/down arrow key.

+1

@ciaranmckenna
Copy link

Is there a shortcut to group related tabs together? For example I have a number of services within a parent folder, I'd like to group them for navigation ease. Much like the chrome offering of grouping tabs.

@alex-berk
Copy link

@ralexrdz you can go to iterm settings -> Profiles -> Keys -> General and set Left Option key to Esc+, alt+. and other alt+... keybindings will start working

@equiman
Copy link

equiman commented Oct 8, 2024

I would like to add these ones:

Shortcut Function
^ + X + E Open editor with current command (specially good for editing long commands)
^ + Q Park current command (you lost run a command before, save it memory while run a command first)
^ + X a Reveal an alias

Default editor can be changed with preferred, mine: export EDITOR="code -w"

@steezeburger
Copy link

Did an update with something change this? All of a sudden cmd arrows don't change tabs.

@jchoca
Copy link

jchoca commented May 4, 2025

Is there any way to duplicate a tab into a new tab with a keyboard shortcut? I find myself having to ctrl + t to make a new tab, cycle back to the original tab, right click on the tab, and then duplicate it. Catch is that the original tab has to be color coordinated or I'll accidentally delete the duplicated tab. Additionally, you can't duplicate a tab in the right-click context menu unless it's actually in tab form, not window form, which is why I need to make an arbitrary tab in the first place, and at this point I wonder if it would just save more time to manually cd into my desired directory.

EDIT: I have found a workaround, sort of. In the settings, I discovered I can show tabs even when there's only one tab. This will make duplicating them a lot easier, however, I still wasn't able to figure out how shortcuts work. To the docs..

@Arbyrd33 for each profile you can go into the key bindings and add a new one (Profiles -> {select profile} -> Keys -> "+"), then bind command+t to open a new tab and choose the profile you're currently editing. I did this and now when I press cmd+t it opens the current profile I'm in.

@ecbaldwin
Copy link

⌘ + Shift + arrow-up
⌘ + Shift + arrow-down
For navigating marks. If shell integration is enabled all commands are marked automatically, and you can quickly go to previous commands and their output.
βœ…

I didn't understand that when I navigated to pre/next Mark, the cursor was still in the same position.

so what is the point of navigation?

This isn't really to replace your shell's command history browsing, it is command output browsing. You can navigate to a previous command and see it isolated with its output. You can select it and copy it if you need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment