iTerm2 should require little explanation for users accustomed to terminal emulators. Even if you are an experienced user, take the time to read through the highlights section of this document. It will familiarize you with some features of iTerm2 that you may not have seen in other terminal emulators that can make a real difference in the way you work.

If you're having problems, please use the Bug Reporter.

Table of Contents


Highlights for New Users

This chapter describes features of iTerm2 that go beyond basic usage and are not generally found in other terminal emulators.

Text Selection

There are several ways to select text to copy to the clipboard:

  • You can use the mouse.
  • You can use the find feature's "mouseless copy" feature.
    To select text without using the mouse, press cmd-f to open the find field. Enter the beginning of the text you wish to copy and the find feature will select it in your window. Then press tab and the end of the selection will advance by a word. To move the beginning of the selection to the left, press shift-tab. At most one line of text can be selected this way.
  • You can use Copy Mode.
  • You can bind keystrokes to create and adjust selections.
    In Prefs > Profiles > Keys you can assign keys to move the beginning or end of the selection by a single character, word, or line. No such keys are bound by default.

Split Panes

iTerm2 allows you to divide a tab into many rectangular "panes", each of which is a different terminal session. The shortcuts cmd-d and cmd-shift-d divide an existing session vertically or horizontally, respectively. You can navigate among split panes with cmd-opt-arrow or cmd-[ and cmd-]. You can "maximize" the current pane--hiding all others in that tab--with cmd-shift-enter. Pressing the shortcut again restores the hidden panes.

Hotkey Window

iTerm2 offers a special terminal window that is always available with a single keystroke. This window is called the "hotkey window" and is most commonly used for occasional administrative tasks. It is described in Hotkeys.

Swap Cmd and Option

iTerm2 allows you to remap modifiers. You have separate control over left and right command and option keys. One common need is to exchange cmd and option. To do this, go to Settings > Keys. Set Left option key to Left command key and Left command key to Left option key (and do the same for Right command and Right option if you please). You can add exceptions if you don't want certain combinations to be remapped (for example, cmd-tab) by adding a new global shortcut with the action “Do Not Remap Modifiers” and the keystroke of the (unremapped) key you wish to keep unaffected by modifier remapping.

Save Mark/Jump to Mark

You can mark a location in a session with cmd-shift-M and then jump back to it with cmd-shift-J. This is useful, for instance, if you suspend your editor to compile a program and it emits errors. You can save a mark at that point and then return to your editor to fix the errors. As you work, you can jump back to the compilation errors with cmd-shift-J.

Regular Expression Search

When you open the find field (cmd-f) there is a down-arrow on the left of the field by the magnifying glass. Clicking it opens a menu of options in which you can enable regular expression search. The ICU syntax is used.

Autocomplete

Any text that exists in a tab or its scrollback buffer can be autocompleted in that tab. To use autocomplete, type the beginning of a word and then press cmd-;. An autocomplete window opens showing the top 20 choices for words beginning what you have entered. The list can be filtered by typing a subsequence. The filter can be reset by pressing backspace. If you make a selection and press return, it will be entered for you. If you make a selection and press tab, your autocomplete will be extended with the selection.

Paste History

Whenever text is copied or pasted in iTerm2 it is added to the paste history. You can access paste history with cmd-shift-H. It can be filtered by typing a subsequence, and the filter can be cleared by pressing backspace. You can choose to have your paste history saved to disk by turning that option on under Settings > General > Save copy/paste history to disk.

Instant Replay

Sometimes interactive programs will overwrite something of interest on the screen (for example, top(1) does this all the time). Normally, this would be lost forever. With Instant Replay, you can step back in time to see exactly what was on your screen at some point in the recent past. To enable, press cmd-opt-B. Once you are in instant replay mode, you can use the left and right arrow keys to navigate back and forward through time. Esc exits instant replay mode. By default, each session uses up to 4MB to save its instant replay history, and this can be adjusted under Settings > General > Instant Replay uses __ MB per session.

Another benefit of Instant Replay is that it shows you the exact time that something appeared on your screen down to the second. This is useful when trying to figure out when an error occurred, for example.

Full Screen

You can press cmd-enter and iTerm2 will take up the entire screen. If you had a transparent background configured, it will be turned off upon entering full screen mode to reduce distractions. You can re-enable it with cmd-U. Unlike most macOS apps, iTerm2 can open a fullscreen window in the same desktop with no annoying animation if you disable Settings > General > Native full screen windows.

High-Color Modes

iTerm2 supports 256 color mode. To enable this for csh shells, set your terminal to xterm-256color (under Settings > Profiles > Terminal > Report Terminal Type). Some applications may need to be configured to support this mode. In vim, add this to your .vimrc:

set t_Co=256

iTerm2 also supports 24-bit color.

Focus Follows Mouse

This option is off by default, but can be enabled under Settings > Pointer > Focus follows mouse. It only affects iTerm2 windows.

Middle Button Paste

If you have a three-button mouse, by default the middle button performs "paste". You can configure the behavior of the middle button, as well as many other kinds of clicks and gestures, in Prefs > Pointer.

Cursor Finery

When using a block cursor, it's hard to pick a cursor color that's visible against every background color. If you enable Smart cursor color (under Settings > Profiles > Colors) then the cursor color will be dynamically chosen to be visible against the text it is over and the adjacent cells.

If you prefer a white or black cursor, you can use the "cursor boost" feature (under Settings > Profiles > Colors) to make all colors other than the cursor dimmer.

Do you have trouble finding your cursor? You can turn on the cursor guide by toggling the View > Show Cursor Guide menu item or turning on Settings > Profiles > Colors > Cursor Guide. This can also be toggled by an escape sequence. For example, add this to your .vimrc:

let &t_ti.="\<Esc>]1337;HighlightCursorLine=true\x7"
let &t_te.="\<Esc>]1337;HighlightCursorLine=false\x7"

If you've lost your cursor, press Cmd-/ or select View > Find Cursor and the cursor's position on the screen will be indicated very clearly

Minimum Contrast

Sometimes an application will display text with a color combination that is hard to read. Colorblind users in particular may find certain combinations hard to see if the colors differ only in hue and not brightness. If you enable minimum contrast (under Settings > Profiles > Colors > Minimum contrast, then iTerm2 will guarantee a minimum level of brightness difference between the foreground and background color of every character. If you set this to its maximum value, then all text will be black or white.

Notification Center Support

If you enable notifications (Settings > Profiles > Terminal > Send Notification Center alerts) then you'll receive messages when a terminal beeps, has output after a period of silence, or terminates. There's also a proprietary escape sequence to send a notification. You can adjust the kinds of notifications that get posted in Settings > Profiles > Terminal > Filter Alerts.

Window Arrangements

You can take a snapshot of your open windows, tabs, and panes with the menu option Window > Save Window Arrangement. You can restore this configuration with Window > Restore Window Arrangement, or you can choose to have it automatically restored when you start iTerm2 with Settings > General > Open saved window arrangement.

Smart Selection

Performing a quad-click does a "smart selection," which selects text under the pointer in a way appropriate to its content. For example, URLs, quoted strings, and email addresses (among many other objects) are recognized and selected in their entirety. You can also bind actions to a smart selection rule. The first action takes effect when you cmd-click on text matching the rule. All actions are added to the context menu when you right click on text matching the rule.

Triggers

Triggers are user-configurable actions that run in response to activity in a session. Most fire when received text matches a regular expression, but a trigger can also fire on events such as a command finishing or a job starting. Actions include highlighting the matching text, showing an alert, sending text back, and more. See the Triggers documentation for the full details.

One advanced use of a trigger is to capture output matching a regex and display just those matching lines in the toolbelt. For example, you could create a trigger that matches compiler errors. When you run Make the errors will appear on the side of your window and you can click each to jump right to it. More information is available at the Captured Output manual.

Tmux Integration

iTerm2 is tightly integrated with tmux. The integration allows you to see tmux windows as native iTerm2 windows or tabs. The tmux prefix key is not needed, as native menu commands operate on tmux windows. For more information, please see the iTerm2-tmux Integration document.

Coprocesses

Coprocesses are programs that run alongside iTerm2 and are bound to a single session. All output bound for the session is also routed as input to the coprocess. The coprocess's output acts like the user typing at the keyboard. Coprocesses can be used to automate tasks. For more information, see the Coprocess document.

Dynamic Profiles

If you have hundreds or thousands of profiles, look in to Dynamic Profiles. This feature allows you to define profiles in JSON.

Automatic Profile Switching

You can automatically change the current session's profile using Automatic Profile Switching. For example, this would allow you to change the background color when you are on a production system.

Inline Images

iTerm2 can display images inline, including animated GIFs. The easiest way to use this feature is to install Shell Integration and Utilities, which adds an imgcat script.

Undo Close

If you accidentally close a session, you get five seconds (by default; configurable in Settings > Profiles > Session) to undo it with Shell > Undo Close (Cmd-Shift-T).

Shell Integration

Shell Integration is a feature exclusive to iTerm2 that uses knowledge about your shell prompt to help you navigate from one shell prompt to another, record your command history, suggest most used directories, helps you re-run commands, download files from remote hosts with a click, upload files to remote hosts with drag and drop, and more. See the Shell Integration documentation for all the details.

Password Manager

iTerm2 can save your passwords in the Keychain or use your existing password manager, such as 1Password. Use the Window > Password Manager menu item to open the password manager and enter your passwords. See Password Manager for details.

Timestamps

Toggle View > Show Timestamps to indicate the time each line was last modified. This is useful for telling how long operations took or when a message was printed.

Tab Bar on Left

You can position the tab bar on the left side of the window. This is useful if you have a really large number of tabs.

Open Quickly

If you have lots of sessions you can quickly find the one you're looking for with Open Quickly. Select the View > Open Quickly menu item (cmd-shift-O) and then enter a search query. You can search by tab title, command name, host name, user name, profile name, directory name, badge label, and more. Open Quickly also lets you create new tabs, change the current session's profile, and open arrangements. If you start your query with a / then that gives you a shortcut to various commands. Enter a query of / to see them.

Shell Integration and Utilities

Shell integration consists of a shell script that's loaded when you create a new session or ssh to a remote host. It modifies your prompt so iTerm2 knows where it is. This enables a number of features, such as Copy Output of Last Command, Automatic Profile Switching when changing hosts, and more as described in Shell Integration. When you install Shell Integration you'll be prompted to also install its Utilities. The Utilities are a collection of shell scripts that use iTerm2's unique features and make them easy to use. For example, you can upload or download files from a remote host, copy to the pasteboard from the command line (even over ssh!), and make fireworks explode from the cursor. It's described in Utilities.


General Usage

Tabs

When you first start iTerm2, a window opens showing a terminal session. If you want to open more than one session at a time, you have a few options: You can create a new window (Shell > New Window), you can create a new tab (Shell > New Tab), you can split the current session into two panes (Shell > Split Horizontally, Shell > Split Vertically), each of which is a separate session, or you can open a floating pane that floats over the tab’s split panes (Shell > New Floating Pane with Current Profile).

Tabs in iTerm2 behave like tabs in other programs, most notably web browsers like Safari, Firefox, and Google Chrome. Note that you can drag and drop tabs to reorder them within a window. You can drag tabs from one window to another, and you can drag a tab from a window into a new window by dropping it outside any iTerm2 window's tab bar. To move the current tab with the keyboard, use Window > Tab > Move Tab > Move Tab Left and Move Tab Right.

You can organize a window’s tabs into named, colored tab groups, and nest a group inside another one.

Right-click a tab for a menu of things you can do with it, including Rename Tab… (which opens the same tab title dialog as double-clicking the tab or Window > Tab > Edit Tab Title), Duplicate Tab (which opens a copy immediately to the right of the original), Move to New Window, Pin Tab, Tab Color, and commands for closing tabs and adding the tab to a group. When the tab bar is on the left or right side of the window, the menu says New Tab Below and Close Tabs Below instead of “to the Right”, since the tabs run from top to bottom.

By default, the label of each tab is the name of the job that's running in that session. Some systems are configured to augment this with additional information such as the hostname you're logged in to or your current directory (this is done by sending a special code of ESC]0;string ^G).

Tab labels have indicators that tell you their status. A blue dot means new input was received. An activity indicator means new output is being received. When the session ends, a ⃠ icon appears in the tab. You can customize these indicators in Settings > Appearance.

Language

iTerm2’s interface follows your preferred language in System Settings > General > Language & Region. It is available in English (including British, Australian, Canadian, Indian, and Philippine English), Brazilian and European Portuguese, Cantonese, Catalan, Croatian, Czech, Danish, Dutch, Finnish, French (including Canadian French), German, Greek, Hindi, Hungarian, Indonesian, Italian, Japanese, Korean, Malay, Norwegian Bokmål, Polish, Romanian, Russian, Simplified Chinese, Slovak, Slovenian, Spanish (including Latin American and US Spanish), Swedish, Thai, Traditional Chinese (including Hong Kong), Turkish, Ukrainian, and Vietnamese.

Running More Than One Copy

If you launch a second copy of iTerm2 while one using the same settings is already running, iTerm2 warns you that the two could overwrite each other’s preferences and saved windows. Click Quit to switch to the copy that is already running, or Launch Anyway to keep going.

Edit Current Session

The Edit Current Session panel lets you modify the appearance of a single session. If you customize some attribute of the session (for example, by changing the default text color) then subsequent changes to that same attribute in the profile will not affect the customized session. However, changes to other attributes of the profile will affect the customized session.

Pointer

The primary use of the mouse in iTerm2 is to select text, and (by default) text is copied to the clipboard immediately upon being selected. You can click and drag to perform a normal selection. Double-clicking selects a whole word. Triple-clicking selects an entire line. Quadruple-clicking performs a "smart select", matching recognized strings such as URLs and email addresses. You can add custom pointer actions in Settings > Pointer. I recommend using three-finger tap for smart selection, but you must ensure that System Settings > Trackpad does not have any other action already assigned to three-finger tap.

If you hold shift while clicking the existing selection is extended. In fact, you can single click in one location and shift click in an other location to make a selection: no dragging needed.

If you hold cmd while dragging it will create a noncontiguous selection.

If you hold cmd and click on a URL it will be opened. If you hold cmd and click on a filename, it will be opened. There is special support for MacVim, TextMate, and BBEdit when you cmd-click on a text file's name: if it is followed by a colon and line number, the file will be opened at that line number. The current directory is tracked if you have your shell prompt set the window title, as described here, or if you have Shell Integration installed.

If you hold cmd and option while selecting, a rectangular selection will be made.

If mouse reporting is enabled (in Settings > Profile > Terminal) and the currently running terminal application is using it, pressing option will temporarily disable it so you can make a selection.

Right clicking on certain values shows helpful information in the context menu:

  • Right-clicking on a number shows its conversion to or from hex, or if it looks like a unix timestamp its representation in local time will be shown.
  • Right-clicking on a non-ASCII character shows its code point and UTF-8 representation.

You can configure your pointing device's scroll gesture to send arrow keys in interactive programs by turning on Settings > Advanced > Scroll wheel sends arrow keys when in alternate screen mode, but it will only work if Settings > Profiles > Terminal > Disable save/restore alternate screen is turned off.

A three-finger swipe left or right on a trackpad (if configured to "navigate") will select an adjacent tab.

Middle clicking on a tab (if your pointing device has a middle button) closes it.

Keyboard

Every aspect of the keyboard can be configured in iTerm2. These keystrokes may be useful to remember:

  • Cmd+left arrow, Cmd+right arrow navigates among tabs. So does Cmd-{ and Cmd-}.
  • Cmd+number navigates directly to a tab.
  • Cmd+Option+Number navigates directly to a window.
  • Cmd+Option+Arrow keys navigate among split panes.
  • Cmd+] and Cmd+[ navigates among split panes in order of use.

You can configure any key combination to perform any action in two places: in Settings > Keys, you can define global key shortcuts that affect all profiles. In Settings > Profiles > Keys, you can define key shortcuts that affect only a single profile.

You can remap modifiers like Option and Cmd within iTerm2. Some users find that pressing Option frequently is uncomfortable, and configure iTerm2 to swap the function of the Option and Cmd keys. This is done in Settings > Keys > Remap Modifiers. If there is some key combination that you don't want to be affected by this change (such as Cmd-tab) add a new global shortcut key with the action Do Not Remap Modifiers.

iTerm2 allows you to define a global hotkey. This is a single keystroke that iTerm2 listens for even when another application has keyboard focus. When it is pressed, iTerm2 comes to the front. Press it again, and iTerm2 goes away. You can choose to bind the hotkey to a single dedicated window. For more on the hotkey window and other uses of hotkeys, see Hotkeys.

Context menus

By right-clicking in a session a context menu opens. You can use it to open a new session, perform various actions on selected text, or access frequently used features to affect the clicked-on session.

Profiles

Many settings are stored in profiles. A profile is a named collection of settings, and you can have as many of them as you like. Most users only have one profile, but if you find that you often connect to different servers, they may be useful for you. A key feature of a profile is that you can associate a command with it that is run when it begins. For instance, if you often ssh to a particular host, you could create a profile with the command "ssh example.com" to automate that process.


General Preferences

General


Startup

Window restoration policy

This setting determines how windows will be opened when iTerm2 is launched. Most users will want Use System Window Restoration Setting as it works best with Session Restoration. Users who exclusively use the Hotkey Window may prefer Only Restore Hotkey Window, which will not restore regular windows but will restore the hotkey window. If you have a default window arrangement saved then Open Default Window Arrangement will be available.

Open profiles window

If selected, the Profiles Window will automatically open when iTerm2 is started.

Restore windows to same Spaces

macOS apps do not typically restore windows to the same Space (aka Desktop) that they were originally on except on system restart. When this setting is enabled, iTerm2 will attempt to restore windows to their original Spaces.

Always open at least one terminal window at startup

If you have a hotkey window defined then iTerm2 won't open a regular window on launch. If you'd prefer to always have a visible window in addition to the hotkey window, enable this setting.


Closing

Quit when all windows are closed

If selected, iTerm2 will automatically quit when its last terminal window is closed.

Confirm closing multiple sessions

If selected, commands that close one session will not be confirmed, but commands that close multiple sessions (such as clicking the red button on a window with two or more tabs) will be confirmed with an alert box.

Confirm “Quit iTerm2 (⌘Q)”

If selected, the Quit iTerm2 (cmd-Q) command will be confirmed if any terminal windows are open.

Even if there are no windows

Modifies Confirm “Quit iTerm2 (⌘Q)” to disable the prompt when there are no open windows.

Disable all confirmations on system shutdown, restart, and log out

When enabled, iTerm2 will never block system shutdown, restart, and log out by asking for confirmation. Enabling this setting could cause you to lose work.


Magic

Add Bonjour hosts to Profiles

If selected, all Bonjour hosts on the local network have a profile created for them as long as they're around.

Instant Replay: Memory usage per session (in MB)

This setting specifies the maximum amount of memory allocated to instant replay for each tab or split pane. More memory means instant replay is able to go farther back into the past. You can enter instant replay with View > Start Instant Replay.

Save copy/paste and command history to disk

If selected, every time text is copied or pasted in iTerm2 it will be saved to disk. The last 20 values are recorded. They can be accessed with Edit > Open Paste History.... If you use Shell Integration then when this is enabled your command history, directory history, and remote hostname and usernames will also be saved to disk. Unchecking this will erase all of the saved information.

Enable Python API

Toggles the availability of the Python API. See Python API Authentication for details on the security model.

The menu beside it chooses how apps that connect to the API are authorized. Require “Automation” permission (the default) only lets an app connect if macOS has given it Automation permission to control iTerm2. Allow all apps to connect turns off that check for every app on your Mac; choosing it asks for administrator access.

Manage Permissions…

Opens a window with two tabs:

  • Browser Scripting - Before a Python API script loads URLs or runs JavaScript on a website in a browser session, iTerm2 asks you. Remembered answers are listed here, one row per website and kind of permission (Run JavaScript or Load URLs), and apply to all scripts. Uncheck Allowed to always deny a website, use the minus button to forget an answer so iTerm2 asks again, or use the plus button to allow a website in advance.
  • API Access over SSH - Lists the remote hosts reached through SSH Integration that may use the iTerm2 API (for example, with it2) without asking first. A host is added here when you choose Always Allow This Host at its prompt. Removing a host makes it ask again the next time it connects.

Custom Python API Scripts Folder

Normally Python API scripts go in ~/Library/Application Support/iTerm2/Scripts but if you'd prefer to have them elsewhere you can specify the path with this setting.

GPU rendering

The GPU renderer improves drawing performance, but it may use more energy. You can also configure when it is enabled with the Advanced GPU Settings… button.

The advanced settings are:

  • Disable GPU renderer when disconnected from power - Use this to conserve energy when not plugged in and to get the best drawing performance when connected to power.
  • Disable GPU renderer in low power mode - Turns off the GPU renderer while macOS Low Power Mode is on.
  • Prefer integrated to discrete GPU - If your machine has two GPUs, enable this to use the slower but less power-hungry GPU. This is unavailable on a Mac with only one GPU, and you must restart iTerm2 for a change to take effect.

Maximize throughput at the cost of higher latency

When this is enabled:

  • The frame rate will be reduced when a lot of data is being received.
  • Input handling is prioritized over redrawing, reducing the maximum frame rate.

You probably need to disable this to hit 120 FPS.

Sessions processing output at once

Limits how many sessions can process terminal output at the same time, so heavy output in many sessions can't use all of your CPU. The slider ranges from 2 to the number of CPU cores in your Mac. When Automatic is checked (the default), the limit is a quarter of your cores, but never less than 2 or more than 4.

This applies only with the new implementation of session input and output, in which each session handles its output independently so that heavy output in some sessions doesn't make typing lag in others. It is on in beta builds and for a share of other users; when it is off, the slider and checkbox are disabled. If you suspect the new implementation of causing a problem, search Settings > Advanced for “new implementation of session input”, turn that setting off, and restart iTerm2. A separate advanced setting, “Limit how many sessions process output at once”, turns off only this limit.


AI > General

Plugin

To use AI features you must install the AI plugin. The plugin's status is shown next to this label. If the plugin isn't detected, an Install… button opens the plugin's download page (it is disabled when the advanced setting “Allow the use of large language model APIs?” is off); iTerm2 rechecks for the plugin every ten seconds until it is found. Once the plugin is installed and working, the button becomes Reveal in Finder. The ↻ button reloads the plugin and checks its status again, which is useful after you install or update it.

Consent: Enable generative AI features

You must consent to AI features before they can be used. This is a secure user default which requires you to enter an administrator password to change.

API Key: Set API Key…

Because AI features depend on your provider's API, you must provide your own API keys. The Set API Key… button opens a sheet with a field for each provider that uses one: OpenAI, Anthropic, Gemini, DeepSeek, and Grok (an xAI API key). Unlike most settings (which are saved in user defaults), API keys are stored in the macOS Keychain to prevent unauthorized access. Ollama runs on your own computer and needs no key.

A provider's stored key is sent automatically only to that provider's own servers. To send a key to another endpoint, such as a gateway, choose it in the model's API key setting (see Manual AI Models below).

AI Model

Selects the default model for AI features. The menu lists the built-in providers (OpenAI, Anthropic, Gemini, DeepSeek, Grok, and Ollama), followed by any models you have configured manually. When you choose a provider, iTerm2 uses its recommended model, which is normally its newest flagship model; to use a different built-in model, add it in Manage AI Models… by picking it from the Preset menu. iTerm2 knows each built-in model's context window (up to 1 million tokens for recent Claude models) and, where the provider offers one, uses a smaller, cheaper model from the same provider for frequent background jobs.

Beneath the menu, a note says which API key will authorize the selected model and whether that key has been entered.

When you choose Ollama, iTerm2 lists the models installed on your Ollama server at http://localhost:11434, reading each model's context window and capabilities (thinking, tools, and vision) from the server, so there is nothing to configure. Two menus appear in place of the note: Regular picks the model used for chats, and Budget picks a smaller model for quick background tasks (by default, Same as regular model). If no models are found, make sure Ollama is running. For an Ollama server on another computer, add a manual model with the Ollama (auto-discover) or Ollama (native) preset.

Manage AI Models…

Opens the Manual AI Models panel where you can add, edit, duplicate, and delete models. You can mark one model as the default (shown with a star) and another as the economy model (a cheaper model used for frequent background jobs, such as command safety checks; shown with a leaf). See Manual AI Models below for the per-model fields.

Timeout

How long to wait, in seconds, for more data from the AI provider before giving up. This is an idle timeout, not a limit on the total time a request may take: a slow but healthy response, such as a reasoning model that is still thinking or a local model that is loading, keeps going as long as data keeps arriving, while a dead connection still fails. The default is 1200 seconds (20 minutes).

Use AI to check safety of commands before running them

When enabled, iTerm2 checks a command with AI before it is run automatically. Deterministic rules run first, and AI is consulted only when those rules are inconclusive. The check uses the economy model when there is one (the one you marked in Manage AI Models…, the Budget model for Ollama, or otherwise a smaller, cheaper model from your provider), so it costs less than using your chat model. If you previously chose on-device Apple Intelligence for this check, it keeps using Apple Intelligence. This is opt-in and off by default.

Enable “zero data retention” (send whole conversation every time)

Turn this on if your OpenAI organization has Zero Data Retention enabled. iTerm2 then stops sending previous_response_id and sets store=false so that no response state is retained on the server. Leave it off otherwise, since it disables some optimizations.

Automatically update available AI models from live online database

When enabled, iTerm2 periodically refreshes the list of available models from an online database so newly released models appear without waiting for a software update. This is on by default. The Update Now button checks immediately.

AI > General > Manual AI Models

Reached through the Manage AI Models… button. This panel lists your manually configured models and lets you add, edit, duplicate, or delete them. A starred model is the default and another may be marked as the economy model. Each model has the following fields, edited in the add/edit sheet:

Preset

Fills in the form from a starting point you can then adjust. The menu lists every built-in model, followed by presets for other services: Ollama (auto-discover), Ollama (native), Local OpenAI-compatible (LM Studio, vLLM, …), OpenRouter, z.ai (GLM), Qwen (DashScope), and MiniMax. A service preset fills in the URL, API, and capabilities but leaves the model name for you to enter. Choosing a preset also clears the custom headers and resets the API key choice, so credentials meant for one endpoint aren't sent to another.

Model

The name of the model to use. This value is sent in the API request.

The Fetch Models button beside it asks the server for its list of models so you can pick one instead of typing its exact name. It works with Ollama and with OpenAI- and Anthropic-compatible servers such as vLLM, LM Studio, and llama.cpp. It isn't available for the Google Gemini API.

URL

The URL to send requests to. This may be the full endpoint, or a base URL such as http://localhost:8000/v1 or a gateway's Anthropic-compatible base URL such as https://api.z.ai/api/anthropic. When the URL has no path, or its path ends in a version (like /v1 or /v1beta), /anthropic, or /openai, iTerm2 adds the endpoint for the chosen API (for example, /chat/completions or /messages); a URL with no path gets /v1 first. Any other URL is sent exactly as you typed it. For the Ollama API, only a bare server URL such as http://localhost:11434 is completed. A Google Gemini URL must be the full endpoint.

API

Which style of API to use: Responses, Chat Completions, Anthropic, Google Gemini, DeepSeek, Ollama (the native Ollama API), Completions, or Chat Completions (Early O1).

API key

Chooses which key is sent with requests to this model:

  • Automatic - iTerm2 infers the provider from the API, URL, and model name, and its title shows the key it picked, such as Automatic (OpenAI API key). It sends a provider's key only to that provider's own servers, so no key is sent to a local endpoint or to a third-party gateway such as OpenRouter. In those cases it reads Automatic (none for a local endpoint) or Automatic (none for this endpoint).
  • (Provider) API key - Always sends that provider's stored key, wherever the model's URL points.
  • This model's own key - Sends a key you enter in the field beside the menu, used only for this model.
  • None - Sends no key.

A note below the menu explains which key will be sent. If your endpoint needs some other form of authentication, use a custom header. Models you set up before this setting existed keep sending the key they sent before.

Discover installed models automatically (Ollama)

When enabled, this entry lists the models installed on the Ollama server at its URL, along with each model's context window and capabilities, instead of naming one model. The Model field becomes a menu where you can choose one discovered model or all installed models, the capability and token limit settings are disabled because the server provides them, and Fetch Models becomes Refresh Models.

Context tokens and Max response tokens

Give the maximum number of tokens in the context and in a response. If these values are too high your requests may fail.

Vector store

Choose OpenAI to use OpenAI's vector store for file uploads, or Disabled.

Features

The following features are available. Not all APIs support all features.

  • Function calling - Most APIs support this
  • Streaming responses - Most APIs support this
  • Vision (image input) - Enable this if the model accepts images
  • Hosted web search - OpenAI Responses API only
  • Hosted file search - OpenAI Responses API only
  • Hosted code interpreter - OpenAI Responses API only

Configurable thinking

Enable this for reasoning models with a thinking mode (such as GPT-5, the o-series, or DeepSeek models) so the chat's Think toggle appears.

Supports temperature

Enable this if the model accepts a temperature parameter. Some models, such as Anthropic Opus 4.7 and later, reject requests that include one.

Custom headers

HTTP headers to send with every request to this model, such as an Authorization header for an authenticated self-hosted or gateway endpoint. Use the plus and minus buttons to add and remove headers.

Test Connection

Sends a test request using the values in the form so you can check them before saving.

AI > General > Prompts

Here you can edit the prompts. Values in \(...) are substituted. The exact substitutions depend on which prompt it is. For more information on interpolated strings, see Variables.

  • Edit > Engage Artificial Intelligence - This prompt is sent when you select the Engage Artificial Intelligence menu item. ai.prompt is replaced with the text at the cursor or the manually entered prompt.
  • AI Chat (no function calling), AI Chat + Read-Only Terminal Access, AI Chat + Full Terminal Access, and the three + Browser Access variants - These prompts are used depending on which permissions are enabled.
  • AI Chat + Orchestration - Used for orchestration chats.
  • Code Review System Prompt - Available to a Workgroup's Code Review session as \(codeReviewSystemPromptFile), the path of a temporary file holding the prompt. See Workgroups.
  • Chat List Icon - Used to pick an icon for a chat in the chat list. ai.subject is replaced with the chat's title.

The Reset button restores the selected prompt to its default.

AI > Features

These settings define the default permissions for new chats. Each can be set to Ask Each Time, Allow Without Asking, or Never Allow (View Contents offers Provide Automatically in place of Allow Without Asking).

Check Terminal State

This exposes information about the linked terminal to AI, including the current directory, user shell, the current or last command and its exit status, the size of the terminal window, the host you are SSHed to (if any), and the current username.

Run Commands

This makes functions available to AI that let it execute commands on your behalf.

Control Terminal

This makes functions available to AI that let it send keystrokes to the terminal. It also lets AI restart a session.

View Contents

This exposes the contents of the linked session to AI, including your command history. When it is set to provide contents automatically, a session-bound chat also includes the terminal's visible screen with each message you send.

View Manpages

This lets AI view manpages. If you are using ssh integration, man pages from the remote host may be viewed by it.

Write to Clipboard

This makes functions available to AI that let it write to the clipboard.

Write to Filesystem

This makes functions available to AI that let it write to the filesystem.

Act in Web Browser

This makes functions available to AI that let it view the contents of the current web page (applicable only in browser profiles).

Offer AI command suggestion in Composer & Auto Composer

When enabled, as you type in the Composer what you have entered and relevant files or commands are sent to AI so it can make suggested completions. Usually a suggestion finishes what you typed, but if you type a plain-English request (such as “find large files”) instead of the start of a command, the suggested command replaces what you typed instead of being appended to it. This is disabled by default because it is not very privacy-friendly.


Software Update

Update to Beta test releases

If enabled, iTerm2 will periodically check if a new unstable version of iTerm2 exists, and if so it will prompt you to download and upgrade. Nightly builds can't update to beta or release builds, so this is disabled in them.

Check for updates automatically

If enabled, iTerm2 will periodically check if a new version of iTerm2 exists, and if so it will prompt you to download and upgrade.

Ignore non-critical shell integration updates

If enabled, you won't be notified of updates to shell integration unless there is a security problem or other critical issue. Shell integration update notifications are shown when the shell integration script is loaded (when you log in or ssh somewhere that has it installed).


Selection

Copy to clipboard on selection

If enabled, text is copied to the clipboard immediately upon selection. If not selected, you must select Edit > Copy to copy it.

Copied text includes trailing newline

If enabled, a terminal newline will be copied to the pasteboard when the selection includes one; otherwise, no selection will ever include a terminal newline.

Applications in terminal may access clipboard

If enabled, clipboard access will be granted via escape code to programs running in iTerm2. They will be able to set the contents of the system pasteboard. For more details, see Shell Integration Utilities.

Allow sending of clipboard contents?

An app running in the terminal can request that the terminal transmit the clipboard contents to it. Since this is a security risk, it normally requires you to consent each time.

Triple-click selects entire wrapped lines

If enabled, a triple click selects a whole line, even if it was longer than one row in the terminal. If off, then triple click selects exactly one row.

Double-click performs smart selection

If enabled, double click performs smart selection instead of word selection as is standard on macOS.

Automatically enter copy mode on Shift+Arrow key with selection

If enabled, pressing shift-left or shift-right will enter copy mode when a selection exists.

Characters considered part of a word

When you double-click in the terminal window, a “word” is selected. The menu beside this setting chooses how words are defined:

  • List of Characters - The OS's algorithm for word selection is used, but it's extended to also include the characters in the field. For example, by adding / to this field, double-clicking on a path/like/this would select the entire path instead of just one component.
  • Regular Expression - A word is text that matches the regular expression in the field.

Clicking on a command selects it to restrict Find and Filter

When enabled, clicking on a command dims other commands and then Find, Filter, and Select All operate only on the selected command. This requires shell integration.

When pasting a dropped filename, wrap it in double quotes

When enabled, dropping a file into a terminal will ensure that its name is always quoted with ".


Window

New window placement

Chooses where new windows open and how big they are:

  • Let macOS decide the position of new windows and use size from profile - macOS places the window. Its size comes from the profile's columns and rows.
  • Remember the position of previously closed windows and use size from profile - This is the default. The window opens where a previously closed window was, and its size comes from the profile.
  • Remember the size and position of previously closed windows - The window takes both the size and the position of a previously closed window.
  • Smart Window Placement - New windows open where there is the most free space, so they overlap existing windows as little as possible.

Window positions are remembered per profile, so a new window opens where the last window using its profile was.

Adjust window when changing font size

If enabled, a change to a session's font will cause the window to grow or shrink.

Zoom maximizes vertically only

If enabled, the green “Zoom” button expands a terminal window vertically but does not affect its width. This can be overridden by holding down shift while clicking the zoom button.

Native full screen windows

If enabled, fullscreen windows will animate into a special desktop, as is typical in macOS. If disabled, fullscreen windows will instantly go fullscreen without changing desktops.

Each tab may have its own window title

The OSC 0 and OSC 2 control sequences set the window title. This setting controls whether such a control sequence changes the window title associated with all sessions in the window, or only with the one in which it was received.


Settings

Load settings from a custom folder or URL

If enabled, iTerm2 will load its settings from the specified folder or URL. Besides settings, iTerm2 can also sync your snippets, global notes, and session icon customizations through the folder. The first time this happens you'll be asked to consent, and if the same data was changed on more than one machine you'll be asked how to resolve the conflict.

Save changes

When you've turned on Load settings from a custom folder or URL, this menu chooses when changes you make to your settings are written to the custom folder: Automatically (as soon as you make them), Manually (the default; only when you click Save Now), or When Quitting.

Export All Settings and Data… / Import All Settings and Data…

If you need to back up/restore all of your settings, such as when moving to a new computer, use these buttons. The following are included:

  • Python API Runtimes
  • Secure user defaults (settings that require your password to change), including the Python API authorization setting
  • Everything in the Settings window
  • The contents ~/.iterm2, such as shell integration scripts.
  • The contents of ~/Library/Application Support/iTerm2 which has your toolbelt notes, dynamic profiles, and more.
  • Python API scripts
  • Optionally, passwords saved in the Password Manager

When the Password Manager keeps passwords in the Keychain, the export's save panel has a checkbox, Include saved passwords (encrypted with a passphrase). If you turn it on, you'll be asked to authenticate and to choose a passphrase, and the passwords are stored encrypted in the export file. When you import a file that includes passwords, you'll be asked for that passphrase; cancel to import everything else without them.

Importing may install Python runtimes and update secure settings, which may require your password, and then restarts iTerm2 to finish.

Erase All Settings and Data…

Offers to export your settings and data first, then erases everything: your preferences, profiles, saved sessions, scripts, and the contents of ~/.iterm2 and ~/Library/Application Support/iTerm2. iTerm2 quits immediately afterward. Items stored in the macOS Keychain (such as the AI API key and Password Manager entries) are not erased.


tmux

Open tmux windows as tabs in the attaching window

When enabled, tmux windows open as tabs in the window where you started tmux integration (where you ran tmux -CC).

When attaching, open unrecognized windows in

When the setting above is off, this menu defines how tmux windows should be mapped to native constructs. When attaching to a tmux session with the tmux integration, tmux windows not seen by iTerm2 before will open in either new Windows or Tabs in a new window, as specified by this preference.

Automatically bury the tmux client session after connecting

When the tmux integration is entered by running tmux -CC, the window in which that command was run will be buried.

Use “tmux” profile rather than profile of the connecting session

This used to on by default, but is no longer so as of version 3.3. When enabled, a copy of the Default profile is created, called tmux. When using tmux integration all tmux sessions will use this profile.

When disabled, the profile of the session in which you ran tmux -CC will be used for all tmux sessions.

Status bar shows tmux status bar content, not native components

When enabled, the status bar will contain the same content as the tmux status bar in its text-mode UI. When disabled, the status bar defined in the profile used for a tmux integration session will be used. This requires tmux 2.9 or later.

Pause a pane if catching up would take longer than (seconds)

When both a tmux integration and tmux text-mode UI client are attached to the same tmux session, the text-mode UI can sink data much faster than tmux integration can because it drops information between frames. In this case, a large buffer can grow in the tmux integration window. Once the time to catch up exceeds this number of seconds, the tmux integration session will be paused. That means it stops receiving new data. While paused, no more data will be added to its buffer and may be lost forever. You will be prompted by a notification at the top of the window to unpause the session. This feature is only available in tmux 3.2 and later.

Warn before pausing

If enabled, a notification is shown when a pause is projected to occur within half of the pause deadline. See Pause a pane if it would take more than X seconds to catch up for more detail on pausing.

Unpause automatically

When enabled, this unpauses the tmux session as quickly as possible after it is paused by tmux. It does not completely eliminate the possibility of data loss.

Mirror tmux paste buffer to local clipboard

tmux has a “paste buffer” which acts like its clipboard. When this option is enabled, the contents of the tmux paste buffer are copied into the system clipboard.

Experimental

Enable support for right-to-left scripts

When enabled, right-to-left scripts such as Arabic and Persian are reordered for display (bidi reordering) and their letters are joined in cursive form, instead of being drawn as plain left-to-right text. This setting also enables ligature support in the GPU renderer. This is on by default.

Use SSH integration for ssh: URLs

If enabled, use SSH integration when opening an SSH URL.


Appearance Preferences

Appearance


General

Theme

Allows you to select the theme. The theme affects how the areas outside the main terminal view are drawn, including colors and fonts.

The options are:

  • Regular - The standard macOS theme. Switches between dark and light mode automatically based on the system setting.
  • Minimal - This is inspired by the appearance of Electron apps. It is modern and streamlined.
  • Compact - A combination of Regular and Minimal. The standard colors are used, but the title bar is eliminated to save space.
  • Light - Regular theme but ignores system light/dark mode.
  • Dark - Regular theme but ignores system light/dark mode.
  • Light (High Contrast) - High contrast version of Light
  • Dark (High Contrast) - High contrast version of Dark

In Minimal and Compact, tabs go in the title bar if the tabs are on top. The area between the red, yellow, and green buttons and the first tab can be used to drag the window. If tabs are on the bottom or the right, you can move the mouse to the top left of the window to reveal the red, yellow, and green buttons. The area around them, when revealed, can be used to drag the window. With the tab bar on the left, the buttons are always shown at the top of the tab bar.

Because Minimal and Compact have no title bar, a window's name can be shown beside the tabs instead. It appears once you name a window with Window > Edit Window Title, so windows you haven't named look the same as before. Double-click the name to rename the window. With the tab bar on the left, or on the right while the window number or proxy icon is shown, the window's title is shown at the top of the tab bar beside the window buttons, window number, or proxy icon even if you haven't named the window, since it takes no room from the tabs there. The advanced setting “Show the window name beside the tabs in the Compact and Minimal themes” can change this to Never or Always.

Tab Bar Location

Defines whether tabs appear at the top, bottom, left, or right side of your windows.

Status Bar Location

Defines where the status bar appears, if enabled.

Auto-hide menu bar in non-native fullscreen

When native fullscreen mode is disabled (in Settings > General > Window), this option is available. When it is on, the menu bar is hidden while a non-native fullscreen window is on a screen with a menu bar, and appears when you move the pointer to the top of the screen. Turn it off if you'd like the menu bar to remain visible. Excluding iTerm2 from the Dock turns this off.

Exclude from Dock and ⌘-Tab Application Switcher

When this setting is enabled, iTerm2 will disappear from the dock and you won't be able to switch to it with Cmd-Tab. An icon will be added to the right side of the menu bar that lets you get back to iTerm2's Settings. This is useful if you only use hotkey windows and you want iTerm2 to keep a low profile. You should be warned that this is a buggy part of macOS and sometimes things misbehave in small ways when this is enabled.

When selected, you can also enable …but only if all windows are hotkey windows to bring back the dock icon when a non-hotkey window exists.

Show menu bar icon

Shows an iTerm2 icon in the menu bar. Click it for a menu with Settings, Bring All Windows to Front, Buried Sessions, Check For Updates, and a Main Menu submenu that mirrors iTerm2's menu bar. While iTerm2 is excluded from the Dock this is always on, since the icon is your way back to Settings.

Menu bar icon

An optional interpolated string shown beside the menu bar icon, evaluated in the global scope. For example, \(iterm2.workingSessionCount) shows how many sessions report that they are working (see Session Status), and iterm2.waitingSessionCount counts sessions that are waiting for you. If the string can't be evaluated, the icon shows that something is wrong and its menu has an item that shows the error.

Hide menu item icons

On macOS 26 and later, menu items show icons. Turn this on to hide them. On earlier versions of macOS the checkbox is disabled.


Windows

Show window number in title bar

If selected, window titles include the window number. You can navigate to a window by pressing cmd-opt-N where N is the window number. You can also change which modifiers are used in Settings > Keys.

Heavy border around windows in light mode

In light mode (or when there is a pane with transparency), window borders can be hard to see. Enabling this setting draws a thicker border around windows.

Hide scrollbars

If selected, scrollbars will be hidden in terminal windows.

Disable transparency for non-native fullscreen windows by default

If enabled, entering non-native fullscreen mode will automatically turn off transparency for that window. You can still turn transparency back on for a window with View > Use Transparency.

Show line under title bar when the tab bar is not visible

Turn this off for a sleek appearance with the dark theme.

Show proxy icon in window title bar

When enabled, an icon representing the current directory is added to the window's title bar. You can drag it. This also works in the Compact and Minimal themes, where the icon appears next to the window's stoplight buttons.


Tabs

Show tab bar even when there is only one tab

If selected, the tab bar will remain visible when a window contains exactly one tab.

Preserve window size when tab bar shows or hides

When enabled, the window will not change size as the tab bar is shown or hidden. Instead, the number of rows of text inside the window may change.

…but only if it would cause the window to go off-screen

Modifies the setting above so that the window keeps its size only when growing it to make room for the tab bar would push it off the screen. Otherwise, the window grows or shrinks.

Show tab numbers

If selected, tabs will indicate their keyboard shortcut.

Tabs have close buttons

If selected, tabs show close buttons. If not selected, the close buttons only appear when the mouse hovers over the tab.

Show activity indicator

If selected, the activity indicator in each tab will be displayed when new output is received and the tab is not selected.

Show new-output indicator

If selected, non-selected tabs will indicate they have unseen output with a blue circle in the tab.

Flash tab bar when switching tabs in fullscreen

If selected, the tab bar will show briefly when switching tabs in a fullscreen window. It will also show briefly when the number of tabs changes.

Show tab bar in fullscreen

If selected the tab bar will be visible in fullscreen windows.

Stretch tabs to fill bar

If selected, tabs will grow large enough to fill the entire tab bar, like system native tab bars. This is on by default.

Tab bar scrolls when tabs don't fit

When there are more tabs than fit in the tab bar, this option keeps the extra tabs in the bar and lets you scroll to reach them instead of moving them into an overflow menu. It works for tab bars on the top, bottom, left, or right. This is on by default.

New tabs open at end of tab bar

When enabled (the default), a new tab is added at the end of the tab bar. When disabled, it opens just after the current tab.

Show a list of tabs with a preview while cycling through tabs

This is the Control-Tab Switcher. When Cycle Tabs Forward or Cycle Tabs Backward is bound to a key with a modifier (Control-Tab and Control-Shift-Tab by default), holding the modifier shows the window's tabs, most recently used first. Each row shows the tab's icon, title, status (such as new output or a session status), where its session is, and when you last saw it, and a preview of the highlighted tab appears beside the list. Press the key again to move the highlight, or point at or click a row, and release the modifier to switch to the highlighted tab. Tapping the key quickly switches tabs without showing the list. This is off by default.

Support basic HTML tags in tab titles

When enabled the following HTML tags are supported in tab titles and in per-pane title bars, where they render as bold, italic, and underlined text: <b>, <i>, <u>. You can also use &lt; and &amp; for a literal < and &. The window title shows the text without the tags, including titles set by a program or by tmux.


Panes

Show per-pane title bars

When a tab has split panes, this option controls whether each split pane will have its own title bar.

…even if there is only one pane

Shows the per-pane title bar even in a tab that has no split panes.

Separate status bars per pane

When enabled, each pane gets its own status bar. When disabled, the window has a single status bar that shows information pertaining to the current pane.

Separate background images per pane

When disabled, the current pane's background image fills the window, spanning all panes.

Side/Top & Bottom margins

Margins are the area around terminal content that is usually empty. Note that the right and bottom margins may be larger than the value you specify here if the window size is not evenly divisible by the size of a single character. These values are in points.


Dimming

Dimming amount

This slider controls how much to dim inactive windows or panes.

Dim inactive split panes

If selected, split panes that do not have keyboard focus will be slightly dimmed.

Dim background windows

If enabled, windows in the background (that is, those not receiving keyboard input) are dimmed according to the above settings.

Dimming affects only text, not background

When a window or pane is dimmed, this option controls whether the background color is dimmed or only the text colors.


General Profile Preferences

Profiles

General

Name

Gives the name of the profile which is shown in menus, Settings, and the profiles window. This serves as the default session name for sessions created with this profile, which is an interpolated string.

Profile Type

If the browser extension is installed this lets you define whether this session is for a terminal emulator or web browser session. See Web Browser for more information.

Initial URL

In a web browser profile, this is the page a new session with this profile opens.

Shortcut key

This shortcut can be used to open a new window or tab. By default, it opens a new tab, but if you hold down the option key while pressing the shortcut, a new window will be opened instead.

Tags

Tags are a collection of words or phrases that annotate a profile. When you search your profiles (for instance, in the profiles window), the tag names are searched in addition to the profile name. If a tag name contains a slash that defines a hierarchy of menu items in the Profiles menu.

Badge

The badge is a large label visible in the top right of a terminal session behind its text. For more information see Badges. This is an interpolated string.

Click the Edit... button to configure the position, maximum size, and typeface of the badge.

Title

This menu contains items which may be separately enabled. They are combined to form the session's title. The session's title is shown in per-pane title bars, when visible; it is also the default tab title. The current tab title also serves as the window title. The standard items in this menu are:

  • Session Name - The session name defaults to the profile name but may be changed later through the Edit Session dialog.
  • Profile Name - Gives the current name of the profile the session uses. If the session's profile changes, this profile name will be updated.
  • Profile & Session Name - Shows both names if they are different or just the shared name if they are the same.
  • Job Name - The name of the foreground job.
  • Job Name with Arguments - The foreground job’s name followed by its arguments.
  • Columns × Rows - The session’s size in cells.
  • User - The current user name. Use Shell Integration to enable this to work when connected to a remote machine.
  • Host - The current host name. Use Shell Integration to set the host name.
  • PWD - The present working directory. Use Shell Integration to enable this to work when connected to a remote machine.
  • TTY - The path to the TTY device associated with this session.

If a script that installs a custom title provider is running, its offerings will be added to the bottom of the list. For a working demo, see the George's Title Algorithm example.

Learn more about session titles.

Applications in terminal may change the title

When enabled, a control sequence can change a session's or window's title.

Subtitle

A tab's subtitle is a second line in a smaller typeface beneath the main title. It can be set by a control sequence or you can define it as an interpolated string. If your configuration has a legacy "short tabs" setting then you'll be prompted to enable "tall tabs" first, to make room for subtitles. That makes room for the second line of text and brings tab height up to the standard used by the most recent version of macOS.

Icon

You may assign an icon to the profile, elect to use the built-in icon (which is based on the foreground application), or to have no icon at all. Icons appear in the tab bar and the window title bar.

Command

This is the command that is executed when a new session with the profile is created. If login shell is chosen, then login is invoked. You can put special terms surrounded by $$ in this field (example: $$USERNAME$$). When a new session is created, you will be prompted to enter a value for each such term. See the description of URL Schemes below for details about the special "$$" value that can go in this field.

When custom shell is selected, you should enter the path to a shell (e.g., /usr/local/bin/bash) and it will be run as a login shell.

If Command is set to SSH then SSH Integration will be used. SSH integration adds some features that regular SSH does not have:

  • Set environment variables automatically
  • Load shell integration automatically
  • Copy over local files to remote host
  • Features like CPU utilization in the status bar will show values from the remote host.

Consider SSH integration to be a beta quality feature.

To take full advantage of it the remote host must have Python 3 installed.

It is not recommended for SSHing to non-Unix hosts.

When you have selected SSH you can click the Configure button to further configure the SSH connection.

In this configuration window you can turn off SSH Integration to fall back to the system ssh command. You can also list environment variables to copy to the remote host. The values come from the current session. You can also edit the list of files to copy upon connection and where to place them on the remote host.

Run command through your shell

When the profile uses a custom Command (rather than a login shell), this option runs that command through your login shell first. Your dotfiles get a chance to run, so $PATH and any variables you export (API keys, GEM_HOME, and the like) are in place before the command starts. This option is only shown when a custom command is configured.

Load shell integration automatically

When enabled, Shell Integration will be loaded into your shell when a new session is created. This is available for zsh, bash, and fish.

Send Text at Start

This text will be sent when a session begins. If it is not empty then a newline will be sent afterwards. It does not accept any special characters or require any escaping.

Initial Directory

Chooses where new sessions with this profile start:

  • Home directory - Your home directory. This is the default.
  • Reuse previous session's directory - The working directory of the session you were in when you created the new one.
  • Directory: - The directory you enter. This is an interpolated string.
  • Advanced Configuration - Choose separately for new windows, new tabs, and new split panes. Click the edit button next to this option to open a sheet with a Working Directory for New Windows, Working Directory for New Tabs, and Working Directory for New Split Panes section; each offers Home directory, Reuse previous session's directory, or Directory:.

URL Schemes

You can configure a profile to handle a URL scheme, such as ssh. When a hyperlink is clicked on with that scheme, a new tab is opened with the selected profile. It is recommended that you set the command to "$$", in which case an ssh command line will be auto-generated. For other schemes, you can uses these variables in the Command field and they will be replaced with the appropriate part of the URL:

  • $$URL$$ The complete url
  • $$HOST$$ The host portion of a url like scheme://host/
  • $$USER$$ The username portion of a url like scheme://user@host/
  • $$PASSWORD$$ The password portion of a url like scheme://user:password@host/
  • $$PORT$$ The port number of a url like scheme://host:port/
  • $$PATH$$ The path portion of a url like scheme://host/path
  • $$RES$$ The portion of a url following the scheme.


Color Profile Preferences

Profiles

Modes

Profiles may have different colors configured for light and dark mode. If you select Use separate colors for light and dark mode then you can switch between modes using the Editing control. Otherwise, only one set of colors will be assigned to this profile.

Color Presets...

iTerm2 ships with some color presets, which you may load from this popup menu. You can import and export color presets to files with the extension "itermcolors". There is an online color gallery where users may share color presets, and a link to it is provided in this menu. When importing a color preset, the name it is assigned is based on the filename imported.

Colors

Clicking on any of the color wells opens a color picker that lets you change the setting for the selected color. iTerm2 has a custom color picker. If you don't like it you can revert to the system color picker by clicking the rectangular icon to the right of the eyedropper.

Context-aware cursor color

This affects the box cursor only. When selected, a box cursor will be displayed in reverse video. If this would result in confusion because nearby background colors would be very similar to the cursor's color, then a different color is chosen that will be most visible.

Use HDR cursor when available

When enabled, the cursor is drawn in a white brighter than ordinary white on a display that supports HDR (extended dynamic range), so it stands out. It works with both the GPU renderer and the legacy renderer. It only takes effect when the display has HDR headroom and the session’s background is dark; otherwise the cursor is drawn normally. While it is in effect the cursor’s color setting and Context-aware cursor color are ignored, and the character under a box cursor is drawn in bold to stay legible. A box cursor in a window without keyboard focus is drawn as a hollow outline in its usual color. Off by default.

The slider beside it sets the peak brightness, from 2 to 16 times normal white (the default is the maximum, 16). A display can only show as much as its current HDR headroom allows, so higher values may look the same.

Cursor Boost

Cursor Boost dims all colors other than the cursor colors to make the cursor stand out more.

Cursor Guide

The cursor guide is a horizontal rule that indicates the vertical position of the cursor. You can adjust its color, including alpha value, to make it more visible against your background color.

Bold

When Use custom color for bold text is enabled, this color is used for bold text that has the default foreground color.

Use bright version of ANSI colors for bold text

When enabled, bold text in one of the eight “normal” ANSI colors (0 through 7) is drawn in the corresponding bright ANSI color. This applies whether the color was set with the basic SGR codes (30 through 37) or as 8-bit colors 0 through 7 (for example, 38;5;1). It doesn’t affect text that is already in a bright ANSI color, other 8-bit colors (8 through 255), 24-bit colors, or the default foreground color. On by default.

Underline Color

If enabled, this color will be used for all underlining, independent of the color that underlined characters have themselves.

Use ANSI colors for mark indicators

When enabled, the command-prompt mark indicators are drawn using the color preset's ANSI blue, red, and yellow instead of the built-in mark colors. This lets the indicators match the rest of your theme. Off by default.

Faint text opacity

Selects how prominent "faint" text is. The minimum value is 0.1; lower values are clamped to that floor.

Minimum Contrast

Sometimes text in a terminal can be hard to read because the background and text colors are too similar. Because ANSI colors are configurable, apps have a hard time avoiding this problem. To ensure legibility, you can increase the Minimum Contrast setting. It has the effect of shifting text colors that are similar to their background colors closer to black or white. As this setting is increased, more colors are affected and the effect is greater. At 100, all text will be pure black or pure white. Minimum contrast never modifies background colors.

Selection

When enabled, you can specify a color for selected text. When disabled, the regular color is used (which may be difficult to read if the text color is similar to the selection color).

Use custom color for selected text

When enabled, the color you specify here for Foreground will be used for selected text. Otherwise, text color won't change when a selection is made.

ANSI Colors

These are the 16 standard colors most often used in terminal emulators. To the right is a visualization in polar coordinates where the angle gives the hue and the distance from center gives the saturation. This can help you configure colors that cover the color space consistently.

Select 8-bit colors to match ANSI colors

When enabled, the 256-color palette (other than the 16 ANSI colors) is chosen to blend well with your eight “normal” ANSI colors. Otherwise the standard RGB cube is used. Changes take effect for new sessions and when a session is reset. Off by default.

Links, Search results, Badge, and Input Method Editor

These color wells set the colors of hyperlinks, highlighted search results, the badge, and the cursor shown while an input method (for example, for Japanese or Chinese) is composing text.

Tab Color

If enabled, this color will decorate the tab control. Tabs indicate the color of their current session if there is more than one split pane.

Border around active pane

When enabled, a border in the selected color is drawn around the active pane (the one that receives keyboard input in its tab), making it easier to see which pane you are typing into. The border is drawn at half strength when the window isn’t the key window. Off by default.


Text Profile Preferences

Profiles

Text

Cursor

This lets you select a cursor shape.

Shadow

This option is available for the underline and vertical bar cursors. It improves their visibility by adding a second line in a constrasting color next to the regular cursor.

Blink

If checked, the cursor will blink slowly to improve visibility.

Smooth blink

When enabled, the cursor fades smoothly in and out instead of toggling abruptly on and off. Click Configure to tune the fade-in and fade-out durations, the easing, and how long the cursor dwells fully visible and fully hidden. It is available only when Blink is on, and is off by default.

Animate large movements

If enabled, when the cursor jumps a long way it is drawn with a stretching animation to make it easier to follow. It animates only jumps that happen within a second of your last keystroke or mouse action (adjustable in Settings > Advanced), so a program redrawing the screen on its own doesn’t leave streaks. Off by default.

…but only in interactive apps

When enabled (the default), Animate large movements applies only while an interactive app (one using the alternate screen, like vim) is running. When disabled, cursor jumps are animated everywhere.

Smooth-typing animation

This makes the cursor slide smoothly to its new position when it moves one cell sideways, as when you type. It works with the underline and vertical bar cursors, and with the box cursor when GPU rendering is on (Settings > General > Magic > GPU rendering); with the box cursor and GPU rendering off it is unavailable. It is distinct from Animate large movements, which stretches the cursor across long jumps. Off by default.

Hide when keyboard focus lost

If enabled, the cursor will become invisible when the terminal does not have keyboard focus.

Allow italic text

If selected, text with the italic attribute set will be rendered in italics. The font you select must have an italic face.

Allow blinking text

If selected, text with the blink attribute set will actually blink. Oh, the humanity.

Draw bold text in bold font

If selected, bold text will be drawn in a bold version of the selected font. If the font does not have a bold version, then a bold appearance is simulated by "double striking" the text: that is, drawing it twice, shifting it one pixel horizontally the second time.

Use built-in Powerline glyphs

When enabled, iTerm2 renders Powerline glyphs itself rather than using what is built-in to the font. These glyphs tend to line up better with other elements than font-provided glyphs.

Use thin strokes for anti-aliased text

Anti-aliased text will be drawn with thinner strokes by default on Retina displays when the background color is darker than the foreground color. The effect may be more or less visible depending on your particular hardware and OS version. You can configure when thin strokes are used depending on display type and colors.

Use Unicode Version 9+ Widths

Unicode version 9 offers better formatting for Emoji. If your applications have been updated to use these tables, you should enable this setting.

Ambiguous characters are double-width

Some characters (e.g., Chinese ideograms) are double-width, and take two cells to display. Other characters (e.g., Latin letters) are single width and take only one cell to display. There is another category of characters known as "ambiguous width". One example of ambiguous-width characters are Greek letters. Depending on your application, you may prefer to display them as double-width or single-width. If most of the text you deal with is double-width, then you should enable this setting as it will help things to line up correctly in that context.

Normalization

This affects how text is processed on input. Most users will want no normalization. HFS+ normalization preserves the fullwidth attribute of composed characters.

Regular font

ASCII text (latin letters, numbers, and some symbols) will be drawn using this font. Select "Anti-aliased" to draw the text with smooth edges.

Non-ASCII font

All non-ASCII text (many accented Latin letters, non-Latin text, less-common symbols, and thousands of miscellaneous unicode characters) will be drawn with this font. It is recommended that you use the same point size for both regular and non-ASCII fonts. Select "Anti-aliased" to draw the text with smooth edges.

Ligatures

When enabled and you have a font that supports ligatures (such as FiraCode) then text will be rendered with ligatures. Ligatures use a slower text-shaping API, so drawing is somewhat slower. The GPU renderer supports ligatures as long as Enable support for right-to-left scripts in Settings > General > Experimental is on (the default); if you turn that setting off, enabling ligatures turns off the GPU renderer for the session.

Contextual Alternates

For ligature-capable fonts, the font picker's options menu includes a Contextual Alternates (calt) toggle. Some fonts use contextual alternates to produce substitutions you may not want (for example, Monaspace renders [] as a checkbox). Turning this off for the profile disables those substitutions while leaving ordinary ligatures alone.

Special Exceptions

When the non-ASCII font is enabled you'll have the option to manage special exceptions. A special exception is a rule that maps a range of codes from another font into the terminal, possibly at a different range. This is useful if you work in multiple languages. For example, if you want to use a different font for Korean versus Chinese, you could create special exceptions for Korean characters to pull from a different font.

This is more frequently used by Powerline (or "nerd font") users to mix graphical characters from different fonts. After opening the Special Exceptions panel, you can use the Install Nerd Font Bundle to get a good default configuration of powerline glyphs from a number of fonts.

You can import and export special exceptions to share them with others.


Window Profile Preferences

Profiles

Window

Transparency

This sets the transparency of the window background. It can be temporarily disabled with View > Use Transparency.

Keep background colors opaque

If selected, non-default background colors will be opaque. This is only available when transparency is greater than zero.

Blur

If selected, the window background is blurred provided the background has some transparency. Selecting a large radius will blur the background more, but (especially on Retina displays on older machines) comes with a performance penalty.

Rows/Columns

When creating a new window with this profile, it will be created with this many rows and columns. For the Normal, No Title Bar, Centered, Centered, No Title Bar, and Bottom/Top/Left/Right of Screen styles, each field has its own unit menu: choose Columns or % of screen width for the width, and Rows or % of screen height for the height. The two are independent, so, for example, a window can be 80 columns wide and 50% of the screen tall. With the Full Screen and Maximized styles the size fields are disabled, since the screen determines the window’s size.

Lock window size automatically

When enabled, the window created with this profile cannot be resized. This is the per-profile counterpart to the Window > Lock Size menu item.

Hide after opening

If enabled, a window created with this profile will immediately miniaturize after its creation.

Open Toolbelt

If enabled, a window created with this profile will feature an open toolbelt.

Custom window title

New windows created with this profile will use this title by default, overriding the default behavior of using the current tab's title as the window's title. This is an interpolated string.

Always open in a new window, never in a tab

If you ask for a new tab with this profile, it will just open in a window instead. This is for people who hate tabs.

Use Transparency

Sets whether the transparency setting is respected for new windows created with this profile. It can then be toggled with View > Use Transparency.

Custom Tab Title

New tabs created with this profile will use this tab title by default. This is an interpolated string.

Background Image

This allows you to select an image to display behind the terminal's text. Instead of a single file you can choose a folder of images: the profile then rotates through the images in that folder, changing at the rotation interval you specify.

Mode

This allows you to select how the image is scaled to fit the window:

  • Stretch - The image is distorted to exactly fill the window.
  • Tile - The image is not scaled. It is tessellated.
  • Scale to Fill - The image is scaled up or down preserving the aspect ratio so that it completely fills the window. Parts of the image may be cropped out.
  • Scale to Fit - The image is scaled to exactly fill the window either horizontally or vertically. Its aspect ratio is preserved. Letterboxes or pillarboxes may be added.

See also: Settings > Appearance > Panes > Separate background images per pane.

Blending

The blending slider determines how strongly the image dominates over the text's background color.

Style

This defines the window style.

  • Normal - A regular window with a title bar.
  • Full Screen - A full screen window. See Settings > General > Window > Native full screen windows.
  • Maximized - The window has a normal title bar but is forced to be as large as possible on the the screen it is on.
  • No Title Bar - A window without a title bar. It is hard to move but is as minimal as can be.
  • Centered - A window with a normal title bar that opens in the center of its screen and is re-centered when the screen configuration changes, keeping any size you gave it.
  • Centered, No Title Bar - Like Centered, but with no title bar or window controls.
  • Bottom/Top/Left/Right of Screen - A window that is stuck to one edge of the screen. Its width and height can each be given in cells or as a percentage of the screen, so, for example, a Top of Screen window 100% of the screen wide spans the top edge from corner to corner.

Screen

If you have more than one screen connected, this lets you select the screen on which a new window should open. It is particularly useful for fullscreen and top-of-screen window styles. The Screen with Cursor option affects the initial screen of the window, but it won't follow your cursor from screen to screen.

Space

If you have enabled Spaces (or your OS uses Desktops instead of spaces) and have set Spaces/Mission Control to use Control+Number to switch spaces/desktops, then you can use this setting to select the initial space/desktop to open a new window using this profile.

Current Space means the window opens on the visible Space at the time it was created. For hotkey windows, Current Space causes them to move to the current Space each time they are opened.

All Spaces means the window follows you around from Space to Space.


Terminal Profile Preferences

Profiles

Terminal

Scrollback lines

The number of lines of scrollback buffer to keep above the visible part of the screen. Unlimited scrollback will allow it to grow indefinitely, possibly using all available memory.

Save lines to scrollback when an app status bar is present

Some programs (such as vim or tmux) keep a status bar at the bottom of the screen. For some applications (like vim) it is undesirable to save lines to the scrollback buffer when the application scrolls. For others (like tmux) you may want to save scrolled-off lines into the scrollback buffer. When this setting is enabled, lines scrolled off the top of the screen in the presence of a status bar are added to the scrollback buffer. The screen is considered to have a status bar if it has a scroll region whose top is the first line of the screen and whose bottom is above the bottom of the screen.

Save lines to scrollback in alternate screen mode

When in alternate screen mode, lines that scroll off the top of the screen will be saved to the scrollback buffer only if this option is enabled.

Drag-to-scroll disabled in alternate screen mode

Normally you can use the mouse to scroll by starting a selection and moving the pointer above or below the session's bounds with the button pressed. Interactive apps (like vim or emacs) signal their interactivity by entering alternate screen mode. When this setting is enabled, you won't be able to accidentally scroll by dragging in an interactive app.

Character encoding

The encoding to send and receive in. For most people, "Unicode (UTF-8)" is the right choice.

Report terminal type

The TERM variable will be set to this value by default. If xterm-256color is selected and your system is missing the terminfo file, you will be prompted to install it when you open a new session.

ENQ answer back

Text to send when the ENQ sequence is received. Not normally used.

Enable mouse reporting

If selected, applications may choose to receive information about the mouse. This can be temporarily disabled by holding down Option.

Report mouse wheel events

If disabled, the mouse wheel will always perform its default action (such as scrolling history) rather than being reported to an app that has enabled mouse reporting.

Report mouse clicks & drags

If disabled, the mouse buttons will always perform their default action (such as making a selection) rather than being reported to an app that has enabled mouse reporting.

Terminal may enable alternate mouse scroll

Alternate mouse scroll is a feature where the scroll wheel sends arrow up/down keys rather than navigating history. If enabled, a program may switch into alternate mouse scroll.

Automatically enable alternate mouse scroll

When enabled, alternate mouse scroll will be turned on any time you're in an interactive application.

Restrict alternate mouse scroll to vertical scrolling

When enabled, a horizontal scroll gesture will never send arrow keys when alternate mouse scroll is on.

Restrict mouse reporting to alternate screen mode

When enabled, mouse movements or clicks will be reported only when in an interactive application.

Terminal may report window title

Programs running in a terminal may send an escape code to request the current window title. When this option is enabled, iTerm2 answers such requests; when it is disabled, it doesn’t. It should be disabled if you're communicating with an untrusted party, as there are possible injection attacks.

Terminal may change cursor blink

If enabled apps running in the terminal can cause the cursor to start or stop blinking with a control sequence.

Disable session-initiated printing

If enabled, escape codes that initiate printing will be ignored.

Disable save/restore alternate screen

Some programs (such as vim, tmux, and less) switch into a so-called "alternate screen". A characteristic of this behavior is that when these programs terminate the screen's contents are restored to their state from before the program was run. If this option is selected, alternate screen mode is disabled and the screen cannot be restored by an application.

A session may cause the window to resize

If enabled, the window size can be changed by a program sending a control sequence.

...even if it is in an unselected tab or split pane

If enabled, programs running non-selected tabs or split panes without keyboard focus may resize the window.

Terminal may enable paste bracketing

Paste bracketing is a feature that can be enabled by an app running in iTerm2 by sending a control sequence. When enabled, iTerm2 transmits a control sequence before and after paste operations (e.g., pressing Cmd-V). This can be useful because editors like vim may disable auto-indenting when pasting already-indented code. Sometimes paste bracketing can be left on, causing unexpected behavior when you paste. For example, if a program running in an ssh session enables paste bracketing and then your ssh connection ends unexpectedly it won't have a chance to turn it off. Your next paste will include the bracketing control sequences, which will be mishandled by whatever program receives them. For that reason, some people prefer to disable paste bracketing. If you install Shell Integration it can detect when this occurs and automatically disable paste bracketing for you, making it safe to leave it enabled here.

Silence bell

If selected, the bell (control-G) will not make an audible sound.

Bell sound

Chooses the sound the bell plays. The default, System Alert Sound, is your Mac’s alert sound. The menu also lists the sounds installed in the Sounds folders (~/Library/Sounds, /Library/Sounds, /Network/Library/Sounds, and /System/Library/Sounds), and Other… lets you pick any audio file. The sound plays when you choose it so you can hear it. Giving a profile its own bell sound makes its sessions’ bells easy to tell apart. If the chosen file is later missing or can’t be played, the menu marks it with a warning and the bell plays the system alert sound instead. This is disabled when Silence bell is on.

Flash visual bell

If selected, a bell graphic will be flashed when the bell character is received.

Show bell icon in tabs

If selected, tabs will indicate that a bell has rung by displaying a bell graphic.

Notification Center alerts

If selected, iTerm2 will post a notifications when sessions receive output, become idle, ring the bell, close, or get a proprietary escape sequence to post a notification.

Filter Alerts

This button opens a panel that lets you customize which notifications will be posted.

Suppress alerts from active session

Found in the Filter Alerts panel. When enabled, alerts are not posted for the session that currently has keyboard focus, so you're only notified about activity you aren't already watching.

Send alerts to paired iPhone

Found in the Filter Alerts panel. When enabled, this profile's alerts (such as alert on next mark and Post Notification triggers) are delivered to a paired companion iPhone. This is opt-in.

Environment

You have the following options:

  • Set locale environment variables automatically - If enabled, LANG and LC_CTYPE environment variables will be set based on your machine's language settings.
  • Do not set locale environment variables - iTerm2 doesn't set LANG or LC_CTYPE; whatever values the session would otherwise inherit are left alone.
  • Use custom locale… - Lets you specify the locale you wish to use; it is assigned to LANG. You will be limited to those that are supported by your Mac.
  • Use “POSIX” locale (LC_CTYPE=encoding) - Sets only LC_CTYPE, to the profile’s character encoding (for example, UTF-8), and doesn't set LANG.

The current locale is shown beneath this setting.

Insert newline before start of command prompt if needed

If you have Shell Integration installed and a command's output does not end in a newline, this setting will ensure your prompt does not begin in the middle of the line.

Show mark indicators

If you have Shell Integration and this setting is selected then a blue or red arrow appears next to each shell prompt. Turn this off to hide the arrow.

Show offscreen command line at top of session

When the session shows part of a command's output but the command is above the top of the screen, the command can be shown in a box at the top when this is enabled.

…even for the currently running command

When enabled, the offscreen command line is shown even while that command is still running (except in alternate screen mode, as when a full-screen app is running). Otherwise it is shown only for commands that have finished. Off by default.

Click on a path in a shell prompt to open Navigator

If enabled and your shell prompt contains something directory-like (for example, /Users/george%) then clicking on that directory opens a Navigator window that lets you browse the file system.

Send \n rather than \r to terminate commands

Some obscure or ancient systems expect newlines as line terminators. Unfortunately there is no way to detect this automatically. If tmux integration simply hangs for you on certain hosts, enabling this setting may fix it.


Session Profile Preferences

Profiles

Session

Warn about short-lived sessions

When enabled, you'll be given a warning if a session ends within a short time after it starts. This gives you a chance to see what went wrong and fix it.

“Undo” can revive a closed session for up to this many seconds

When you close a session, window, or tab the shell is not terminated until this many seconds pass. While that time period has not elapsed, Undo will reopen the session, tab, or window.

If Archive sessions on closure (below) is also on, Undo keeps working after this time runs out: the shell is gone by then, so the session comes back from its archive instead, in its original split pane, tab, and window. The 20 most recent archived closes can be undone even after iTerm2 restarts.

After a session ends

Defines what happens when a session ends.

  • No Action - The session stays open and you will be prompted to restart it.
  • Close - The session is automatically closed.
  • Restart - The session is automatically restarted with the same command that launched it.

Prompt before closing

When a session will close, you can choose when to be prompted with a modal alert: Never, Always, or If there are jobs besides. If you select If there are jobs besides then the prompt will only be shown when an app besides those specified (which are often present when nothing is happening) is running.

Enable automatic session logging

If enabled, every session's output will be logged to a file in the specified directory. The filename format can also be specified here as an interpolated string.

Log format

You can log in the following formats:

  • Raw data - An exact copy of the input that was received including control sequences.
  • Plain text - Excludes control sequences. Just text and newlines. This is very readable when running CLI apps but becomes utter chaos for interactive programs like vim or emacs.
  • HTML - Like Plain text, it excludes control sequences. Colors and various font attributes are preserved. The resulting file can be viewed in a web browser.
  • asciinema - Produces a file viewable with asciinema, which preserves time as well as more font attributes.

Folder

The folder in which to place logs. This is an interpolated string.

Filename

The name to give the log file. This is an interpolated string.

Open password manager automatically when a password prompt is detected

If enabled, the password manager opens automatically when iTerm2 detects that a session with this profile is showing a password prompt.

Timestamps

When enabled, the last modified date and time of each line is shown on the right-hand side of the terminal. You can also select where timestamps are drawn: Over contents, Over contents when mouse hovers over scrollbar, or Next to contents.

Status bar enabled

See Status Bar for details on the status bar. Click Configure Status Bar to choose its components.

Show progress bars

When enabled, a thin progress bar is drawn at the top of the session when a program reports progress with the OSC 9;4 escape sequence. Height sets its thickness in points (it can't be taller than the top margin, so it never covers text), and Color Scheme sets the colors of both ordinary percentage bars and indeterminate ones (bars that show activity without a percentage). Bars reporting an error or warning keep their red or orange colors regardless of the scheme. On by default.

Periodically send an ASCII code when idle

If selected, the specified ASCII code (a number from 0 to 255) will be transmitted every Interval (seconds) seconds while nothing is happening. Don't use this unless you know what you're doing as it can have unexpected consequences. Seriously, it's probably not what you want.

Avoid repainting while cursor is hidden to reduce flicker while scrolling

When selected, the screen will slightly delay redraws while the cursor is hidden. This improves the visual appearance of scrolling in many programs but might introduce noticeable delays for some users.

Archive sessions on closure

When enabled, an archive of the session is saved automatically when it closes. Use the accompanying directory picker to choose where the archives are written. See Session Archives for details on what is captured and how to open an archive later.

Archiving also extends Undo: a closed session can be undone after the “Undo” time limit runs out, because it is restored from its archive. See the “Undo” setting above.

Lock pane by default

When enabled, new sessions with this profile start out locked. A locked pane can’t be moved by dragging, and closing it asks for confirmation.

Buffer input by default

When enabled, text you type in a new session with this profile is stored rather than sent, until you turn buffering off with Shell > Toggle Buffer Input (or a Buffer Input... trigger configured to stop buffering).

Prevent sleep

When Prevent the system from sleeping while a session has this setting on is enabled, your Mac won’t go to sleep due to inactivity while any session with this setting on exists (including buried sessions). It prevents only idle sleep: the display can still sleep, and closing the lid or choosing Sleep from the Apple menu still puts the Mac to sleep. A session whose program has ended but whose pane is still open doesn’t count. Off by default.

This only takes effect while the Mac is connected to power. To make it apply on battery too, turn on the advanced setting “Prevent system idle sleep on battery too, for profiles with ‘Prevent sleep’ enabled?” in Settings > Advanced.

Beneath the checkbox, iTerm2 shows how many sessions are currently preventing sleep, or how many would if the Mac weren’t on battery.

To keep the Mac awake only while a particular job runs (for example, an AI coding agent), leave this off and use a pair of Set Profile Setting triggers (for example, on the Job Started and Job Ended events) to turn it on when the job starts and off when it ends. A trigger changes the setting only for the session it fires in. See Triggers.


Keys Profile Preferences

Profiles

Keys > General

Allow Application Keypad Mode

Some full-screen programs (like emacs) switch the keyboard into application keypad mode, which changes how the numeric keypad behaves. Disabling this option causes iTerm2 to never enter application keypad mode.

Report keys using CSI u

Enables a more powerful keyboard reporting algorithm that some applications may use to enable the use of modifiers on more keys and more combinations of modifiers. This is not recommended. Applications should use the Kitty keyboard protocol instead.

Apps can change how keys are reported

When enabled apps running in the terminal can change the key reporting mode.

Page up, page down, home and end scroll outside interactive apps

When enabled, these keys move the viewport unless you are running an interactive application.

Treat option as Alt for special keys like arrows

When reporting function keys (such as arrows) to apps running in the terminal, the specifications are ambiguous about whether the Mac Option key should behave like Alt or Meta. When this setting is enabled, it is treated as alt. When disabled, it is treated as Meta.

Left/Right Option Key

It is common to use a modifier to send so-called "meta keys". For most users, selecting "+Esc" here is the right choice. The "Meta" option sets the high bit of the input character, and is not compatible with modern systems.

The corresponding Apps can change this setting can be disabled to prevent apps in the terminal from modifying your setting with a control sequence.

Left/Right Control/Command, fn key

Some programs support extended modifier keys of Hyper, Meta, and Super. You can configure existing modifier keys to act as these extended keys. This setting will be in effect only when running a program that uses the Kitty keyboard protocol; otherwise, they will act like regular control, command, and fn keys.

A hotkey opens a dedicated window with this profile

When enabled, a dedicated hotkey window is attached to this profile. The Configure Hotkey Window button lets you configure the hotkey and other attributes of the window. For more information, see Hotkey Windows.

Keys > Key Mappings

This panel shows key mappings. You can double-click on a mapping to edit it. When the "Keyboard Shortcut" field has focus, you should press the keystroke that you want to modify (even if it involves modifiers like Cmd). The following actions are available:

  • Ignore - The keypress will do nothing.
  • Bypass Terminal - Prevents the keystroke from being sent to the terminal while allowing macOS to handle it normally. For example, if F1 triggers a macOS Shortcut, binding F1 to Bypass Terminal stops it from sending a control sequence to the terminal but still lets the system shortcut work.
  • Select Menu Item... - This action allows you to enter the name of an iTerm2 menu item. It must be entered exactly the same as it appears in the menu. Ellipses can be typed with option-semicolon.

  • Do Not Remap Modifiers - This action lets you exempt a keystroke from modifier remapping. For example, if you remap ⌘ to ⌥ but you want ⌘-Tab to work as though ⌘ were unmapped just for that keystroke, you would use this action and set the keyboard shortcut to ⌘-Tab.

  • Remap Modifiers in iTerm2 Only - This action applies modifier remapping but prevents other programs from seeing the keystroke. For example, if you've swapped ⌘ and ^ and want physical ^-tab to switch tabs in iTerm2 instead of triggering the app switcher: bind ^-tab to this action. The system won't see the remapped ⌘-tab (so no app switcher), but iTerm2 receives it and can switch tabs.

  • Cycle Tabs Forward/Backward - This implements tab switching the same way Cmd-Tab (or Cmd-Shift-Tab) switches windows, with the most-recently-used stack.

  • Run Coprocess - This action launches a Coprocess. Learn more about coprocesses.

  • Start Instant Replay - This is equivalent to the menu item View > Start Instant Replay.
  • Undo - Invokes the Undo action. Could be used to undo closing a session/tab/window.
  • Send tmux command - Used in tmux integration to send a command directly to the tmux server of the current session.
  • Alert on next mark - Toggles the Alert on next mark feature.

  • New Window with Profile - Creates a new window with a profile you specify here.

  • New Tab with Profile - Creates a new tab with a profile you specify here.
  • Duplicate Tab - Creates another tab exactly like the current one.

  • Split horizontally/vertically with Profile - Creates a new split pane by cleaving the current session. Uses the profile you specify here.

  • New Floating Pane with Profile - Creates a floating pane, which floats over the tab’s split panes, using the profile you specify here.
  • Split/New Window/Tab with Profile - These actions allow you to create a new session with a specified profile when a key is pressed.

  • Change Profile - This action changes the profile of the current session.

  • Load Color Preset - This action changes the colors of the current session using the specified preset.
  • Set Character Encoding… - Switches the current session’s character encoding to the one you pick from the Encoding menu, and briefly shows a message confirming the change. Only the current session is affected; the profile isn’t changed. This is not available in web browser profiles.

  • Next/Previous Tab/Window/Pane - These actions navigate among tabs, windows, and split panes.

  • Move tab left/right - Changes the tab's position in the order.
  • Next/Previous Window - Selects the next or previous window in window order.
  • Next/Previous Pane - Selects the next or previous pane in left-to-right, top-to-bottom order.
  • Select Split Pane Above/Below/Left/Right - These actions navigate split panes.

  • Increase/Decrease Width/Height - Changes the size of the current session.

  • Scroll to End/Top/Up/Down - These actions move through the scrollback buffer.

  • Scroll one Line/Page Up/Down - These actions move through the scrollback buffer.

  • Swap with Split Pane Above/Below/Left/Right - Exchanges the current session with an adjacent session in a split pane in the same tab.

  • Swap with Next/Previous Pane - Exchanges the current session with the next/previous pane in the same tab.
  • Move Session to Split Pane - After invoking this, click a different session. The current pane will be moved to share half its former space.

  • Send ^? / ^H Backspace - Modern systems use ^? for backspace, while some legacy systems use ^H.

  • Send Escape Sequence - This action allows you to enter some text that will be sent when the associated key is pressed. First, the ESC character is sent, and then the text you entered is sent. There are no special characters and no escaping is necessary.
  • Send Hex Code - This action allows you to enter a sequence of hex codes that will be sent. Each value should begin with "0x" followed by one or two hex digits (0-9, a-f, or A-F). Each code should be separated by a space. You can see a list of hex codes on http://asciitable.com/ in the "Hx" column.
  • Send Text - This action allows you to enter a text string that will be sent when the associated key is pressed. The following escape characters are supported: \n (newline), \e (escape), \a (bell), \t (tab).
  • Send Text with “vim” Special Chars - This action allows you to enter a text string that will be sent when the associated key is pressed. The following special sequences are supported, where the "." characters are placeholders: ... (three-digit octal number), .. (two-digit octal number; must be followed by non-digit), . (one-digit octal number; must be followed by non-digit), \x.. (two-digit hex number), \x. (one-digit hex number), \u.... (four-digit hex number), \b (backspace), \e (escape), \f (form feed), \n (newline), \r (carriage return), \t (tab), \ (backslash), \" (double quote), \\ (control key), \\ (meta key)
  • Send Text without Broadcasting - Like Send Text with “vim” Special Chars, but the text goes only to the current session even when input is being broadcast to several sessions.
  • Send Snippet - You can choose a snippet to send.
  • Compose... - Open the Composer.

  • Find Regular Expression - Performs a search for a saved regular expression.

  • Find Again Up/Down - Repeats the search, finding the next result at an earlier/later position.

  • Paste - Like Edit > Paste, but you can set advanced paste settings to use.

  • Paste From Selection - Like Edit > Paste and Edit > Paste Special > Paste Selection, but you can set advanced paste settings to use.
  • Copy or send ^C - If there is a selection, copy it. Otherwise, send the literal Control-C keystroke.
  • Paste or send ^V - If there is text in the pasteboard, paste it. Otherwise, send a literal Control-V keystroke.
  • Copy Interpolated String - Evaluates the interpolated string you provide it and copies it to the clipboard.
  • Copy Mode Commands - Takes as a parameter a sequence of commands that you would normally use interactively in Copy Mode. For example, you could give it <space> k <space> y to select the line above the cursor.
  • Toggle Fullscreen - This action enters or exits full screen mode
  • Toggle Pin Hotkey Window - Toggles whether the hotkey window hides when it loses focus.
  • Toggle Mouse Reporting - Temporarily enable or disable mouse reporting.
  • Toggle Setting - Turns a checkbox setting on or off. Pick the setting from the menu. If it’s a profile setting, only the current session’s copy of the profile changes.

  • Move Start/End of Selection Back/Forward - Adjusts the range of selected text.

  • Invoke Script Function - Calls a function registered by a script. See Scripting Fundamentals for details on functions.

  • Sequence... - Lets you create a keybinding from a sequence of key bindings.

You can add a new keymapping by pressing "+". You can remove an existing mapping by selecting it and pressing "-". Three presets are provided: "Xterm defaults" is the normal key mappings, while "Xterm defaults with numeric keypad" disables the "application keypad" in favor of the numbers and symbols that the numeric keypad typically emits. "Terminal.app Compatibility" tries to emulate the way that Terminal.app sends keys by default.

You can also import and export your key bindings to share with others.

Repair Broken Bindings

This button appears only when iTerm2 detects key bindings that were corrupted by a bug in an earlier version of iTerm2. Such bindings still work but display incorrectly. Pressing it shows the affected bindings and, after you confirm, fixes them so they display correctly again.

Delete key sends ^H

If you are on a legacy system that does not accept ^? for backspace, select this and it will add a key mapping for you.


Advanced Profile Preferences

Profiles > Advanced

Triggers

Triggers are actions that are performed when text matching a regular expression is received. Each trigger has a regular expression, which defines when it runs. It has an action, which defines what it performs, and it has an optional parameter, whose meaning depends on the action. When the parameter is textual, \0 is replaced with the entire match, and \1...\9 are replaced with match groups. Each trigger has a checkbox in the "Instant" column. Instant triggers run as soon as text matching the regular expression is matched; triggers that are not instant only match after the cursor moves off the current line (such as when a newline is received).

Full details can be found at Triggers.

Enabled in interactive apps

When enabled (the default), triggers also run while an interactive app that uses the alternate screen, such as vim, is running. Turn it off to have triggers ignore output from such apps.

Smart Selection

Smart Selection defines regular expressions that are used to select text on quad-click.

Automatic Profile Switching

You can specify rules that, when satisfied, changes any session's profile to this one. See Automatic Profile Switching for all the details. Shell Integration must be installed to use this feature.

Write Automatic Profile Switching debug logs to Script Console

When enabled, Automatic Profile Switching logs how it evaluates its rules to the Script Console (Scripts > Manage > Console, ⌥⌘J), which helps you figure out why a rule did or didn’t match. This setting applies to all profiles.

Snippets Filter

The Snippets feature lets you save a collection of strings to re-send later on. Each snippet may have one or more tags associated with it. If you would like to show only certain snippets when working in a particular profile, you can name tags in the Snippets Filter that are required for a snippet to be available in the context of a session with this profile.

Semantic History

Semantic history is used to open a file when you Cmd-Click on it. The current working directory for each line in the terminal is tracked to help find files. If Semantic History is set to Open with default app, then files are passed to the OS to be opened with whatever is associated. Alternatively, you can choose Open URL… to open a specific URL (with \1 replaced with the filename and \2 replaced with the line number, if applicable). If you choose Open with editor… then text files will be opened with the designated editor, while other files are opened with the default app for their file type. For more flexibility, choose Run command… and specify a command to execute. \1 will be replaced with the file name, \2 will be replaced with the line number (if applicable), \3 with text in the line prior to the click location, \4 with text in the line subsequent to the click location, and \5 for the working directory of the line clicked on. Always run command… is like Run command…, but takes effect even if the object clicked on is not an existing filename. Run coprocess… runs the command you enter as a coprocess, and Send text… sends the text you enter to the session, with vim-style special characters supported; both use the same \1 through \5 substitutions as Run command… and, like it, take effect only when the clicked text is the path of an existing file or directory.


Keys Preferences

Keys


Key Bindings

This interface works like the keyboard shortcut system in profiles (described above) but it affects all profiles. Settings here are overridden by those in a profile's key mappings.

See the list of key binding actions at Settings > Profiles > Keys.

Add Touch Bar Item

This button is only visible if your OS version supports touch bars. By pressing this button, you can define a new custom touch bar button with any of the actions you can assign to a key (see below). You can then add the custom button to your touch bar with View > Customize Touch Bar.

Touch Bar Mitigations

This opens a panel with these options:

  • Haptic feedback when pressing esc When you press esc on a touchbar, this makes the trackpad vibrate to provide feedback.
  • Key click for virtual esc key When you press esc on a touchbar, this causes a click sound to be played.
  • Visual esc key indicator When you press esc on a touchbar, make the cursor change shape briefly to provide feedback.

Repair Broken Bindings

This button appears only when iTerm2 detects key bindings that were corrupted by a bug in an earlier version of iTerm2. Such bindings still work but display incorrectly. Pressing it shows the affected bindings and, after you confirm, fixes them so they display correctly again.

Presets > Factory Defaults

Restores key bindings to the iTerm2 defaults.

Presets > Import/Export

Lets you share key bindings with others.

Interpret key bindings based on physical key, ignoring input language

When enabled key bindings refer to a particular key rather than a particular character. For example, suppose you have bound Cmd-Opt-A to perform some action while using a US keyboard and then switch to an AZERTY layout. With this setting enabled, you'd press Cmd-Opt-Q to invoke the action since the AZERTY Q is where the QWERTY A goes.

Note that only key bindings created with iTerm2 version 3.5.0beta19 or later will adapt to different keyboard layouts. Older key bindings did not store the keycode and will continue to behave as though this setting was not enabled.

Leader

By defining a "leader" key you can create shortcuts that consist of two keystrokes. Command-B is the recommended leader. After setting the leader, you can define a new keybinding by pressing Leader followed by another keystroke. For example, if your leader is Command-B, you could define a key binding as the sequence Command-B N.

In tmux integration key bindings are automatically created for you based on tmux's configured command key bindings. For example, if tmux is configured for C-b c to create a new window, then in tmux integration [leader] c will do the same.

Navigation Shortcuts

Shortcut to select a tab

Tabs are normally navigated with cmd+number, but you can change the modifier used for that function here.

Shortcut to activate a window

Windows are normally navigated with cmd+opt+number, but you can change the modifier used for that function here.

Shortcut to choose a split pane

You can use this to configure a modifier+number shortcut to select a split pane in the current tab.

Emulate U.S. Keyboard

If your keyboard layout requires you to hold Shift (or some other modifier) to press a number, enable this to treat the top row of keys as number keys even when Shift is not pressed. This only affects switching panes, tabs, and windows by keyboard as configured in the preceding settings.

Hotkey

Create a Dedicated Hotkey Window

Sets up a new hotkey window profile if you don't already have one. For more information, see Hotkey Windows.

Show/hide all windows with a system-wide hotkey

When enabled, you can focus the App Hotkey field and press a keystroke. From then on, pressing that keystroke (even when iTerm2 is not the front application) will cause iTerm2 to come to the front. If it is the foreground app, it will be sent to the back. For more information, see Hotkey Windows.

Open Quickly hotkey

Focus this field and press a keystroke to assign a system-wide hotkey for Open Quickly. Pressing it while another application is in front invokes Open Quickly without activating iTerm2. iTerm2 comes to the front only once you commit a selection.

Remap Modifiers

iTerm2 allows you to change the meanings of the modifier keys. This is useful, for example, if you find it difficult to press “option” for “meta” and would prefer to use “command” for that purpose. Reset to Defaults restores the normal meanings.

Remap fn key to

Along with the left and right Control, Option, and Command keys, you can remap the fn (Function) key to any of those modifiers. When fn is remapped, iTerm2 undoes the translation macOS normally applies to keys pressed with fn, so, for example, fn-Up Arrow with fn remapped to Control arrives as Control-Up Arrow rather than Page Up.

Remap modifiers globally

When enabled (the default), modifiers are remapped in a way that also affects system shortcuts and other apps that receive keystrokes in the background while iTerm2 is active. For example, if you remap ⌥ to ⌘ with this enabled, you could press ⌥-Tab to switch apps. When disabled, remapping affects only keystrokes that iTerm2 itself handles.

Input Locale

Force keyboard

You can enable this setting to force iTerm2 to use a specific keyboard layout rather than the current system keyboard.

Only force once per session when it first receives keyboard focus

Normally, while Force keyboard is on, iTerm2 keeps forcing the selected layout, so you can’t switch to another layout within a session. When this is enabled, the layout is forced only the first time a new session receives keyboard focus, and you are free to change it afterward.

Respect shortcuts from System Settings > Keyboard > Keyboard Shortcuts > Keyboard

On macOS 15 and later, when this is enabled (the default), a keystroke that is assigned to a system shortcut in System Settings > Keyboard > Keyboard Shortcuts > Keyboard goes to the system instead of to the terminal.


Arrangement Preferences

Arrangements


This pane has two tabs.

Arrangements

This tab lets you view saved window arrangements. Select an arrangement to see a preview of its windows, and double-click its name to rename it. You can delete an arrangement with the minus button and choose the default arrangement with Set Default. The default arrangement, marked in the Default column, is opened when iTerm2 starts if you choose Open Default Window Arrangement in Settings > General > Startup.

Workgroups

This tab is where you create and edit Workgroups: sets of sessions that you can switch among with one click. See Workgroups for details.


Pointer Preferences

Pointer


General

⌘-Click opens filename/URL (semantic history)

If enabled, then cmd-clicking on a filename (of an existing file on the local machine) or a URL will open it.

⌥-Click moves cursor

If enabled, option-click will move the cursor to where the mouse pointer is. If you install shell integration, this will be well-behaved at the shell prompt by not sending up and down arrow keys.

Three-finger tap emulates middle click

If enabled, a three-finger tap acts like a middle click.

Focus follows mouse

If enabled, moving the mouse over an inactive window or pane will cause it to receive keyboard focus. Focus moves only onto the terminal itself, so pointing at a pane doesn't take focus away from its find bar, composer, or other fields by accident.

…even to views like Search or Composer

When this and Focus follows mouse are both enabled, focus also follows the pointer onto views in a pane such as the find bar or the composer, and back onto the terminal.

Focus window after right or middle click

When enabled, right-clicking or middle-clicking on a window will give it keyboard focus.

^-Click reported to apps, does not open menu

If enabled, ctrl-click will be sent to applications that support Xterm mouse reporting (if mouse reporting is enabled) instead of opening the context menu.

Right click reported to apps, does not open menu

If enabled, a right click will be sent to applications that support Xterm mouse reporting (if mouse reporting is enabled) instead of opening the context menu.

Mouse reporting supports horizontal scrolling

When enabled (the default), horizontal scroll wheel and trackpad movements are reported to applications that use mouse reporting. Turn it off if horizontal scrolling causes unwanted input in such an app.

Bindings

Mouse Button and Trackpad Gesture Actions

You may assign custom actions to mouse clicks and trackpad gestures. The left mouse button is not configurable because its behavior is rather complex, however. This is especially useful if you have a mouse with many buttons. Any combination of mouse button + number of clicks + modifiers may be assigned an action. For gestures, three finger taps and swipes, and a Force Touch click, may be configured in combination with modifiers. The Load Defaults button restores the default bindings. The following actions are available:

  • Copy Link Address - Copies the address of the link under the pointer.
  • Copy or Paste - Copies the selection if there is one; otherwise, pastes.
  • Extend selection - The text selection will grow, either from its beginning or end, to the location of the pointer.
  • Ignore - Perform no action
  • Invoke script function - Call a Python API-defined function.
  • Move pane - The current pane will turn green. Click in another window's tab bar or in another pane to split to move the now-green pane.
  • New Horizontal/Vertical split with profile - The pane under the pointer will be split and the new split will use the specified profile.
  • New Split/Tab/Window With Profile - A new split pane/tab/window will be opened with the specified profile.
  • New Floating Pane With Profile - A new floating pane, which floats over the tab's split panes, will be opened with the specified profile.
  • Next/Previous Tab/Window - Navigates through tabs and windows.
  • Open Context Menu - Opens the menu normally opened by a right click.
  • Open URL in background - Opens the URL under the pointer in your web browser without bringing the browser to the foreground.
  • Open URL/Semantic History - Opens the URL under the pointer, bringing the web browser to the foreground. If what's under the cursor is a filename on the local machine, it will be opened with Semantic History.
  • Paste from Clipboard - Pastes the contents of the pasteboard (like Edit > Paste) but you can also configure advanced paste settings.
  • Paste from Selection - Pastes the most recent selection made in iTerm2, even if it's not what's in the pasteboard. Allows you to configure advanced paste settings.
  • Quicklook - Defines the word under the cursor or, if it's a URL, opens it in a web browser popover.
  • Select Next/Previous Pane - Navigates panes according to how recently they were used.
  • Select menu item - Select an item from the app's main menu.
  • Select pane Above/Below/Left/Right - Navigates panes by their layout.
  • Send Escape Sequence... - This action allows you to enter some text that will be sent when the associated key is pressed. First, the ESC character is sent, and then the text you entered is sent.
  • Send Hex Code - This action allows you to enter a sequence of hex codes that will be sent. Each value should begin with 0x followed by one or two hex digits (0-9, a-f, or A-F). Each code should be separated by a space. You can see a list of hex codes on http://asciitable.com/ in the “Hx” column.
  • Send Text - This action allows you to enter a text string that will be sent when the associated key is pressed. The following escape characters are supported: \n (newline), \e (escape), \a (bell), \t (tab).
  • Smart Selection - Performs smart selection on the text under the pointer.
  • Smart Selection ignoring Newlines - Performs smart selection on the text under the pointer, ignoring newlines (e.g., if a URL is split by a hard newline, it can still be selected as a single item).


Shortcuts Preferences

Shortcuts


Shortcuts are quick ways to perform common tasks. There are various places in the UI where you can activate shortcuts:

  • The Shortcuts toolbelt tool.
  • The Edit > Actions menu.
  • The Actions Menu and Snippets Menu status bar components.
  • The Open Quickly panel.

Actions

An action consists of something to do (such as open a new window) with a name, called its title. Actions are very similar to key bindings except that they don't need to have a keyboard shortcut attached.

Use the plus and minus buttons to add and remove actions. The import and export buttons save your actions to a file and load them from one, so you can share them or move them to another computer.

Snippets

A Snippet is a string of text with a title. By activating the snippet, the associated text is sent as though it had been typed.

When you edit a snippet you can give it tags. Use / in a tag name to create folders in the Edit > Snippets menu. The Escaping menu chooses how the snippet's text is interpreted: C-Style Backslash Escaping (so \n is a newline), Unescaped Literal Text, or Backward Compatibility Escaping. As with actions, snippets can be exported to a file and imported from one.


Advanced Preferences

Advanced

Advanced Settings are self-documenting. Use the search field to find what you're looking for, as there are quite a few of them. Some work better than others. Proceed with caution.

Turn on Show only non-default values to list only the settings you have changed from their defaults.


Scripting

iTerm2 features AppleScript support which allows you to automate many aspects of its behavior. Quite a bit of customization is also possible by writing shell scripts.

AppleScript

iTerm2 has sophisticated AppleScript support allowing one to write stand-alone scripts to launch the application and open multiple sessions with profiles into either new tabs or new windows. You can also set some other parameters for a session such as foreground and background colors, and transparency.

These scripts can then be saved as stand-alone executable applications.

Autolaunching Scripts

iTerm2 also supports autolaunching of an AppleScript on startup. On startup, iTerm2 looks for an AppleScript file in ~/Library/Application Support/iTerm2/Scripts/AutoLaunch.scpt. If it is found, the AutoLaunch.scpt script is launched and executed.

User-Defined Scripts

iTerm2 also supports launching of user defined scripts from the Scripts menu. The scripts need to be stored under the ~/Library/Application Support/iTerm2/Scripts directory (or the folder set in Settings > General > Magic > Custom Python API Scripts Folder). You can create this directory if it does not already exist. AppleScripts must be named with the extension .scpt or .app.

Reference

Objects

The basic objects are: window, tab, and session. The application has zero or more windows, each window has one or more tabs, and each tab has one or more sessions. Multiple sessions in a tab happen when there are split panes.


Application

The application exposes various properties and provides functions that are described in this section. For example:

tell application "iTerm2"
  create window with default profile
end tell

create hotkey window with profile "name"
Creates a hotkey window with the specified profile. The profile must be configured to have a hotkey. Example: create hotkey window with profile "Hotkey Window"

create window with default profile
create window with default profile command "command"

These commands create a window with the default profile. If you specify a command, it overrides the profile's command (which by default is to invoke `login`). Examples: set newWindow to (create window with default profile) set newWindow to (create window with default profile command "ls -l -R /")

create window with profile "name"
create window with profile "name" command "command"

These commands create a window with a named profile. If you specify a command, it overrides the profile's command (which by default is to invoke `login`). Returns a reference to the new window. Examples: set newWindow to (create window with profile "Name Of Some Profile") set newWindow to (create window with profile "Name Of Some Profile" command "ls -l -R /")

current window

A reference to the window that most recently had keyboard focus. tell current window ... end tell

windows

A windows property exposes an array of terminal windows. Other windows, like the Settings panel, are not included. The following are standard AppleScript idioms for accessing elements of an array of objects:

tell first window
...
end tell

repeat with aWindow in windows
...
end repeat

Windows

These functions and properties are provided by windows. For example:

tell application "iTerm2"
  tell current window
    create tab with default profile
  end tell
end tell

There are many standard AppleScript functions (e.g., to get the window's size and position) that are not documented here.

create tab with default profile
create tab with default profile command "command" create tab with profile "name"
create tab with profile "name" command "command"

Creates a tab with the default profile or a profile by name. If the command is specified, it is run instead of the profile's command/login shell.

Returns a reference to the new tab.

current session

The current session is the session that would receive keyboard input if the window had keyboard focus.

current tab

The current tab is the tab that is selected in the window.

hide hotkey window

If this is a hotkey window, it hides it with the standard hotkey window animation and makes the previously active application active, if appropriate.

hotkey window profile

Returns the name of the hotkey window profile associated with this window, if any.

id

The window ID. Useful for commands like screencapture.

is hotkey window

Returns a boolean value which is true if the window is a hotkey window associated with a profile.

name

The window's name, as appears in the title bar.

reveal hotkey window

If this is a hotkey window, it reveals it with the standard hotkey window animation and makes it key and the application active.

select

Gives the window keyboard focus and brings it to the front.

tabs

An array of tabs. See the methods on Tab, below.

toggle hotkey window

Either shows or hides the hotkey window, if this is a hotkey window, using the standard animation. May make the app active or inactive.


Sessions

These functions and properties are provided by sessions. For example:

tell application "iTerm2"
  tell current session of current window
    split horizontally with default profile
  end tell
end tell

background image

This is a string property that gives a path to the background image of the session.

close

Terminates the session and closes its pane.

Color properties

Various properties which are readable and settable affect the session's colors:

  • background color
  • bold color
  • cursor color
  • cursor text color
  • foreground color
  • selected text color
  • selection color
  • underline color
  • ANSI black color
  • ANSI red color
  • ANSI green color
  • ANSI yellow color
  • ANSI blue color
  • ANSI magenta color
  • ANSI cyan color
  • ANSI white color
  • ANSI bright black color
  • ANSI bright red color
  • ANSI bright green color
  • ANSI bright yellow color
  • ANSI bright blue color
  • ANSI bright magenta color
  • ANSI bright cyan color
  • ANSI bright white color

An example:

set foreground color to {65535, 0, 0, 0}

Because AppleScript is kind of a dumpster fire, the standard syntax for a color is {red, green, blue, alpha} where each value is a number between 0 and 65535.

There is also a boolean use underline color property that controls whether the underline color is applied, and a color preset property that you can set to the name of a color preset to apply it.

answerback string

The string sent when the ENQ escape sequence is received.

columns

The width of the session in character cells.

contents

Returns the visible contents of the session as a string. Each row is terminated with a newline.

id

Returns the session's unique identifier.

is at shell prompt

Indicates if the session is at a shell prompt accepting a command. Only works if Shell Integration is installed; if not it will return false.

is processing

Returns a boolean indicating if the session received output recently.

name

A string property with the session's name as seen in its title bar.

profile name

The name of the profile the session was created with. A string. Read-only.

rows

The height of the session in character cells.

set columns to number
set rows to number

Changes the size of the session.

split horizontally with default profile
split vertically with default profile
split horizontally with default profile command "command"
split vertically with default profile command "command"

Splits the session either horizontally or vertically. If the optional command is provided then it is run in place of the profile's command. A horizontal split has a horizontal divider, while a vertical split has a vertical divider.

Returns a reference to a session.

create floating pane
create floating pane with profile "name"
create floating pane command "command"
create floating pane with profile "name" command "command"

Adds a floating pane, which floats over the split panes, to the session's tab. The default profile is used unless you name a profile. If the optional command is provided then it is run in place of the profile's command. This fails in a tmux tab or when the window’s layout is locked (Window > Lock Layout).

Returns a reference to the new session.

split horizontally with profile "name"
split vertically with profile "name"
split horizontally with profile "name" command "command"
split vertically with profile "name" command "command"

Like the "default profile" commands, but uses a named profile instead of the default profile.

split horizontally with same profile
split vertically with same profile
split horizontally with same profile command "command"
split vertically with same profile command "command"

Like the "default profile" commands, but uses the current session's profile.

select

Makes the session active in its tab. Does not affect which tab is selected or which window has keyboard focus.

text

A synonym for contents.

transparency

A floating-point value from 0 to 1 giving how transparent the session is.

tty

The name of the session's tty (e.g., /dev/ttys01). Returns a string.

unique id

A string uniquely identifying the session.

variable "name"
set variable named "name" to "value"

Gets and sets the value of a variable by name. Variables are described in Badges. You may only set user-defined variables, whose names always begin with "user.".

write text "text"
write text "text" newline NO

Writes text to the session, as though you had typed it. Optionally without a newline.

write contents of file "filename"

Writes the contents of a file to the session as though you had typed it.


Tabs

These functions and properties are provided by tabs. For example:

tell application "iTerm2"
  tell current tab of current window
    select
  end tell
end tell

close

Closes the tab.

current session

The session in this tab that most recently had keyboard focus.

index

The index of the tab in the window, starting from 0.

select

Selects the tab, making it the current tab for the window.

sessions

An array of sessions in this tab.

Supporting both old and new versions of iTerm2

If your application needs to support both the old and new AppleScript syntax, this is the recommended technique:

on theSplit(theString, theDelimiter)
    set oldDelimiters to AppleScript's text item delimiters
    set AppleScript's text item delimiters to theDelimiter
    set theArray to every text item of theString
    set AppleScript's text item delimiters to oldDelimiters
    return theArray
end theSplit

on IsModernVersion(version)
    set myArray to my theSplit(version, ".")
    set major to item 1 of myArray
    set minor to item 2 of myArray
    set veryMinor to item 3 of myArray
    
    if major < 2 then
        return false
    end if
    if major > 2 then
        return true
    end if
    if minor < 9 then
        return false
    end if
    if minor > 9 then
        return true
    end if
    if veryMinor < 20140903 then
        return false
    end if
    return true
end IsModernVersion

on NewScript()
    -- Return the modern script as a string here; what follows is an example.
    return "create window with default profile"
end NewScript

on OldScript()
    -- Return the legacy script as a string here; what follows is an example.
    return "
    set myTerm to (make new terminal)
    tell myTerm
        launch session \"Default\"
    end tell"
end OldScript

tell application "iTerm"
    if my IsModernVersion(version) then
        set myScript to my NewScript()
    else
        set myScript to my OldScript()
    end if
end tell

set fullScript to "tell application \"iTerm\"
" & myScript & "
end tell"

run script fullScript


AppleScript Examples

This is an example of the AppleScript syntax available in version 3.0 and later.

Note: AppleScript support is no longer receiving improvements. Use the Python API instead.

tell application iTerm2
  -- application-level commands
  -- These commands return a window.
  set newWindow to (create window with default profile)
  set newWindow to (create window with default profile command "ls -l -R /")

  select first window
  set newWindow to (create window with profile "Default")
  set newWindow to (create window with profile "Default" command "ls -l -R /")

  -- window-level commands
  repeat with aWindow in windows
    tell aWindow
      tell current session
        set newSession to (split horizontally with default profile)
        -- Optional command argument added 12/5/2015
        set newSession to (split horizontally with default profile command "ssh example.com")
      end tell
    end tell
  end repeat
  tell current window
    -- These commands return a tab
    set newTab to (create tab with default profile)
    set newTab to (create tab with profile "Projection")
  end tell
  tell current window
    tell current session
      set columns to 40
      set rows to 40
    end tell
  end tell

  -- tab-level commands
  tell current window
    tell second tab
      select
    end tell
    tell first tab
      close
    end tell
    tell current tab
      log title
      repeat with aSession in sessions
        tell aSession
          write text "Hello"
        end tell
      end repeat
       end tell
   end tell

  -- session-level commands
  tell current session of first window
    write text "cat > /dev/null"
    write text "cat > /dev/null" newline NO
    write contents of file "/etc/passwd"
    -- Get the path to the current session's tty and write it
    write text (tty)
    -- Get the content of the session and write it back
    write text (text)
    -- Get the session's unique identifier and write it back
    write text (unique ID)

    -- These commands return a session
    set newSession to (split vertically with default profile)
    set newSession to (split vertically with profile "Default")
    set newSession to (split vertically with same profile)
    
    -- Optional command argument added 12/5/2015
    set newSession to (split vertically with default profile command "ssh example.com")
    set newSession to (split vertically with profile "Default" command "ssh example.com")
    set newSession to (split vertically with same profile command "ssh example.com")

    set newSession to (split horizontally with default profile)
    set newSession to (split horizontally with profile "Default")
    set newSession to (split horizontally with same profile)

    -- Optional command argument added 12/5/2015
    set newSession to (split horizontally with default profile command "ssh example.com")
    set newSession to (split horizontally with profile "Default" command "ssh example.com")
    set newSession to (split horizontally with same profile command "ssh example.com")

    -- Add a floating pane to the session's tab
    set newSession to (create floating pane)
    set newSession to (create floating pane with profile "Default")
    set newSession to (create floating pane with profile "Default" command "ssh example.com")

    set foreground color to {65535, 0, 0, 0}
    set background color to {65535, 0, 0, 0}
    set bold color to {65535, 0, 0, 0}
    set cursor color to {65535, 0, 0, 0}
    set cursor text color to {65535, 0, 0, 0}
    set selected text color to {65535, 0, 0, 0}
    set selection color to {65535, 0, 0, 0}
    set underline color to {65535, 0, 0, 0}
    set ANSI black color to {65535, 0, 0, 0}
    set ANSI red color to {65535, 0, 0, 0}
    set ANSI green color to {65535, 0, 0, 0}
    set ANSI yellow color to {65535, 0, 0, 0}
    set ANSI blue color to {65535, 0, 0, 0}
    set ANSI magenta color to {65535, 0, 0, 0}
    set ANSI cyan color to {65535, 0, 0, 0}
    set ANSI white color to {65535, 0, 0, 0}

    set ANSI bright black color to {65535, 0, 0, 0}
    set ANSI bright red color to {65535, 0, 0, 0}
    set ANSI bright green color to {65535, 0, 0, 0}
    set ANSI bright yellow color to {65535, 0, 0, 0}
    set ANSI bright blue color to {65535, 0, 0, 0}
    set ANSI bright magenta color to {65535, 0, 0, 0}
    set ANSI bright cyan color to {65535, 0, 0, 0}
    set ANSI bright white color to {65535, 0, 0, 0}

    set background image to "/usr/share/httpd/icons/small/rainbow.png"
    set name to "New Name"
    set transparency to 0.5
    -- The name of the session's profile (different from the
    -- session's name, which can be changed by editing the Session
    -- Title field in Edit Session or by an escape sequence).
    -- Added 10/6/15.
    write text (profile name)

    -- is processing means it has received output in the last two seconds.
    if (is processing) then
      set foreground color to { 65535, 65535, 65535, 65535 }
    end if

    -- This will only work if shell integration is installed.
    -- Otherwise it always returns false.
    if (is at shell prompt) then
      set background color to { 65535, 0, 65535, 65535 }
    end if

    -- New in 2.9.20160104
    set answerback string to "Hello world"

    -- New in 2.9.201601. See https://iterm2.com/badges.html for more on variables.
    variable named "session.name"
    set variable named "user.phaseOfTheMoon" to "Gibbous"
  end tell
end tell

Supporting both old and new versions of iTerm2

If your application needs to support both the old and new AppleScript syntax, this is the recommended technique:

on theSplit(theString, theDelimiter)
    set oldDelimiters to AppleScript's text item delimiters
    set AppleScript's text item delimiters to theDelimiter
    set theArray to every text item of theString
    set AppleScript's text item delimiters to oldDelimiters
    return theArray
end theSplit

on IsModernVersion(version)
    set myArray to my theSplit(version, ".")
    set major to item 1 of myArray
    set minor to item 2 of myArray
    set veryMinor to item 3 of myArray
    
    if major < 2 then
        return false
    end if
    if major > 2 then
        return true
    end if
    if minor < 9 then
        return false
    end if
    if minor > 9 then
        return true
    end if
    if veryMinor < 20140903 then
        return false
    end if
    return true
end IsModernVersion

on NewScript()
    -- Return the modern script as a string here; what follows is an example.
    return "create window with default profile"
end NewScript

on OldScript()
    -- Return the legacy script as a string here; what follows is an example.
    return "
    set myTerm to (make new terminal)
    tell myTerm
        launch session \"Default\"
    end tell"
end OldScript

tell application "iTerm"
    if my IsModernVersion(version) then
        set myScript to my NewScript()
    else
        set myScript to my OldScript()
    end if
end tell

set fullScript to "tell application \"iTerm\"
" & myScript & "
end tell"

run script fullScript

Legacy Note

Note: in iTerm2 3.0.0, sessions had a property called contents. That conflicted with a reserved word, and has been renamed to text. The example below reflects proper usage for version 3.0.1 and up.


Buried Sessions

A buried session is a session that continues to run but is not a part of any window. If you have a long-running job that you want out of the way, it can be convenient to bury its session. It is used by default for the session where you initiate a tmux integration client using tmux Integration.

To bury the current session, select Session > Bury Session. To restore a session, select it from the list of buried sessions in Session > Buried Sessions.


Copy Mode

Copy Mode allows you to make selections using the keyboard. To enter or exit Copy Mode, select Edit > Copy Mode. You can also enter copy mode by pressing Shift+Arrow key immediately after making a selection with the mouse. A special cursor rendered as a downward-pointing arrow is visible while in Copy Mode.

While in Copy Mode, the session's contents will not change. You can use the keyboard to move the cursor and modify the selection using these keystrokes:

Changing Modes

Keystroke Action
C-space Stop selecting
Esc, q, C-c, C-g Exit copy mode
C-v Toggle rectangular selection
Space, v Toggle selection by character
V Toggle selection by line

Basic Movement

Keystroke Action
h, Left arrow Move left
j, Down arrow Move down
k, Up arrow Move up
l, Right arrow Move right

Content-Based Movement

Keystroke Action
Meta-Left arrow, M-b, Shift-tab, b Move back one word, treating symbols as word breaks.
M-Right arrow, M-f, Tab, w Move forward one word, treating symbols as word breaks.
B Move back one word, treating symbols as part of a word.
W Move forward one word, treating symbols as part of a word.
[ Move to previous mark
] Move to next mark

Screen Movement

Keystroke Action
C-b, Page Up Move up one screen
C-f, Page Down Move down one screen
H Move to top of visible area
M Move to middle of visible area
L Move to bottom of visible area

Line Movement

Keystroke Action
^, M-m Move to start of indentation
0 Move to start of line
$ Move to end of line
Return Move to start of next line

Document Movement

Keystroke Action
g Move to start
G Move to end

Other Commands

Keystroke Action
o Swap cursor and other selection endpoint
C-k, y Copy selection

Menu Items


iTerm2 Menu

iTerm2 > Show Tip of the Day

When you start using iTerm2 it will offer to show you a daily tip describing a feature. You can show a tip immediately by selecting this item.

iTerm2 > Companion Device Settings

Opens the pairing window for the companion app (iTerm2 Buddy). See Companion for details.

iTerm2 > Suppressed Alerts…

Lists alerts and announcements (the bars at the top of a session) that iTerm2 no longer shows because you chose to remember your response, for example by turning on “Remember my choice” or choosing “Never,” “Always,” or “Don’t Ask Again.” Each row shows the alert, the response being given automatically, and when it was last suppressed. Select one and click Un-suppress to see it again, or click Un-suppress All. Turn on Always show alerts with remembered selections to show all of them again until you turn it off.

iTerm2 > Check for Updates…

Checks to see if a new version of iTerm2 is available. If Settings > General > Software Update > Update to Beta test releases is turned on then this includes beta versions; otherwise only stable versions are downloaded.

While an update downloads and installs, its window can be minimized. A download that loses its network connection picks up where it left off. Once the update is ready to install you can relaunch right away, or close the window and the update is installed the next time you quit iTerm2. If automatic updating ever stops working, iTerm2 can still tell you that a new version is available and offer a link to download it.

iTerm2 > Toggle Debug Logging

This saves helpful debugging information in memory. When it is toggled off it is saved to /tmp/debuglog.txt.

iTerm2 > Save Retrospective Debug Logs

Writes recently captured low-frequency diagnostic information to a file, even if debug logging was never turned on. This is useful for reporting issues you did not anticipate.

iTerm2 > Copy Performance Stats

This copies information about drawing speed to the pasteboard. This is useful when reporting issues relating to poor performance.

iTerm2 > Capture GPU Frame

This saves information about how the current session is drawn. This is useful when reporting issues relating to drawing errors in the GPU renderer.

iTerm2 > Secure Keyboard Entry

When this is enabled, the operating system will prevent other programs running on your computer from being able to see what you are typing. If you're concerned that untrusted programs might try to steal your passwords, you can turn this on, but it may disable global hotkeys in other programs.

iTerm2 > Make iTerm2 Default Term

Makes iTerm2 the default terminal for opening .command, .tool, .zsh, .csh, and .pl files.

iTerm2 > Make Terminal Default Term

You must hold down Option for this entry to be visible. Makes Terminal.app the default terminal for opening .command, .tool, .zsh, .csh, and .pl files.

iTerm2 > Install Shell Integration

This opens a window that guides you through the installation of the Shell Integration features.

iTerm2 > Install Claude Code Integration

This opens a window that guides you through setting up the Claude Code Integration. Once the integration is installed, this item is replaced by Reinstall and Uninstall entries.

iTerm2 > Reinstall Claude Code Integration

Reopens the Claude Code Integration setup window, for example if Claude Code has rewritten its settings and dropped the status hook. This item is visible only when the integration is installed.

iTerm2 > Uninstall Claude Code Integration

Removes the Claude Code Integration: the status hook it added to Claude Code's settings, the Claude Code Workgroup, and the Enter/Exit Workgroup triggers. This item is visible only when the integration is installed.

iTerm2 > Remove Recent Profiles from Dock Menu

Clears the list of recently used profiles shown in iTerm2’s Dock menu.


Shell Menu

Shell > New Window/Tab

This creates a new window or tab with the default profile. If the current session is a tmux integration session, then you will be prompted for whether to create a local or tmux session.

Shell > New Window/Tab with Current Profile

This creates a new tab using the same profile as the current session rather than the default profile.

Shell > New Floating Pane with Current Profile

Adds a floating pane to the current tab, using the profile of the current session. A floating pane floats over the tab’s split panes.

Shell > Duplicate Tab/Window

Creates another tab or window with the same arrangement of split panes, profile, etc. A duplicated tab opens immediately to the right of the original tab.

Shell > Split Vertically/Horizontally

These menu items allow you to divide a tab into two or more split panes. The panes can be adjusted by dragging the line that divides them. They will use the default profile.

Shell > Split Vertically/Horizontally with Current Profile

These menu items allow you to divide a tab into two or more split panes. The panes can be adjusted by dragging the line that divides them. They will use the profile of the current session.

Shell > Save Contents

Save the entire contents of the current session to a file.

Shell > Save Selected Text

Saves the selected text to a file.

Shell > Close

Terminates the current session.

Shell > Close Terminal Window

Terminates all sessions in the current window.

Shell > Close All Panes in Tab

Terminates all sessions in the current tab.

Shell > Undo Close

Undoes closing a session, tab, or window (⌘⇧T). The closed session’s job keeps running in the background until the time limit expires, so Undo Close brings it back exactly as it was. You can set the limit under Settings > Profiles > Session > “Undo” can revive a closed session for up to this many seconds.

If the profile archives sessions when they close (Settings > Profiles > Session > Archive sessions on closure), Undo Close keeps working after the time limit runs out: the session’s job is gone, but its contents come back from its archive in its original split pane, tab, and window. The 20 most recent of these can be undone even after you restart iTerm2. See Session Archives.

Undo Close used to be bound to ⌘Z. Now ⌘Z is Edit > Undo, which undoes text editing. The first time you press ⌘Z while a closed session can still be restored, iTerm2 explains the change and lets you choose Undo Close or a regular undo.

Shell > Archives > ...

Lets you save and restore session archives. See Session Archives for details.

  • Save Archive of Current Session...: Writes an archive of the current session to a file.
  • Restore Archive...: Opens an archive file, recreating the saved session.
  • [Recent archives]: The most recently saved archives are listed for quick restoration.

Shell > Toggle Buffer Input

Starts or stops buffering typed input. While buffering, keystrokes are held rather than sent to the session; toggling it off sends the buffered input.

Shell > Broadcast Input > ...

These options allow you to send keyboard input to more than one session. Be careful.

  • Send input to current session only: The default setting.
  • Broadcast to all panes in all tabs: Anything you type on the keyboard goes to all sessions in this window.
  • Broadcast to all panes in current tab: Anything you type on the keyboard goes to all sessions in this tab.
  • Toggle broadcast input to current session: Toggles whether this session receives broadcasted keystrokes within this window.
  • Show Background Pattern Indicator: If selected, sessions receiving broadcast input get an obnoxious red-stripe background.

Shell > tmux > ...

These commands let you interact with the tmux integration

  • Detach: Detaches from the tmux session associated with the current pane. It remains running in the tmux server.
  • Force Detach: Leaves tmux integration mode without waiting for tmux, which is useful if it has stopped responding. The tmux client may still be running afterward.
  • New tmux Window/Tab: Creates a new tmux window, which appears in either a native window or tab, as requested.
  • Dashboard: The tmux dashboard is a view that lets you see all your tmux sessions and windows at a glance, adjust which are visible, rename them, and change the current tmux session.

Shell > ssh > Disconnect

Closes an SSH integration SSH connection.

Shell > ssh > Download files

Available when SSH Integration is in use. Opens a file picker showing files on currently connected remote hosts. Selecting one or more files downloads them.

Shell > ssh > Remote host can control iTerm2

A per-connection permission that lets the it2 command-line tool running on the remote host drive your local iTerm2. A checkmark is shown while the permission is granted.

Shell > Workgroups > ...

A Workgroup builds a set of related sessions from the current one. This submenu lists your configured Workgroups along with a command to leave the current one:

  • [Workgroup name]: Enters that Workgroup, spawning its Peers, splits, and tabs from the current session.
  • Exit Workgroup: Leaves the current Workgroup, closing the sessions it created and leaving the main session running.

Shell > Print

I'm thinking printers!


Edit Menu

Edit > Undo/Redo

Undoes or redoes text editing in the field you are editing, such as the composer, the browser’s address bar, annotations, notes, or AI chat. To reopen a session, tab, or window you closed, use Shell > Undo Close (⌘⇧T) instead.

Edit > Copy with Styles

Hold down Option while the Edit menu is open to turn Copy into Copy with Styles (⌥⌘C). It copies the selection as rich text (RTF), including fonts and colors, so the text keeps its appearance when pasted into an app such as TextEdit. With no selection, it copies the selected command and its output, if a command is selected.

Edit > Copy with Control Sequences

Copies the selected text, including control sequences that will reproduce the appearance (bold, colors, etc.) of the copied text when pasted into a terminal. Note that these will not be exactly the control sequences that were originally received, but instead a reconstruction that has the same effect.

Edit > Copy Mode

Enters Copy Mode which lets you make selections using the keyboard. See Copy Mode for details.

Edit > Paste Special > Advanced Paste

This opens the Advanced Paste window which lets you select a string from the pasteboard in recent history, select different representations of the current pasteboard, and modify the string before pasting it. You can modify it by applying a regex substitution, using various built-in modifiers (such as base-64 encoding), or edit it by hand.

Edit > Paste Special > Paste Selection

Pastes the currently selected text (which may differ from the text in the pasteboard).

Edit > Paste Special > Paste File Base64-Encoded

If there is a file on the pasteboard then this is enabled. When invoked, it base64-encodes the file and pastes the encoded value.

Edit > Paste Special > Paste Slowly

"Paste Slowly" pastes the current string in the clipboard, but it doesn't send the whole string at once. It is sent in batches of 16 bytes with a 125ms delay between batches.

Edit > Paste Special > Paste Faster/Slower

Adjusts the speed of pasting to be faster or slower.

Edit > Paste Special > Paste Slowly Faster/Slower

Adjusts the speed of slow pasting to be faster or slower. You must hold down option for this menu item to be visible.

Edit > Paste Special > Warn Before Multi-Line Paste

When enabled, you'll be warned before pasting more than one line.

Edit > Paste Special > Limit Multi-Line Paste To Shell Prompt

If Warn Before Multi-Line Paste is on, then this restricts it to warn only when you're at the shell prompt. It only works if shell integration is installed, since otherwise iTerm2 cannot tell when you're at the shell prompt.

Edit > Paste Special > Prompt to Convert Tabs to Spaces when Pasting

If Prompt to Convert Tabs to Spaces when Pasting is enabled, you'll be asked whether to convert tabs to spaces when pasting text containing tab characters.

Edit > Paste Special > Warn Before Pasting One Line Ending in a Newline at Shell Prompt

This requires shell integration to be installed to work. If you try to paste one line that ends in a newline while at the shell prompt and this is enabled, you'll get a confirmation dialog before the text is pasted.

Edit > Replace Selection > Render Selection Natively

Replaces the selection with a native rendering. For example, Markdown is replaced with formatted text with different font sizes, weights, etc.

Edit > Replace Selection > Replace with Pretty-Printed JSON

Replaces the selection with nicely formatted JSON. You can click in the margin to collapse sections.

Edit > Replace Selection > Replace with Base 64-Encoded/Decoded Value

Replaces the selection by encoding or decoding its value. Note the selection must be an entire line, not a portion of a line.

Edit > Engage Artificial Intelligence

Passes the value at the cursor to AI as a prompt. If there is no value, you'll be asked to provide a prompt. If you have shell integration installed and keyboard focus is on the terminal, then iTerm2 will use what you've typed so far at the command prompt as the input to the AI.

Edit > Explain Output with AI

This is available when there is a selection or a selected command. That text will be sent to AI to explain. The terminal contents will be modified, adding annotations detailing what parts of the text mean. The chat window will open so you can drill down more.

Edit > Snippets

Gives access to Snippets, which are saved bits of text that can be pasted quickly. You can change snippets in Prefs>Shortcuts>Snippets.

Edit > Actions

Gives access to Actions, which are user-defined actions similar to those that can be bound to a keystroke. You can change actions in Prefs>Shortcuts>Actions.

Edit > Open Selection

Opens the selected text using semantic history or as a URL, if it is URL-like.

Edit > Jump to Selection

Scrolls the selection to be visible.

Edit > Selection Respects Soft Boundaries

When enabled, vertical lines of pipe characters | will be interpreted as pane dividers (as in vim or emacs) and selection will wrap at them.

Edit > Select Output of Last Command

Requires shell integration to be installed. Selects the output of the last command.

Edit > Select Current Command

Requires shell integration to be installed. Selects the text of the current command entered at the command prompt.

Edit > Find > Find

Opens or focuses the find panel. Select the down arrow to the left of the search field to open the options menu, which lets you select case insensitivity and regular expression options. The default case sensitivity option of "Smart Case Sensitivity" performs a case-sensitive search if the search query contains any upper case letters. Otherwise, a case-insensitive search is performed.

Edit > Find > Find Next/Previous

Next and previous are, by default, reversed from the macOS standard because in a terminal you generally want to search backwards. You can use Settings > Advanced > Swap Find Next and Find Previous to get the standard behavior.

Edit > Find > Find Globally

Opens a window that lets you search all tabs at once.

Edit > Find > Select Matches

Converts Find matches into selections.

Edit > Find > Find URLs

Searches the current session for URLish looking strings.

Edit > Find > Find All Smart Selection Matches

Searches for all smart selection regular expressions at once.

Edit > Find > Pick Result to Open

Shows a shortcut next to each find match. Typing the shortcut opens it using smart selection or, if it is URL-like, using the default URL handler.

Edit > Find > Filter

Opens a panel where you can enter text to filter by. Non-matching lines are temporarily hidden until the filter panel is closed.

Edit > Marks and Annotations > Set Mark

Records the current scroll position. Use Edit > Jump to Mark to restore the scroll position.

Edit > Marks and Annotations > Jump to Mark

Makes the last mark (either created by Set Mark or by shell integration) visible by scrolling to it.

Edit > Marks and Annotations > Next/Previous Mark

Reveals the next/previous mark by scrolling and highlighting it in blue or red (red if it was tagged as a failing command).

Edit > Marks and Annotations > Add Annotation at Cursor

Adds an annotation to the word beginning at the cursor. An annotation is a scratchpad for you to write notes about a chunk of text in your history.

Edit > Marks and Annotations > Annotate Selection

Adds an annotation to the current selection. This item has no keyboard shortcut by default, but you can assign one under Settings > Keys.

Edit > Marks and Annotations > Next/Previous Annotations

Reveals the next/previous annotation.

Edit > Marks and Annotations > Alerts > Alert on Next Mark

When a mark is set (typically by Shell Integration when the currently running shell command terminates) then show an alert.

Edit > Marks and Annotations > Alerts > Alert on Marks in Offscreen Sessions

When disabled, Alert on Next Mark alerts even if the session is not currently visible. When enabled, only visible sessions (those that are in a non-hidden window in a selected tab) will alert.

Edit > Set Named Mark

Asks for a name and adds a named mark at the current location. Named marks are listed in the Named Marks toolbelt tool and in Edit > Named Marks.

Edit > Named Marks

Lists the current session’s named marks. Select one to scroll to it.

Edit > Fold Selected Lines

Folds the selected lines, collapsing a block of output into a single foldable line. Click the fold to expand it again.

Edit > Fold All

Folds everything in the session, aside from folds at the very top of history.

Edit > Clear Buffer

Clears the entire terminal history and the mutable area.

Edit > Clear Instant Replay

Erases instant replay history for the current session.

Edit > Clear Scrollback Buffer

Clears scrollback history, preserving the mutable area.

Edit > Clear to Start Of Selection

Erases text between the start of the selection and the end.

Edit > Clear to Last Mark

Erases text between the last mark and the end.


View Menu

View > Show Tabs in Fullscreen

If enabled, tabs are shown in fullscreen windows.

View > Toggle Full Screen

Enters or exits full screen mode. iTerm2 supports both the standard macOS full screen mode, where the window occupies its own Space, and its traditional full screen mode that shares a Space with other windows. You can control which is used in Settings > General > Native full screen windows.

View > Toolbelt > Set Default Width

Saves the current window's toolbelt width as the default width for new windows' toolbelts.

View > Toolbelt > Show Toolbelt

This toggles the visibility of the Toolbelt on the right side of all windows.

View > Toolbelt > Actions

This toggles the visibility of the Actions tool, which shows actions you have configured under Settings > Shortcuts > Actions.

View > Toolbelt > Captured Output

This toggles the visibility of the Captured Output tool. It shows captured output located with the Capture Output trigger. See Captured Output for more information.

View > Toolbelt > Codecierge

This toggles the visibility of an AI assistant that helps you complete tasks in the terminal.

View > Toolbelt > Command History

This toggles the visibility of the Command History tool. It shows recently used commands. You must install Shell Integration for this to know your command history.

View > Toolbelt > Jobs

This toggles the visibility of the Jobs tool, which shows the running jobs in the current session, and allows you to send them signals.

View > Toolbelt > Named Marks

This toggles the visibility of the Named Marks tool, which helps you navigate to saved locations in the current session's history. In browser sessions, named marks take you to saved locations on a web page.

View > Toolbelt > Notes

This toggles the visibility of the Notes tool, which provides a freeform scratchpad in the toolbelt. Notes persist across restarts of the app and are saved in ~/Library/Application Support/iTerm2/notes.rtfd.

View > Toolbelt > Paste History

This toggles the visibility of the Paste History tool, which shows recently pasted strings in the toolbelt.

View > Toolbelt > Profiles

This toggles the visibility of the Profiles tool, which lets you select profiles to open new windows, tabs, and split panes.

View > Toolbelt > Recent Directories

This toggles the visibility of the Recent Directories tool. It shows recently used directories sorted by a combination of recency and frequency of use. You must install Shell Integration for this to know your directory history. You can right click a directory to open a context menu that allows you to "start" a directory. This keeps it pinned at the bottom of the list so it's easy to find.

View > Toolbelt > Session Status

This toggles the visibility of the Session Status tool, which lists your sessions along with the status each one reports. A session can report a status such as “working,” “waiting,” “done,” “error,” or “idle” from a trigger, from a control sequence such as OSC 7501 (the Program Status Protocol) or OSC 21337, or from an integration like Claude Code. The tool sorts sessions by priority so the ones that need attention rise to the top. Click the gear icon to reorder the priorities, and click a row to jump to that session.

View > Toolbelt > Snippets

This toggles the visibility of the Snippets tool, which helps you send frequently used text strings.

View > Use Transparency

This toggles transparency. It only has an effect if you have configured your session to be transparent under Settings > Profiles > Window > Transparency. When Full Screen mode is entered, transparency is turned off by default, but you can select this menu item to re-enable it.

View > Disable Transparency for Active Window

When enabled, the active window will never be transparent. Inactive windows will respect the transparency setting from Settings > Profiles > Window > Transparency.

View > Zoom In on Selection

When a selection is present this is enabled. Zooming on a selection removes all other text from the session and lets you focus on just the zoomed-in-on text. Pressing escape will invoke Zoom Out when you are in the Zoom In state.

View > Zoom Out

Exits the Zoom In on Selection mode.

View > Find Cursor

Reveals the current cursor position.

View > Show Cursor Guide

Toggles the visibility of the cursor guide which is a horizontal rule showing the location of the cursor.

View > Show Timestamps

Indicate the time of last modification of each line on the screen.

View > Show Annotations

Toggles the visibility of annotations.

View > Show Clippings

Toggles a panel in the session's right margin that lists clippings, bits of text collected for the session and shared with its Workgroup peers, which can be sent to the terminal.

View > Show Inline Chat

Toggles an AI chat panel hosted in the session's right margin, letting you converse with AI without opening a separate chat window.

View > Show Session Note

Shows, creating it if necessary, the session's floating note (opt-cmd-G). This is a freeform scratchpad attached to the session, distinct from the Notes toolbelt tool.

View > Show Composer

Toggles the visibility of the Composer, a text area that you can edit using native macOS keystrokes. This is convenient for preparing complex inputs.

View > Auto Command Completion

Automatically shows a window with command completion suggestions as you type. Only usable when you have command history built up with Shell Integration.

View > Auto Composer

Replaces the shell prompt with a macOS native text editing control. It offers filename and command completion, including over ssh when using SSH Integration. It requires Shell Integration to be installed in order to work.

View > Open Quickly

If you have lots of sessions you can quickly find the one you're looking for with Open Quickly. Select the View > Open Quickly menu item (cmd-shift-O) and then enter a search query. You can search by tab title, command name, host name, user name, profile name, directory name, badge label, and more. Queries are scored according to relevance and sorted by score. Open Quickly also lets you create new tabs, change the current session's profile, and open arrangements. If you start your query with a / then that gives you a shortcut to various commands. /a followed by an arrangement name restores the arrangement. /f restricts the query to existing sessions, excluding options to open new tabs, etc. /p restricts the query to profile names to switch the current session to. /t restricts the results to "open new tab" for matching profile names.

View > Maximize Active Pane

When there are split panes present, this toggles whether a given pane expands to fill the tab. When a maximized pane is present, the tab will be inscribed with a dotted outline. Floating panes stay visible over a maximized pane. If the active pane is a floating pane, it fills the tab and goes behind the other floating panes instead.

View > Size Changes Update Profile

If enabled, modifying the text size using View > Make Text Bigger or View > Make Text Smaller will cause the session's profile to be updated with the new font size.

View > Start Instant Replay

Stepping through time allows you to see what was on the screen at a previous time. This is different than going back through the scrollback buffer, as interactive programs sometimes overwrite the screen contents without having them scroll back. Once in this mode, you can use the left and right arrow keys to step back and forward, respectively. The "esc" key exits this mode, as does clicking the close button in the bar that appears on the bottom. You can adjust the amount of memory dedicated to this feature in Settings > Instant Replay uses xx MB per session. The more memory you assign, the further back in time you can step.


Session Menu

Session > Edit Session

This opens a window that lets you change the settings of the current session without affecting any other sessions. Changes made in this panel will not be overridden by subsequent changes to the profile. Settings not changed in this panel will be affected by changes to the profile.

Session > Run/Stop Coprocess

Allows you to start and stop a coprocess linked to the current session. Learn more about coprocesses.

Session > Restart Session

After a session ends (e.g., because the shell exits) this menu item becomes enabled. It will re-run your profile's command in the same viewport as the terminated session.

Session > Duplicate Session

Creates a new session as similar as possible to the current session. The current directory is preserved and if you are using ssh integration it will connect to the same host.

Session > Open Autocomplete...

Shows the autocomplete window, which offers to finish typing a word that you've begun. Learn more about autocomplete on highlights page.

Session > Open Command History...

If you use Shell Integration then Open Command History presents a list of recently used commands to select from.

Session > Open Recent Directories...

If you use Shell Integration then Open Recent Directories presents a list of recently used directories to select from.

Session > Open Paste History...

"Open Paste History" opens a window showing up to the last 20 values that were copied or pasted in iTerm2. You can search its contents by typing a (non-necessarily-consecutive) subsequence of characters that appear in the value. You can use arrow keys and enter to make a selection, or you can click on an item to choose it, and it will be pasted. If you enable the Save copy/pate history to disk preference then these values will persist across sessions of iTerm2.

Session > Open AI Chat

Creates a new AI chat and offers to link the current session to it.

Session > Triggers

Controls the current session's triggers. For more information see Triggers.

  • Add Trigger…: Opens a panel to add a trigger, with the selected text (if any) as a starting point for its regular expression.
  • Edit Triggers: Opens the session's list of triggers for editing.
  • Enable Triggers in Interactive Apps: Toggles whether triggers run while an interactive app (one using the alternate screen) is in the foreground.
  • Enable All and Disable All: Turn every trigger in the session on or off.

Below these, the submenu lists the session's triggers. A check mark shows which are enabled; select one to enable or disable it.

Session > Reset

Resets the internal state of the emulator and clears the screen. Use this if you get wedged in a bad state, like the wrong character set or mouse reporting mode is stuck.

Session > Terminal State

Shows and changes modes that programs normally set with control sequences. This is useful when a program exits without restoring them, for example leaving mouse reporting on. A check mark shows which modes are on, and selecting an item toggles it.

  • Alternate Screen: Switches between the main screen and the alternate screen.
  • Focus Reporting: Whether the program is told when the session gains or loses keyboard focus.
  • Mouse Reporting: Whether mouse events are sent to the program. Turning it back on restores the reporting mode the program last used.
  • Paste Bracketing: Whether pasted text is wrapped in bracketed paste sequences.
  • Application Cursor: Whether the arrow keys send application-mode sequences.
  • Application Keypad: Whether the numeric keypad sends application-mode sequences.
  • Standard Key Reporting Mode, modifyOtherKeys Mode 1, modifyOtherKeys Mode 2, CSI u Mode, and Raw Key Reporting Mode: Choose how keys are encoded. Standard Key Reporting Mode returns to ordinary key reporting.
  • Disambiguate Escape, Report All Event Types, Report Alternate Keys, Report All Keys as Escape Codes, and Report Associated Text: The individual flags of the kitty keyboard protocol. These are unavailable in tmux integration panes.
  • Literal Controls: Shows control characters the program writes as visible caret notation (such as ^[) in reverse video instead of acting on them. Useful for seeing exactly what a program sends.
  • Emulation Level: Sets the terminal's emulation level, from VT100 to VT500.
  • Reset: Resets the terminal's modes to their defaults and returns to the main screen, without clearing it.

The same submenu is in the session's context menu.

Session > Move Session > ...

Moves the current session somewhere else:

  • Move Session to Window: Moves the session into a new window of its own.
  • Move Session to Tab: Moves the session into a new tab of its own in the same window.
  • Move Session to Split Pane: Lets you pick a split pane to move the session next to, as when you drag a pane.
  • Move Session to Floating Pane: Lifts the session out of the tab’s split panes and makes it a floating pane in the same tab. The tab must have another split pane to leave behind. In tmux integration this requires tmux 3.8 or later.

Session > Log > Log to File

Logging saves all input received in a session to a file on disk.

Session > Log > Import/Export Recording

Lets you save or view an instant replay recording.

Session > Make Screenshot...

Creates a screenshot of the current session, including any highlights and redactions.

Session > Bury Session/Buried Sessions

Buries or unburies a session. See Buried Sessions for details.


Scripts Menu

If you have scripts located in $HOME/Library/Application Support/iTerm2/Scripts they'll be added to this menu. You can use a different folder by turning on Settings > General > Magic > Custom Python API Scripts Folder.

Scripts > Manage > New Python Script

Opens a UI to help you create a new Python API script. See the Python API for more information.

Scripts > Manage > Open Python REPL

Opens a window with a Python REPL to facilitate working with the Python API.

Scripts > Manage > Manage Dependencies

Opens a window that lets you adjust dependencies of Python API scripts. This is meant for people authoring a script who need to bring in a new PyPI dependency.

Scripts > Manage > Install Python Runtime

Downloads and installs the Python API Runtime used by Python API scripts. If a runtime is already installed, this checks for and installs any available update. Hold the Option key to change this item to Install Already-Downloaded Python Runtime, which installs a previously downloaded runtime without fetching it again.

Scripts > Manage > Reveal Scripts in Finder

Opens a Finder window in the Scripts folder.

Scripts > Manage > Import

Opens a file picker so you can pick a script file to import. It should have the extension .its.

Scripts > Manage > Export

Opens a file picker so you can pick a script file to export. This is used for sharing scripts with others. The export file will have the extension .its.

Scripts > Manage > Console

Opens the Script Console which shows which scripts are running, lets you view their logs, and has other developer tools for authors of Python API scripts. If you are using browser profiles then Javascript logs appear here as well.


Profiles Menu

This menu contains a list of profiles. Selecting one opens it in a new tab. Hold option while selecting a profile to open it in a new window, instead.

Profiles > Open Profiles...

This opens the “Profiles Window” which allows you to create new windows, tabs, or panes from one or more profiles. You can perform a search by entering text in the search field. Profile names and tags are searched, and the listed profiles are filtered as you type. You can use the up and down arrow keys to make a selection. Pressing enter will open a new tab, while shift-enter will open a new window. You can make multiple selections by holding down shift or cmd and clicking on profiles. The New Floating Pane button opens each selected profile as a floating pane in the current tab. The “New Tabs in New Window” button is enabled only when more than one profile is selected: it will open a new window and create a new tab for each profile selected.

Profiles > Open All

Opens all profiles in tabs (or in windows, if Option is pressed).


Web Menu

The Web menu is only visible when the current session is a web browser profile.

Web > Open Location…

Puts the cursor in the URL bar, showing the toolbar if it was hidden.

Web > Back/Forward

Standard web back/forward navigation.

Web > Reload Page

Reloads the current page.

Web > History

Opens the history page, which shows the sites you have visited in chronological order.

Web > Show Toolbar

Shows or hides the browser session’s toolbar (the navigation buttons and URL bar). With the toolbar hidden, the page fills the pane. Web > Open Location… brings the toolbar back.


Window Menu

Window > Arrangements > Save Window Arrangement

Saves all of the window's positions, tabs, and split panes. You can opt to save them with contents to a file or to save them to the collection of window arrangements (without content) that can be restored later from Window > Arrangements > Restore Window Arrangement (as Tabs) > (arrangement name).

Window > Arrangements > Load Arrangement From File...

Loads a saved arrangement file, which includes window contents.

Window > Arrangements > Change Profile in Arrangement…

Use this to edit an existing arrangement. First, restore the arrangement. Then activate one of the sessions from the restored arrangement. Select Change Profile in Arrangement and you'll be asked to choose a profile. The arrangement will then be updated to use the selected profile for the corresponding session.

Window > Edit Window Title

Opens a dialog that lets you specify a window title as an interpolated string.

Window > Tab > Edit Tab Title

Opens a dialog that lets you specify a tab title as an interpolated string.

Window > Tab > Select Tab > ...

Selects the next or previous tab. Select Next Tab Group and Select Previous Tab Group skip over the other tabs in the current tab’s group (including its sub-groups), so you can move from group to group. The submenu also lists the window’s tabs so you can pick one.

Window > Tab > Move Tab > ...

Move Tab to New Window moves the current tab into a window of its own. Move Tab Left and Move Tab Right move the current tab one position. In a tab group, they move just the current tab, not the whole group: moving a tab past the edge of its group takes it out of the group, and moving an ungrouped tab into a neighboring group adds it to that group.

Window > Tab > Add Tab to New Group…

Asks for a name and creates a new tab group containing the current tab.

Window > Tab > Move Tab to New Sub-group…

Available when the current tab is in a top-level tab group. Asks for a name and creates a new group nested inside the tab’s group, containing the current tab.

Window > Tab > Remove Tab from Group

Takes the current tab out of its tab group.

Window > Split Pane > Select Split Pane > ...

Selects the split pane above, below, left of, or right of the current one, or the next or previous pane. Next Peer and Previous Peer cycle among the peers of a Workgroup.

Window > Split Pane > Resize Split Pane > ...

Moves the dividers around the current split pane. If the current pane is a floating pane, these change its size instead: left and right change its width, and up and down change its height.

Window > Split Pane > Floating Panes > ...

Commands for floating panes, which float over a tab’s split panes:

  • Bring to Front: Puts the active floating pane in front of the tab’s other floating panes.
  • Send to Back: Puts the active floating pane behind the tab’s other floating panes.
  • Select Next Floating Pane: Activates the next floating pane in the tab and brings it to the front. Choosing it repeatedly cycles among them.
  • Dock Floating Pane: Moves the active floating pane into the tab’s split panes.
  • Hide Floating Panes: Hides all of the tab’s floating panes, or shows them again. Their sessions keep running while hidden.
  • Move Floating Pane Up/Down/Left/Right: Moves the active floating pane by one cell.

Window > Split Pane > Lock Split Pane Width

Toggles whether the active session's width is locked. A locked split pane does not change its width as the window is resized horizontally.

Window > Window Style > ...

Changes the style of the current window without changing its profile. The choices are the same as Settings > Profiles > Window > Style: Normal, Full Screen, Maximized, No Title Bar, Centered, Centered, No Title Bar, Full-Width Bottom of Screen, Full-Width Top of Screen, Full-Height Left of Screen, Full-Height Right of Screen, Bottom of Screen, Top of Screen, Left of Screen, and Right of Screen. Centered keeps the window centered on the screen with a title bar; Centered, No Title Bar does the same without a title bar or window buttons.

Window > Password Manager

Opens the password manager. In a browser session, it opens the browser’s password manager.

Window > AI Chats

Opens the AI Chat window.

Window > Lock Size

Prevents the window from being resized.

Window > Lock Layout

Freezes the window's layout. While enabled, you cannot split panes, add, close, or reorder tabs, close or drag panes, or move panes and tabs to other windows. Resizing panes, opening new windows, and closing the window itself still work.

Window > Lock Location

Pins the window to its current display and position. If anything else moves the window, it goes right back, and if its display is disconnected (as can happen while a laptop sleeps), the window returns to it when the display comes back. Dragging the window yourself turns the lock off. For styles that iTerm2 positions on the screen itself, such as Maximized, Centered, or the edge-of-screen styles, the lock keeps the window on its display and lets the style decide its frame there. The lock is not available for windows whose profile opens them on the screen with the cursor, and it has no effect while the window is full screen. It is saved with window arrangements.

Window > Notify on Status Change

Shows an alert the next time any session in the window changes its reported status, then turns itself off. See Session Status for details.

Window > Cockpit

Opens the Cockpit window, which lets you browse the status each session reports across all your windows. See Session Status for details.

Window > Arrange Windows > ...

Merge All Windows moves every tab into the current window. Arrange Windows Horizontally tiles the windows side by side. Arrange Split Panes Evenly makes the current tab’s split panes the same size.

Window > Pin Hotkey Window

Toggles whether the current hotkey window stays open when it loses keyboard focus.


Hotkeys

A hotkey is a keypress that iTerm2 responds to even if another application is active. iTerm2 recognizes three kinds of hotkeys: Toggle All Windows, Session Hotkeys, and Profile Hotkeys.

Toggle All Windows

This hotkey shows or hides all iTerm2 windows. It does not change their positions. It is meant for quickly switching between iTerm2 and other applications. Configure this in Settings > Keys > Show/hide all windows with a system-wide hotkey. Turn on the checkbox and then click in the text field beneath it and type the hotkey you'd like to use.

Session Hotkeys

You can assign a hotkey to a particular session. Select Session > Edit Session to modify properties of the current session. The preference window will open, and at the bottom of the General tab is a field where you can set a hotkey that opens iTerm2 to reveal that session.

Dedicated Hotkey Windows

A dedicated hotkey window is a window that is associated with a profile and has a hotkey attached to it. By pressing the hotkey, the window opens or closes. This is similar to the old Visor app. In its simplest form, it's a system-wide terminal window that you can open with a hotkey. iTerm2 allows you to assign multiple hotkeys to a single profile or even a single hotkey to multiple profiles. You can also assign the double-tap of a modifier.

To create your first dedicated hotkey window, go to Settings > Keys and click Create a Dedicated Hotkey Window…. This will create a new profile called Hotkey Window. You'll be prompted to configure the window. The following settings are available:

  • Pin hotkey window (stays open on loss of keyboard focus): If selected, the hotkey window remains open when another window gets keyboard focus. When off, the window will automatically hide when you select another window (whether in iTerm2 or another app). You can also toggle this for the current hotkey window with Window > Pin Hotkey Window.
  • Automatically reopen on app reactivation: If selected, this dedicated hotkey window will reveal itself when iTerm2 is activated (such as by clicking the dock icon or another iTerm2 window).
  • Animate showing and hiding: Controls whether hotkey windows animate in and out or quickly jump-cut in and out.
  • Floating window: When selected, the dedicated hotkey window can appear over other apps' full screen windows (provided the profile's Window > Space setting is All Spaces). Floating windows overlap the dock. Keys remapped in Settings > Keys > Remap Modifiers work in a floating hotkey window even while another app is active.
  • On Dock icon click: This setting configures what happens when the dock icon is clicked.

If you want to assign multiple hotkeys to a single dedicated hotkey window, add them by clicking Additional Hotkeys.

You can configure an existing hotkey window by clicking Configure Hotkey Window in Settings > Profiles > Keys.


Floating Panes

A floating pane is a session that floats over a tab’s split panes instead of taking up a share of the tab. It is handy for a quick shell, a log you want to glance at, or a tool you want to keep in view without rearranging your splits. A tab can have any number of floating panes, and they stay with the tab when you switch tabs.

Creating a Floating Pane

There are several ways to make one:

  • Shell > New Floating Pane with Current Profile (⌘⌥N) opens a new floating pane in the current tab using the current session’s profile.
  • Session > Move Session > Move Session to Floating Pane, or Move Session to Floating Pane in a pane’s context menu, lifts an existing split pane out of the layout and makes it a floating pane. The tab must have at least one other split pane to leave behind.
  • In the Profiles window (Profiles > Open Profiles…), the New Floating Pane button opens each selected profile as a floating pane in the current tab.
  • In the toolbelt’s Profiles tool (View > Toolbelt > Profiles), select one or more profiles and choose New Floating Pane from the pop-up menu above the list to open each as a floating pane in the current tab. Once it’s chosen, the play button beside the menu does the same thing again.
  • When the selected text is a web URL that iTerm2’s built-in browser can open, Open URL in Floating Pane in the context menu opens it in a browser session in a new floating pane.
  • You can bind a key to the New Floating Pane with Profile action in Settings > Keys > Key Bindings or Settings > Profiles > Keys, or assign the New Floating Pane With Profile… pointer action in Settings > Pointer.

A new floating pane is centered in the tab and takes up about 80% of its width and height.

You can’t add a floating pane while the window’s layout is locked (Window > Lock Layout) or during Instant Replay. This applies to scripts too: AppleScript’s create floating pane, the iterm2.create_floating_pane function, and the Python API’s Tab.async_create_floating_session fail in a window whose layout is locked. A workgroup member can’t become a floating pane.

Moving and Resizing

Drag a floating pane’s title bar to move it within its tab. Drag its edges or corners to resize it; the size snaps to whole rows and columns, and a readout shows the size while you drag. A floating pane can’t be made smaller than a few rows and columns, and it always stays inside its tab. If the tab gets too small for it, the floating pane shrinks or moves to fit and goes back to its old size and place when there is room again.

Clicking anywhere in a floating pane brings it in front of the other floating panes.

From the keyboard, Window > Split Pane > Floating Panes > Move Floating Pane Up/Down/Left/Right moves the active floating pane by one cell. The Window > Split Pane > Resize Split Pane commands resize it: Move Divider Left and Move Divider Right change its width, and Move Divider Up and Move Divider Down change its height.

Double-clicking a floating pane’s title bar, or View > Maximize Active Pane, maximizes it so it fills the tab. A maximized floating pane goes behind the tab’s other floating panes, which stay visible. Do it again to put it back where it was. (In a tmux integration tab, maximizing works as tmux’s zoom does instead.)

Docking and Moving to Another Tab

To put a floating pane into the tab’s split panes, choose Dock Floating Pane from its title bar’s context menu or from Window > Split Pane > Floating Panes. It becomes a split pane to the right of the split pane you used most recently.

You can also drag it:

  • Hold Control while dragging a floating pane’s title bar to turn the move into an ordinary pane drag. While Control is held, floating panes are hidden so you can see the split panes underneath. Drop the pane on one of them to dock it there.
  • Dragging a floating pane out of its tab also turns the move into a pane drag. Drop it in another tab (without Control) and it stays a floating pane there, where you dropped it. Drop it outside any window to give it a window of its own.
  • Dropping any pane that you are dragging onto a floating pane in another tab makes the dropped pane a floating pane in that tab.

Managing Floating Panes

The Window > Split Pane > Floating Panes submenu acts on the active floating pane and the current tab’s floating panes:

  • Bring to Front and Send to Back change the active floating pane’s stacking order.
  • Select Next Floating Pane activates the next floating pane, cycling through all of them, and brings it to the front.
  • Dock Floating Pane moves the active floating pane into the split panes.
  • Hide Floating Panes hides all of the tab’s floating panes without closing them; their sessions keep running. Choose it again to show them. While they are hidden, the split panes show an indicator in their upper right, which changes to let you know about new output, a bell, or a session that ended in a hidden floating pane. Moving keyboard focus into a floating pane (for example, with Select Next Floating Pane or Next Pane) shows them again.
  • Move Floating Pane Up/Down/Left/Right moves the active floating pane by one cell.

A floating pane’s title bar has a context menu with Dock Floating Pane, Bring to Front, and Send to Back, along with the usual pane commands. Swap With Session… works with floating panes too.

A floating pane holds exactly one session, so you can’t split it. Close it the way you close any pane; Shell > Undo Close brings it back where it was.

Saving and Restoring

Floating panes are saved with window arrangements and restored with your windows, including their position, size, stacking order, and whether they were hidden or maximized.

tmux Integration

In tmux integration, iTerm2 shows tmux’s own floating panes as floating panes. This requires tmux 3.7 or later. Creating, moving, resizing, raising, docking, and floating panes requires tmux 3.8 or later; with tmux 3.7 the floating panes are shown but can’t be changed. In a tmux tab, tmux decides where a new or docked floating pane goes. A pane that tmux draws without a border (pane-border-lines none) has no title bar until you show it with the toggle that appears when the pointer is over the pane.

A session that isn’t part of the tmux session can’t become a floating pane in a tmux tab, and a tmux pane can’t be dragged into a regular tab as a floating pane.

Scripting

The Python API can create floating panes (Tab.async_create_floating_session), dock them (Session.async_dock), and set their frames (Session.async_set_floating_frame). See the Python API documentation for details.


Password Manager

Overview

iTerm2 has a password manager that saves your passwords and types them into a session for you, so you don’t have to copy and paste them or type them yourself. Open it with Window > Password Manager (⌥⌘F). It opens as a sheet on the current window, or in a window of its own if no terminal window is open.

The built-in web browser has its own password manager, separate from the one for terminal sessions. When the current session is a browser session, Window > Password Manager opens the browser’s password manager instead. The two work the same way except where noted below.

Storage

By default passwords are saved in the macOS Keychain. Instead, you can use an existing password manager. Choose where passwords are stored from the gear menu at the bottom of the password manager window:

  • macOS Keychain
  • 1Password Integration
  • LastPass Integration
  • KeePassXC Integration
  • Bitwarden Integration
  • Keeper Security

The integrations use your password manager’s command-line tool (for example, op for 1Password and lpass for LastPass). The first time you choose one, iTerm2 walks you through setting it up. Reset Integration Configuration in the gear menu erases iTerm2’s settings for the current integration so you can set it up again; it doesn’t change the passwords themselves. Switch Account is available for integrations that support more than one account. Reload Items fetches the list of accounts again from where passwords are stored, for example after you’ve added or changed a password in the other password manager while iTerm2’s password manager was open.

Using the Password Manager

Search for an account by typing in the search field at the top. Select an account and click Enter Password to type its password into the current session. Enter User Name types the account’s user name. If you type a code into the 2-Factor Code field, it is appended to the password. Turn on Broadcast (⌘B) to send it to every session that receives broadcast input (Shell > Broadcast Input) as well.

The + and - buttons add and remove accounts, and Edit changes the selected account. When adding an account, the dice button generates a random password; hold Option while clicking it to use only letters and digits.

Right-click an account for these actions:

  • Reveal Password shows the password.
  • Copy Password copies it to the pasteboard.
  • Append OTP toggles whether the account’s one-time password is appended to its password when it is entered. It’s available only for accounts that have a one-time password in an integrated password manager.

The gear menu in the terminal password manager also has these settings:

Probe Before Sending Password

When enabled, iTerm2 checks that the session isn’t echoing what you type before it sends the password, so the password doesn’t appear on screen if you weren’t actually at a password prompt.

Automatically Send Return Key after Password

When enabled, a newline is sent after the password.

Other ways to open the password manager:

  • The Open Password Manager trigger opens it when a password prompt appears, with an account selected.
  • The profile setting Settings > Profiles > Session > Open password manager automatically when a password prompt is detected opens it whenever iTerm2 detects that the session is waiting for a password. It’s off by default.
  • In a browser session, a button appears in user name and password fields on web pages. Click it to pick a saved login and fill it in.

Authentication

The password manager can ask for Touch ID or your login password before showing your passwords. Choose how often it asks in the gear menu:

  • Don’t Require Authentication
  • Require Authentication Once per Launch (the default)
  • Require Authentication Once per Launch and after Screen Locks
  • Require Authentication on Every Open

With Require Authentication Once per Launch and after Screen Locks or Require Authentication on Every Open, locking the screen closes the password manager if it is open, so whoever unlocks the screen must authenticate again to see your passwords.

This setting applies to both the terminal and browser password managers. Because it protects your passwords, changing whether authentication is required, or whether it is required on every open, asks for an administrator password.

Exporting and Importing Passwords

Passwords saved in the macOS Keychain can be exported to a file and imported on another Mac. Passwords stored in other password managers can’t be exported this way; use that password manager’s own export instead.

To export, choose Export Passwords… from the gear menu. iTerm2 asks you to authenticate with Touch ID or your login password (even if the password manager doesn’t otherwise require it), then asks where to save the file and for a passphrase. The file, which has the extension .iterm2passwords, is encrypted with that passphrase, and you’ll need the passphrase to import it. The terminal password manager exports terminal passwords and the browser password manager exports browser passwords.

To import, choose Import Passwords… from the gear menu, or double-click a .iterm2passwords file in Finder. After you authenticate and enter the file’s passphrase, iTerm2 adds the passwords. Passwords can only be imported into a password manager that uses the macOS Keychain. If a password for the same account is already saved with a different value, you’re asked whether to replace it: Replace, Don’t Replace, or Always Replace and Never Replace to answer for the rest of the import. When it finishes, iTerm2 shows how many passwords were added, replaced, and kept.

Settings > General > Export All Settings and Data… can include your Keychain passwords, too. Turn on Include saved passwords (encrypted with a passphrase) in the save panel. It’s off every time, because the file holds every password. When you import that file with Import All Settings and Data…, iTerm2 asks for the passphrase; cancel to import everything except the passwords.


tmux Integration

iTerm2 is integrated with tmux, allowing you to enjoy a native user interface with all the benefits of tmux's persistence.

Introduction

Normally, when you use tmux, multiple virtual windows are displayed in a single "physical" window. You can manipulate the environment by issuing commands to tmux. This poses a few problems:

  • Some keystroke must be dedicated to tmux to enter its command mode (^B, by default, which means moving the cursor to the left in emacs or an interactive shell becomes more difficult).
  • You have to ssh to the remote host more than once to get more than one view of your tmux session's window.
  • You have to learn tmux commands.
  • To adjust split panes, you have to enable mouse reporting, even if you don't want it otherwise.
  • Some built-in features of your terminal emulator don't work as well as they would if you weren't using tmux: for instance, you can't access tmux's scrollback history as easily or quickly as you can in a normal terminal window. Also, tmux's find feature isn't as good as iTerm2's.

For many users, a terminal multiplexer would be a great way to work, but they don't want to accept the drawbacks.

iTerm2's tmux integration solves these problems.

When you run "tmux -CC", a new tmux session is created. An iTerm2 window opens and it acts like a normal iTerm2 window. The difference is that when iTerm2 quits or the ssh session is lost, tmux keeps running. You can return to the host you were ssh'ed into and run "tmux -CC attach" and the iTerm2 windows will reopen in the same state they were in before. A few use cases come to mind:

For users who do most of their work in ssh:

  • Restore the environment you had at work when you get home.
  • No more anxiety about letting System Update reboot!

For everyone:

  • Collaborate with another user by having two people attach to the same tmux session.

Usage

You should be able to use tmux as always. Just add the -CC argument to its invocation. In practice, this means running one of these commands:

  • tmux -CC
  • tmux -CC attach

When you run tmux -CC, what you'll see on that terminal is a menu:

** tmux mode started **

Command Menu
----------------------------
esc    Detach cleanly.
  X    Force-quit tmux mode.
  L    Toggle logging.
  C    Run tmux command.
  • If you press esc, the tmux windows will close and the tmux client will exit.
  • If you press esc and nothing happens, then the tmux client may have crashed or something else has gone wrong. Press "X" to force iTerm2 to exit tmux mode. You may need to run "stty sane" to restore your terminal's state if the tmux client did crash.
  • If you want to report a bug, press L and reproduce the issue. The tmux protocol commands will be written to the screen.
  • If you want to run a tmux command that isn't available through the menus, you can press C. A dialog box opens and you can enter a command. For example, "new-window".

In general, you don't need to run commands to perform the most common actions. The following iTerm2 actions affect tmux:

  • Close a session, tab, or window: Kills the tmux session or window.
  • Split a pane: Splits the tmux window using the split-window command.
  • Resize a split pane: Resizes tmux split panes using the resize-pane command.
  • Resize a window: Tells tmux that the client size has changed, causing all windows to resize. Windows are never larger than the smallest attached client. A gray area on the right or bottom of a window indicates that a physical window is larger than the maximum allowed tmux window size. One consequence of this rule is that all tmux windows/tabs will contain the same number of rows and columns.
  • Create a window or tab using the Shell->tmux menu: Creates a new tmux window.
  • Detach using Shell->tmux->Detach: Detaches from the tmux session. All tmux windows are closed. You can get them back with tmux -CC attach.

Limitations

There are a few limitations of tmux integration which are related to the design of tmux.

  • A tab with a tmux window may not contain non-tmux split panes.
  • A tab with split panes may have "empty" areas. This is because tmux wants every tmux window to be the same size, but our split pane dividers are not exactly one cell by one cell in size.

Configuration

Check Settings > General > tmux for configuration settings. You can also adjust whether to open the tmux Dashboard when connecting to a session with a large number of windows. You can open the tmux Dashboard by selecting the menu item Shell > tmux > Dashboard.

See also the tmux section of General Settings.

The tmux Dashboard

The tmux Dashboard, opened with Shell > tmux > Dashboard, lists the sessions on the tmux server and the windows in the selected session, and lets you choose which windows are shown. When it opens, it selects the session you're attached to, which has a checkmark. A gray checkmark marks a session that another tmux integration connection is attached to. A spinner shows while the list of windows loads.

Tab Groups

Tab groups of tmux integration tabs are remembered by the tmux session, so when you detach and reattach they come back with their names, colors, and nesting.

tmux Integration over SSH Integration

When you run tmux -CC on a host you reached through SSH Integration, iTerm2 knows that every pane is on that host. The git status component and other features that depend on a session's host work in its panes even when shell integration isn't loaded there, and each pane knows which program is running in it: the tab shows the job, the Jobs tool lists the pane's processes, and triggers that watch for a program work there. Uploading files by dropping them on a pane, including Upload and Paste Path, works too.

A program running in a pane can use the it2 command-line tool's --tmux "$TMUX" --tmux-pane "$TMUX_PANE" options to act on the session showing its pane. See Targeting a tmux Pane.

Improvements in 3.7

iTerm2 3.7 brings several enhancements to tmux integration:

  • An advanced setting, Open tmux windows and tabs in the background?, reveals a newly attached or created tmux window or tab without moving keyboard focus to it. Focus stays on the session you were already using.
  • When a tmux window is created outside iTerm2 (for example, by running tmux new-window in another client), an advanced setting now lets you choose where it opens: in a new window, in the window that currently has keyboard focus, or in the topmost window that already shows a tab from that tmux session.
  • OSC 52 clipboard query responses now work with tmux 3.6 and later in tmux integration.
  • Per-pane key reporting (modifyOtherKeys) state is now restored when you reattach, using formats available in tmux 3.5 and later. Reattaching while an app such as nvim is running keeps the correct key reporting mode. Bracketed-paste state is restored the same way where your tmux build reports it.

Best Practices

For practical tips on how to configure iTerm2 for use with tmux integration in the real world, please see tmux Integration Best Practices.


Touch Bar

As with many applications, you may customize the controls on the touch bar with View > Customize Touch Bar. The following controls are available:

Man Page

Opens the manpage for the command behind the cursor.

Color Preset

When selected, this opens a scrollable list of color presets. Choosing one changes the current terminal's colors to use the preset.

Function Keys

There are two function keys controls. The first, labeled Function Keys Popover, opens a scrollable list of function keys when pressed. It is compact but requires two taps to press a function key. The second, labeled Function Keys, shows a scrollable list of function keys at all times. It takes more space but is quicker to use.

If you install Shell Integration and Utilities, then you'll get a command it2setkeylabel that lets you configure what each function key's label says. You can configure each application you use (such as vim or emacs) to set the labels appropriately.

Add Mark

The Add Mark touch bar control saves the current location in history. You can navigate among marks with Cmd-Shift-Up and Cmd-Shift-Down. There are also touch bar controls to navigate marks.

Next/Previous Mark

Navigates to the next or previous mark. If you have Shell Integration installed, each command prompt inserts a mark, so the previous mark is usually the previous shell prompt.

Autocomplete Suggestions

If you have Shell Integration installed, iTerm2 can remember you command history. That history is used to make suggestions for commands, which appear in this touch bar control.

Status

The status touch bar control shows a user-configurable message. If you install Shell Integration and Utilities, then you'll get a command it2setkeylabel that lets you configure what the status control says. For example, it could display the git branch of the current directory. Tapping it scrolls to the location where the status was last changed.

For example, suppose you want to show your current git branch in the touch bar.

  1. Select the menu item View > Customize Touch Bar
  2. Drag "Your Message Here" button into the touch bar
  3. Modify PS1 to include \[$(it2setkeylabel set status "$message")\]. For example:
PS1='\s-\v\$\[$(~/.iterm2/it2setkeylabel set status \
"$(test -d .git && (git rev-parse --abbrev-ref HEAD) || (echo -n "Not a repo"))")\] '

Custom Buttons

You can define custom touch bar buttons in Prefs > Keys > Add Touch Bar Item. You can then add the item to your touch bar from View > Customize Touch Bar.


Shell Integration

iTerm2 may be integrated with the unix shell so that it can keep track of your command history, current working directory, host name, and more--even over ssh. This enables several useful features.

Shell integration is compatible with bash, fish (2.3 and later), nushell (0.100 and later), tcsh, xonsh (iTerm2 3.6.10 and later), and zsh.

How To Enable Shell Integration

This section describes the four ways to enable shell integration:

  1. Load it automatically.
  2. Use the Install Shell Integration menu item.
  3. Install it by hand.
  4. Configure triggers appropriately.


Load Automatically

In iTerm2 version 3.5 and later you can enable shell integration by enabling Load shell integration automatically in Settings > Profiles > General in the Command section. This is available if your Command is set to SSH or if it's set to Login Shell and your shell is supported.


Install Shell Integration Menu Item

To modify your shell's dotfiles to load shell integration, you can select the menu item iTerm2 > Install Shell Integration. You'll first be asked whether you wish to install the Utilities. Utilities consist of a number of shell scripts that provide useful functionality, such as displaying inline images, performing file transfer, or customizing the display.

Next you can choose to download and run an installer or to do an internet-free install.

The download-and-run option will type this command for you:

curl -L https://iterm2.com/shell_integration/v2/install_shell_integration.sh | bash

Alternately, select Internet-Free Install. This runs a sequence of commands to determine your shell, install files, and modify your dotfiles to load shell integration automatically.


Install By Hand

If you prefer to have control over the process of modifying your environment, you can manually install shell integration by creating files and editing your shell's configuration. Select your shell to see the appropriate instructions:

bash | fish | nushell | tcsh | xonsh | zsh

curl -L https://iterm2.com/shell_integration/v2/bash \
-o ~/.iterm2_shell_integration.bash
Next, you need to load the script at login time. You need to add the following command to ~/.bash_profile or ~/.profile. If you already have .profile then add it there, otherwise add it to .bash_profile. Put it at the end because other scripts may overwrite the settings it needs, such as `PROMPT_COMMAND`.
source ~/.iterm2_shell_integration.bash


Triggers

Installing a login script on every host you connect to is not always an option. To be sure, modifying root's login script is usually a bad idea. In these cases you can get the benefits of shell integration by defining triggers. The following triggers are of interest:

  • Report User & Host
  • Report Directory
  • Prompt Detected

Use these triggers to tell iTerm2 your current username, hostname, directory, and the location of the shell prompt. Suppose you have a shell prompt that looks like this:

[email protected]:/home/george%

It exposes the username, hostname, and working directory. We can harvest those with a regular expression. First, define a trigger with this regex:

^(\w+)@([\w.]+):.+%

It captures the username and hostname from the example prompt above. Select the action "Report User & Host". Set the trigger's parameter to:

\1@\2

Then create another trigger with the action Report Directory. This regular expression will extract the directory from the example prompt:

^\w+@[\w.]+:([^%]+)%

Set this trigger's parameter to

\1

Make sure both triggers have their Instant checkbox enabled so they'll take effect before a newline is received.

Finally, add a regular expression that matches the start of your prompt and give the "Prompt Detected" action. This causes a "mark" to be added, which is a blue triangle visible to the left of this line (or a horizontal line above, if Auto Composer is enabled).

You may specify a user name or host name alone to Report Host & User. If you give just a user name then the previous host name will be preserved; if you give just a host name then the previous user name will be preserved. To change the user name only, give a parameter like user@. To change the host name only, give a parameter like example.com.

Features

Shell Integration enables numerous features:

Marks

These are saved locations in history. They make it easy to navigate to previous shell prompts or other locations of interest.

Select Output of Last Command

The menu item under Edit selects the output of the last-run command.

Alert when current command finishes running.

iTerm2 will present a modal alert when a long-running command finishes, if you ask it to.

View information about commands.

You can see the return status code, working directory, running time, and more for shell commands entered at the prompt in the past.

Download files from remote hosts with a click.

You can right click on a filename (e.g., in the output of ls) to download it.

Drag-drop files to upload with scp.

Drop a file from Finder into a session on a remote host to upload it, or to choose another way to paste it.

View command history.

It can be seen and searched in the toolbelt or quickly accessed in a popup window.

Easy access to recently and frequently used directories.

iTerm2 remembers the directories you use, sorting them by "frecency" (frequency and recency of use) and giving you access to them in the toolbelt and in a popup window.

Assign profiles to hostnames, usernames, or username+hostname combinations.

Sessions will automatically switch profiles as you log in and out according to rules you define.

Ensures the command prompt always starts at the left column, even when the last command didn't end in a newline.

Each of these features are described in more detail below.

Offscreen Command Line

When part of a command's output is scrolled off the top of the screen, the originating prompt is shown there.

Auto Composer

Auto Composer replaces your shell's prompt with a macOS-native text view that uses native editing conventions.

Command Selection

Click on a command to select it; then Find, Filter, and Select All will be restricted to that command's output.

How it works

Shell Integration works by configuring your shell on each host you log into to send special escape codes that convey the following information:

  • Where the command prompt begins and ends.
  • Where a command entered at the command prompt ends and its output begins.
  • The return code of the last-run command.
  • Your username.
  • The current host name.
  • The current directory.
  • Whether the shell is running on this Mac.

The last item lets iTerm2 recognize a shell running on your own Mac by machine identity rather than by host name, so features that only work locally keep working when the host name doesn't match, such as over a VPN or Tailscale connection. The script computes a keyed hash of the Mac's boot session ID and iTerm2 compares it with its own; the raw ID is never sent. Shell integration scripts installed by older versions of iTerm2 don't report it, so reinstall shell integration (iTerm2 > Install Shell Integration) to get it. When it's missing, iTerm2 falls back to comparing host names.

How to use it

Marks

When shell integration is enabled, iTerm2 automatically adds a mark at each command prompt. Marks are indicated visually by a small blue triangle in the left margin.

You can navigate marks with Cmd-Shift-Up and Down-arrow keys.

If you have a multi-line prompt and would like to customize the mark's location, add this to your PS1 at the location where the mark should appear:

For zsh:

%{$(iterm2_prompt_mark)%}

For bash:

\[$(iterm2_prompt_mark)\]

Fish users can place this line somewhere in their fish_prompt function:

iterm2_prompt_mark

Xonsh users can put marks to PROMPT in xonsh RC file explicitly:

$PROMPT = '{iterm2_prompt_start}' + $PROMPT + '{iterm2_prompt_end}'

This feature is not supported in tcsh.

Right-hand prompts

The zsh, fish, and tcsh scripts also mark the right-hand prompt (RPROMPT and RPS2 in zsh, fish_right_prompt in fish, and rprompt in tcsh), so features that pick out the command you typed, such as Select Current Command and the saved command history, leave it out. In tcsh, this moves the right-hand prompt one column to the left. In zsh and tcsh, set the variable ITERM2_SQUELCH_RPROMPT_MARK before the script loads to turn this off.

For zsh and bash users: if you are unable to modify PS1 directly (for example, if you use a zsh theme that wants to control PS1), you must take an extra step. Add export ITERM2_SQUELCH_MARK=1 before the shell integration script is sourced. Add the iterm2_prompt_mark as directed above to your prompt through those means available to you.

Alert on next mark

iTerm2 can show an alert box when a mark appears. This is useful when you start a long-running command. Select Edit>Marks and Annotations>Alert on next mark (Cmd-Opt-A) after starting a command, and you can go do something else in another window or tab. When the command prompt returns, a modal alert will appear, calling attention to the finished job.

Command status

The mark on a command line will turn red if a command fails. You can right click the mark to view its return code.

Download with scp

You can right-click on a filename (e.g., in the output of ls) and select Download with scp from hostname, and iTerm2 will download the file for you. In a session connected with SSH Integration, the menu item is Download using SSH Integration from hostname and works on folders as well as files.

A new menu bar item will be added called Downloads that lets you view downloaded files and track their progress.

Upload with scp

If you drop a file (e.g., from Finder) into iTerm2 while holding the option key, iTerm2 will offer to upload the file via scp to the remote host into the directory you were in on the line you dropped the file on. A new menu bar item will be added called Uploads that lets you view uploaded files and track their progress.

If you drop files into a session on a remote host without holding option, iTerm2 asks what to do with them. For a single file the choices are:

  • Upload and Paste Path: uploads the file and types its path on the remote host.
  • Upload: uploads the file without typing anything.
  • Paste Base64-Encoded Contents: types the file's contents, base64-encoded.
  • Paste as Text: types the file's contents. Offered only for a text file.

For a folder, Upload and Paste Base64-Encoded Archive (tar.gz) are offered. For several files, the choices are Upload and Paste Paths, which uploads them all and types their remote paths in the order you dropped them, and Upload. Local paths aren't offered when iTerm2 knows the session is on another machine (through SSH Integration, or shell integration's machine identity), since they name nothing on that host. When iTerm2 only guesses that the host is remote because its name isn't one of this Mac's, Paste Path is offered too. Pasting a file or an image from the clipboard on a remote host offers the same choices.

Uploads go to the session's current directory. In a session connected with SSH Integration, they go to your home directory on the host if shell integration hasn't reported a directory yet. Pasted images, such as screenshots, are converted from TIFF to PNG and each gets a unique, timestamped name. This works in tmux Integration windows reached through SSH Integration, too.

Command history

With shell integration, iTerm2 can track your command history. The command history is stored separately for each username+hostname combination. There are four places where this is exposed in the UI:

Command history popup

You can view and search the command history with Session>Open Command History... (Shift-Cmd-;).

Autocomplete

Commands in command history are also added to Autocomplete (Cmd-;). If Settings>General>Save copy/paste history and command history to disk is enabled, then command history will be preserved across runs of iTerm2 (up to 200 commands per user/hostname).

Toolbelt

A command history tool may be added to the toolbelt by selecting Toolbelt>Command History.

Bold commands are from the current session. Clicking on one will scroll to reveal it. Double-clicking enters the command for you. Option-double-clicking will output a "cd" command to go to the directory you were in when it was last run.

Command Completion

iTerm2 will present command completion suggestions automatically when View>Auto Command Completion is selected.

Recent Directories

With shell integration, iTerm2 will remember which directories you have used recently. The list of preferred directories is stored separately for each username+hostname combination. It is sorted by "frecency". There are two places it is exposed in the UI:

Recent Directories popup

You can view and search your recently and frequently used directories in Session>Open Recent Directories... (Cmd-Opt-/).

Toolbelt

A Recent Directories tool may be added to the toolbelt by selecting Toolbelt>Recent Directories.

Double-clicking a directory will type its path for you into the current terminal. Option-double-click will enter a "cd" command for you. You can also right-click on a directory to toggle its "starred" status. A starred directory will always appear at the bottom of the list so it is easy to find.

Automatic Profile Switching

Please see the documentation at Automatic Profile Switching.

Shell Integration for root

If you'd like to be able to use shell integration as root, you have two options. The first option, presuming you use bash, is to become root with sudo -s (which loads your .bashrc as root) and add this to your .bashrc:

test $(whoami) == root && source "${HOME}/.iterm2_shell_integration.bash"

The alternative is to use Triggers to emulate shell integration as described above.

Limitations

Shell integration loads inside tmux, including on a host you ssh to from a tmux pane. It works well with tmux integration (tmux -CC), which passes its escape codes on to iTerm2, so marks, the current directory and host, and the git status work in tmux integration panes. The regular tmux UI discards them, so they have no effect there.

Shell integration skips itself in GNU screen. It decides by $TERM: inside tmux ($TMUX is set, or $TERM begins with tmux or is screen-256color) it loads, and for other screen terminal types it doesn't. To make it load anyway, add this to your login script before loading shell integration:

export ITERM_ENABLE_SHELL_INTEGRATION_WITH_TMUX=1

A Note on SCP

iTerm2 can do uploads and downloads with scp as described above. There are a few things you should know.

iTerm2 links in libssh2, and does not shell out to scp. It respects /etc/known_hosts and ~/.ssh/known_hosts, and will update the latter file appropriately. Host fingerprints are verified, and host key prompts show SHA256 fingerprints, the same form ssh prints. RSA keys work only with servers that support RSA signatures with SHA-2 (roughly, servers from 2016 and later). Password, keyboard-interactive, and public-key authentication are supported. Private keys by default come from ~/.ssh/id_rsa, id_dsa, id_ed25519, or id_ecdsa, and may be encrypted with an optional passphrase.

iTerm2 respects ssh_config files, but only a subset of the commands are understood:

  • Host
  • HostName
  • User
  • Port
  • IdentityFile

Settings pulled from ssh_config override the hostname and user name provided by shell integration. The shell integration-provided host name is used as the text against which Host patterns are matched.

The following files are parsed as ssh_config files, in order of priority:

  • ~/Library/Application Support/iTerm/ssh_config
  • ~/.ssh/config
  • /etc/ssh_config

If you have trouble, see SCP Not Connecting on the wiki.

If you use SSH Integration then file transfer happens over the SSH Integration framing protocol rather than by using scp. This is generally more reliable because it doesn't require opening a new connection.

SSH Integration

SSH Integration is an alternative to plain ssh that keeps a channel open between iTerm2 and the remote host. You use it by setting a profile's Command to SSH (see Profiles > General), or by running the it2ssh utility in place of ssh. For more details, see SSH Integration on the wiki.

SSH Integration runs the ssh command through your login shell, so your dotfiles run first and ssh sees your exported environment. One benefit is that a custom SSH_AUTH_SOCK pointing at an agent that holds your keys is honored.

Shell Integration on the Remote Host

SSH Integration can load shell integration on the remote host for you, without installing anything there. it2ssh does this by default; run it2ssh --no-shell-integration to skip it. An SSH profile follows its Load shell integration automatically setting. Shells that can't have it loaded this way (such as tcsh, and the bash 3.2 that comes with macOS) still get the rest of SSH Integration, including it2.

it2 on the Remote Host

The it2 command-line tool works on the remote host and controls your local iTerm2, once you allow it. A command that names no session acts on the session it runs in for most it2 commands.

File Transfer

Shell > SSH > Download Files… and the Download using SSH Integration context menu item download files and folders from the remote host. Dropping files into the session uploads them, as described in Upload with scp.

git Status

The git status component of the status bar shows the status of a repository on the remote host by running git there, so git must be installed on the host. You don't need to set up it2git.

tmux Integration

When you run tmux -CC on a host reached through SSH Integration, iTerm2 knows that every pane is on that host, so the git status component and other features that depend on a session's host work in its panes even without shell integration loaded there. Each pane also knows which program is running in it: the tab shows the job, the Jobs tool lists the pane's processes, and triggers that watch for a program work there.


Smart Selection

iTerm2 offers a Smart Selection feature that simplifies making selections on semantically recognizable objects.

How do I use Smart Selection?

A quad-click (four clicks of the left mouse button in quick succession) activates Smart Selection at the mouse cursor's position. By default, the following kinds of strings are recognized:

  • Words bounded by whitespace or line boundaries.
  • C++-style pairs of identifiers separated by double colons, such as "namespace::identifier".
  • Filesystem paths, such as "/foo/bar/baz.txt".
  • Quoted strings such as "foo bar".
  • Java or Python-style include paths, such as "foo.bar.baz".
  • URIs with the schemes: mailto, http, https, ssh, or telnet.
  • Objective-C selectors like "@selector(foo:bar:)".
  • Email addresses.

How do I Change Smart Selection Rules?

Under Settings>Profiles>Advanced, you may edit the smart selection rules. In addition to a regular expression, each rule also has a Precision attribute, which takes a value of Very Low, Low, Normal, High, or Very High. Intuitively, it refers to how sure one can be that when a rule's regular expression finds a match that it is what the user intended. For example, the "Word" rule is low precision (it matches almost every time), while the "HTTP URL" rule is very high precision (it almost never produces false positives). This allows the "HTTP URL" rule to take precedence when both match, unless the "Word" rule matches a much longer string. That might happen, for instance, if there were a non-URL character after a URL followed by a lot more text. The precision levels have a very strong effect, so it's very rare for a lower precision rule to take precedence over a higher precision rule.

When editing rules, it is advised that you experiment with different precision levels and different kinds of strings to find one that works well. A collection of test cases may be found at smart_selection_cases.txt.

When Smart Selection is activated, iTerm2 tries each regular expression. For a given regex, various strings on the screen are tested until the longest match is found. Only matches that include the character under the cursor are of interest. The longest such match is added to a pool of "selection candidates". Each candidate is assigned a score equal to its length in characters. Among the candidates in the highest precision class (where Very High is the highest class and Very Low is the lowest) with any matches, the higheset scoring one is used as the selection.

Actions

Actions may be associated with smart selection rules. When you right click in a terminal, smart selection is performed at the cursor's location. Any smart selection rule that matches that location will be searched for associated actions, and those actions will be added to the context menu. A cmd-click on text matching a smart selection rule will invoke the first rule.

The following actions are defined:

  • Open File: Opens the file using the default system application.
  • Open URL: Opens the URL using the default system browser.
  • Run Command: Runs the command using /bin/sh -c in the background. Output goes to the Script Console.
  • Run Coprocess: Starts a coprocess.
  • Send Text: Sends text as though it was typed by the user.
  • Run Command in Window: Opens a new window and runs the command in it.
  • Copy: Copies the string to the pasteboard.

Each action has a parameter. The meaning of the parameter depends on the action. For example, for the Open URL action the parameter should be a URL. The value you put in the Parameter field may contain special substrings which get substituted with values determined at runtime. By default, a legacy syntax is used with the following substitutions:

  • \0: The full text of the match.
  • \1: The first match group (captured using parentheses in the regular expression).
  • \2...\9: Subsequent match groups.
  • \d: The current directory.
  • \u: The current user name. If you're sshed then you must install Shell Integration for this to be known.
  • \h: The current host name. If you're sshed then you must install Shell Integration for this to be known.
  • \n: Newline
  • \\: Backslash

If you check the Use interpolated strings for parameters checkbox, then a more modern syntax is used. See the interpolated string documentation for details. For example, a parameter of \(path) is equivalent to the legacy syntax \d. In addition to the standard variables that are available in an interpolated string evaluated in a Session context, an array of strings called matches is defined. matches[0] is the full text of the match and matches[i] is the ith capture group for i > 0.

When using interpolated strings, the usual escaping rules apply.

Regular Expressions

Regular expressions conform to the ICU regular expressions rules.


Triggers

A trigger is an action that is performed when something happens in a terminal session. Most often the something is text matching a regular expression being received, but triggers can also fire in response to events such as a command finishing, the working directory changing, or a particular job starting.

How to Create a Trigger

To create a trigger, open the Settings panel. Select the Profiles tab. Choose the profile to which you wish to add a trigger. Then select the Advanced tab. Click the Edit button in the Triggers section. A panel opens that displays any existing triggers. You can click the + button to add a new trigger.

Every trigger has a match type, an action, and an optional parameter. The match type determines what causes the trigger to fire. When you add a trigger you choose its match type from a popup menu. There are two broad categories:

  • Regular Expression: the trigger fires when received text matches a regular expression. This is the default and most common kind of trigger. Regex triggers may also be marked as Instant.
  • Events: the trigger fires when a session event occurs, independent of any text on the screen. See Event Triggers below.

Regular Expression

Regular expressions conform to the ICU regular expressions rules. Text that is written to the screen including the BEL control code are sent to the regex matcher for evaluation. Only one line at a time is matched. By default, matching is performed when a newline or cursor-moving escape code is processed. If a line is very long, then only the last three wrapped lines are used (that is, the last three lines as seen on the display). This is done for performance reasons. You can change this limit in Advanced Settings > Number of screen lines to match against trigger regular expressions. Null bytes in received text are treated as spaces for the purpose of trigger regex matching.

Actions

The following actions are available:

  • Annotate: Associates a note with a matching text.
  • Bounce Dock Icon: Makes the dock icon bounce until the iTerm2 window becomes key.
  • Buffer Input: Starts or stops buffering typed input. See the Buffer Input feature.
  • Capture Output: Save the line to the Captured Output toolbelt tool. See Captured Output. The parameter is a coprocess command to run when you double-click an entry in the Captured Output tool.
  • Change Style: Modifies the style of matching text.
  • Enter Workgroup: Turns the session into a Workgroup, a cluster of related sessions.
  • Exit Workgroup: Leaves the current Workgroup. A leader-only option makes only the main session leaving tear the workgroup down.
  • Fold to Named Mark: Collapses all lines between the matching line and a preceding named mark with a given name.
  • Highlight Line: The entire line containing text matching the regex in the trigger will change color. The parameter sets the color.
  • Highlight Text: The text matching the regex in the trigger will change color. The parameter sets the color.
  • Inject Data: Inserts bytes into the input stream. These can be text or control sequences.
  • Invoke Script Function: Executes a function call defined using the Python API.
  • Make Hyperlink: The text matching the regex in the trigger will become a hyperlink which you can open with Cmd-Click. The parameter sets the URL.
  • Open Password Manager: Opens the password manager. You can specify which account to select by default.
  • Post Notification: Posts a notification with Notification Center.
  • Prompt Detected: Informs iTerm2 that the shell prompt begins at the start of the match. Used to emulate Shell Integration features. If the prompt is one line long then use Instant.
  • Report Directory: Tells iTerm2 what your current directory is. You can use this to enable Shell Integration features without installing the scripts. The parameter is your current directory.
  • Report User & Host: Tells iTerm2 what your user or host name is. You can use this to enable Shell Integration features without installing the scripts. To specify just a user name, say `user@`. For just a host, say `@host`. For both, say `user@host`.
  • Ring Bell: Plays the standard system bell sound once.
  • Run Command: Runs a user-defined command.
  • Run Coprocess: Runs a Coprocess.
  • Run Silent Coprocess: Runs a Coprocess but do not show text that's being received (it only goes to the coprocess).
  • Send Text: Sends user-defined text back to the terminal as though the user had typed it.
  • Set Mark: Sets a mark. You can specify whether you'd like the display to stop scrolling after the trigger fires.
  • Set Profile Setting: Turns a profile checkbox setting on or off for this session only, without changing the profile. Choose the setting from a searchable list, grouped the way the settings are laid out in Settings, and choose On or Off. Paired with the Job Started and Job Ended events it gives “while this job runs” behavior: for example, a Job Started trigger for claude that turns on the setting that prevents the system from sleeping (in Settings > Profiles > Session), and a Job Ended trigger for claude that turns it off. Settings whose checkbox is phrased in the negative and the setting that allows title reporting are not offered. This action can't be used with the Session Ended event.
  • Set Named Mark: Associates a name with the matching range. Various features help you navigate to named marks such as the Toolbelt tool and Open Quickly.
  • Set Tab Status: Sets the session's status (dot indicator, subtitle, and subtitle color) shown on its tab. Part of the Session Status feature.
  • Set Title: Sets the session's title.
  • Set User Variable: Assigns a value to a user-defined [variable](https://iterm2.com/documentation-variables.html).
  • Show Alert: Shows an alert box with user-defined text.
  • Stop Processing Triggers: When this action is invoked no triggers further down the list will be invoked for the current text.

Parameter?

Various actions (Run Command, Run Coprocess, Post Notification, Send Text, and Show Alert) require additional information. This is specified in the "Parameters" field. When the parameter is a text field with freeform entry, some special values are defined:

For event triggers, \0 is not defined (there is no matched text), but \1, \2, and so on refer to values captured from the event as described in the Event Triggers table.

Value Meaning
\0 The entire value matched by the regular expression.
\1, \2, ..., \9 The nth value captured by the regular expression.
\a A BEL character (^G).
\b A backspace character ^H.
\e An ESC character (ascii 27).
\n A newline character.
\r A linefeed character.
\t A tab character.
\xNN A hex value NN (for example: \x1b sends ascii code 27, an ESC).

Instant

When Instant is set, the trigger will fire once per line as soon as the match occurs, without waiting for a newline. This was added for the benefit of the Open Password Manager trigger, since password prompts usually are not followed by a newline. This may cause certain regular expressions (for example, ".*") to match less than they otherwise might. Instant applies only to regular-expression triggers.

Job

Every trigger has an optional Job field. When it is set, the trigger is active only while a foreground job of that name is running (the match is case-insensitive). Leave it empty to keep the trigger active at all times. This makes it possible to write triggers that apply only while a particular program is running, for example Claude Code.

The Job field is distinct from the Job Started and Job Ended events: those events fire once when a job begins or ends, whereas the Job field gates whether a trigger is considered at all.

Event Triggers

Instead of matching a regular expression, a trigger can fire in response to a session event. Choose an event from the match-type popup when creating or editing a trigger. Most trigger actions may be used with events; actions that only make sense for matched text, such as Highlight Text, are offered only for regular expressions.

Most events have an optional filter so the trigger fires only for events you care about (for example, only when a command exits non-zero, or only when a process named claude starts). Leave a filter blank to match every occurrence. Each event also provides captured values that you can reference in the action's parameter as \1, \2, and so on.

The available events are:

Event Fires when Filter Captures
Prompt Detected Shell integration detects a new prompt. None None
Command Finished A command exits. Requires shell integration. Exit code: any, zero (success), non-zero (failure), or a specific value. \1 = exit code
Directory Changed The working directory changes. Regular expression matching the directory path. \1 = new directory
Host Changed You connect to a different host (for example, via SSH). Regular expression matching the hostname. \1 = new host
User Changed The current user changes (for example, su or sudo). Regular expression matching the username. \1 = new user
Idle (Silence) No output is received for the specified duration. Timeout in seconds (default 30). \1 = timeout in seconds
Activity After Idle Output resumes after the session was idle. Timeout in seconds that defines "idle" (default 30). None
Session Ended The session terminates. None None
Bell Received A terminal bell (\a) is received. None None
Long-Running Command A command has been running longer than the threshold. Threshold in seconds (default 60) and an optional regular expression matching the command line. \1 = command, \2 = elapsed seconds
Custom Escape Sequence A custom escape sequence is received. Regular expression matching the sequence identifier. \1 = identifier, \2 = payload
Notification Posted A notification is posted by a control sequence (OSC 9). Regular expression matching the notification message. \1, \2, ... = notification text values
Progress Bar Changed A progress bar appears or disappears. Fire when the bar appears, disappears, or either. \1 = "appeared" or "disappeared"
Job Started A process matching the job filter enters the foreground-job ancestry chain. Job: process name to watch for (case-insensitive). Required. \1 = job name
Job Ended A process matching the job filter leaves the foreground-job ancestry chain. Job: process name to watch for (case-insensitive). Required. \1 = job name
Variable Changed A session variable changes value. Variable name to watch, plus an optional regular expression the new value must match. \1 = new value, \2 = variable name

Importing and Exporting Triggers

You can move triggers between profiles or share them with other people. In the trigger editor, select one or more triggers and click the share button. It offers Export to File, which writes an .it2triggers file, and Copy Trigger as URL to Clipboard, which puts a link to the selected triggers on the clipboard. Use the Import button to load triggers from an .it2triggers file.

Example

The iTerm2-zmodem project demonstrates hooking up iTerm2 to zmodem upload and download.


Captured Output

iTerm2 has a feature called "Captured Output" which helps you find and track important lines of output from logs, build processes, and such.

What does it do?

Captured Output is a tool that may be added to iTerm2's toolbelt (a view on the right side of terminal windows). It works in conjunction with user-defined Triggers. A Trigger whose action is Capture Output looks for lines of output that match its regular expression. When one is found, the entire line is added to the Captured Output tool. When the user clicks on a line in the Captured Output tool, iTerm2 scrolls to reveal that line. Double-clicking on a line in the Captured Output tools run a user-defined Coprocess.

Shell Integration Required

Shell Integration must be installed because Captured Output ties in to command history.

Ensure you have enough scrollback history to contain the full output of your build command. The default of 1000 may not be sufficient. You can adjust this in Prefs > Profiles > Terminal > Scrollback lines.

Example

One way to use Captured Output is to view compiler output. Suppose you run make and get thousands of lines of output, some of which may contain errors or warnings. You'd like to examine each one and take some action on it. Here's how you would use Captured Output to assist with this task:

Step 1: Create Triggers

Create a Trigger with the Capture Output action that matches your compiler's errors and warnings. Clang's errors look like this:

filename.c:54:9: error: use of undeclared identifier 'foo'

The following regular expression matches errors and warnings from Clang:

^([_a-zA-Z0-9+/.-]+):([0-9]+):[0-9]+: (?:error|warning):

There are two capture groups defined. We'll come back to those later.

Step 2: Open the Toolbelt

Open the Toolbelt by selecting the menu item Toolbelt > Show Toolbelt. Enable the Toolbelt > Captured Output menu item to ensure it is visible.

Step 3: Run make

Kick off the build by running make. It spits out thousands of lines of output.

Step 4: Examine the Captured Output tool

Any errors or warnings that appear in the compiler output will appear in the Captured Output tool.

Select an entry in the tool. iTerm2 scrolls to display the line and briefly highlights it in blue.

Step 5: Open the file containing the error

The Trigger created in step 1 takes an optional parameter. It is a command for iTerm2 to execute as a Coprocess when you double-click an entry in the Captured Output tool. An example command is:

echo vim \1; sleep 0.5; echo \2G

This coprocess command assumes you are at the command line, and it enters a command to open the offending file to the line number with an error. This is where the capture groups in the regular expression from step 1 become useful. For example, if the filename was "filename.c" and the error was on line 20, as in this error message:

filename.c:20:9 error: use of undeclared identifier 'foo'

The coprocess would:

  • Type "vim filename.c", followed by enter, as though you were typing it at the keyboard.
  • Wait half a second.
  • Type "20G".
  • Step 6: Check it off the list

    You can right-click on an entry in Captured Output to open a menu, which contains a single item: "Toggle Checkmark". This helps you remember which entries have been dealt with as you go through errors and warnings in your compiler output.

    Navigation

    Captured Output is linked to the Command History tool. If no command is selected in the Command History tool, then the most recent captured output is displayed. Otherwise, the captured output from the selected command is displayed. You can remove a selection from the Command History tool by cmd-clicking on it.

    Clearing Captured Output

    You can use the ClearCapturedOutput control sequence to remove captured output. This is useful to do before starting a compilation which may produce errors. Doing so ensures the only captured errors are from the most recent build. Use the following command in bash to produce the control sequence:

    printf "\e]1337;ClearCapturedOutput\e\\"


    Fonts

    While iTerm2 does not require monospaced fonts, they look much better than proportionately spaced fonts.

    iTerm2 has the capability of rendering text with thin strokes to improve readability. You can change how this works in the Text panel of the Profiles tab of Settings.

    You can also specify a "non-ASCII" font in the Text panel of profile Settings. This font will be used for all code points greater than or equal to 128 or for characters with combining marks.

    Some fonts, such as FiraCode, support ligatures if enabled in iTerm2. You can enable ligatures in Settings > Profiles > Text. Ligatures are rendered using CoreText's text shaping, which is slower than the fast path used for ordinary text. The GPU renderer supports ligatures as long as Enable support for right-to-left scripts in Settings > General > Experimental is on (the default); with that setting off, ligatures turn off the GPU renderer.


    Inline Images

    iTerm2 is able to display images within the terminal. Using a similar mechanism, it can also facilitate file transfers over any transport (such as ssh or telnet), even in a non-8-bit-clean environment.

    Just want to try it out and don't care about the protocol? Use the imgcat tool. Download imgcat here

    Example: imgcat

    Using the imgcat script, one or more images may be displayed in a terminal session. For example:

    Critically, animated GIFs are supported as of version 2.9.20150512.

    Retina

    Starting in iTerm2 version 3.2.0, Retina displays are properly supported. Previously, they would be double-size (one display "point" per image pixel rather than one display pixel per image pixel). If you prefer the old behavior, change Prefs > Advanced > Show inline images at Retina resolution.

    Protocol

    This document describes iTerm2's own inline image protocol. In addition to it, iTerm2 also supports the Kitty graphics protocol (using APC G escape sequences), which is documented separately by its authors.

    iTerm2 extends the xterm protocol with a set of proprietary escape sequences. In general, the pattern is:

    ESC ] 1337 ; key = value ^G

    Whitespace is shown here for ease of reading: in practice, no spaces should be used. ^G is the BEL character. You can use ST in place of ^G anywhere it is mentioned in this document. ST is the standard terminator for OSC sequences, and is formed by ESC \.

    For file transfer and inline images, there are two control sequences. The original one, which works on all remotely modern versions of iTerm2 is:

    ESC ] 1337 ; File = [optional arguments] : base-64 encoded file contents ^G

    The optional arguments are formatted as key=value with a semicolon between each key-value pair. They are described below.

    A new way of sending files was introduced in iTerm2 version 3.5 which works in tmux integration mode by splitting the giant control sequence into a number of smaller ones:

    First, send:

    ESC ] 1337 ; MultipartFile = [optional arguments] ^G

    Then, send one or more of:

    ESC ] 1337 ; FilePart = base64 encoded file contents ^G

    What size chunks should you use? Older versions of tmux have a limit of 256 bytes for the entire sequence. In newer versions of tmux, the limit is 1,048,576 bytes. iTerm2 also imposes a limit of 1,048,576 bytes.

    Finally, send:

    ESC ] 1337 ; FileEnd ^G
    KeyDescription of value
    name  base-64 encoded filename. Defaults to "Unnamed file".
    size  File size in bytes. Optional; this is only used by the progress indicator.
    width  Width to render. See notes below.
    height  Height to render. See notes below.
    preserveAspectRatio  If set to 0, then the image's inherent aspect ratio will not be respected; otherwise, it will fill the specified width and height as much as possible without stretching. Defaults to 1.
    inline  If set to 1, the file will be displayed inline. Otherwise, it will be downloaded with no visual representation in the terminal session. Defaults to 0.

    The width and height are given as a number followed by a unit, or the word "auto".

    • N: N character cells.
    • Npx: N pixels.
    • N%: N percent of the session's width or height.
    • auto: The image's inherent size will be used to determine an appropriate dimension.

    More on File Transfers

    By omitting the inline argument (or setting its value to 0), files will be downloaded and saved in the Downloads folder instead of being displayed inline. Any kind of file may be downloaded, but only images will display inline. Any image format that macOS supports will display inline, including PDF, PICT, or any number of bitmap data formats (PNG, GIF, etc.). A new menu item titled Downloads will be added to the menu bar after a download begins, where progress can be monitored and the file can be located, opened, or removed.

    Text and Markdown Files

    When a file sent inline isn't an image but is text, iTerm2 shows it in the session with syntax highlighting and proportionally spaced typography; see File Transfer on the escape codes page for the optional type and mode arguments. For example, imgcat README.md shows a Markdown file.

    Markdown is rendered much like a document: paragraphs reflow instead of keeping the file's line breaks, headings are bold with space around them, lists hang their text past the bullet or number and keep their numbering, code gets a background, block quotes get a bar, tables size their columns to fit, and horizontal rules span the width. Lists and quotes nest to any depth. Task lists, tilde code fences, bare URLs, HTML entities, and footnotes are recognized, and links use the profile's link color.

    Images referenced by the Markdown are never downloaded from the web; they appear as links. Images stored on your Mac appear as placeholders, and clicking one shows the image in a popover. Relative image paths are resolved against the Markdown file's directory. Local images are not shown when the text came from another machine.

    Detection

    Use the Feature Reporting protocol to detect the availability of inline images.

    Sample Code

    Sample code for displaying images may be found here.

    imgls

    Provides an augmented directory listing that includes a thumbnail of each image in a directory.

    imgcat

    Displays one or more images inline at their full size.

    it2dl

    Downloads a file, but does not display it inline.

    divider

    Draws a full-width, one line-tall graphical divider.


    Badges

    A badge is a large text label that appears in the top right of a terminal session to provide dynamic status, such as the current host name or git branch. Its initial value is defined in Settings>Profiles>General>Badge and it can be changed by an iTerm2-proprietary escape sequence. This value is an interpolated string, which means the badge can display the value of variables.

    Here is an example of a session with a badge indicating the current user and host name.

    Escape Sequences

    The badge may be set with the following control sequence:

    OSC 1337 ; SetBadgeFormat=Base-64 encoded badge format ST
    

    Here's an example that works in bash:

    # Set badge to show the current session name and git branch, if any is set.
    printf "\e]1337;SetBadgeFormat=%s\a" \
      $(echo -n "\(session.name) \(user.gitBranch)" | base64)
    

    Color

    The badge's color may be set in Settings>Profiles>Colors. The font and size can be adjusted by selecting Settings>Profiles>General>Edit… next to the Badge field.

    A program can also change the badge color with the SetColors escape sequence. Giving a palette index instead of an RGB value makes the badge follow the color preset and light or dark mode. For example, this makes the badge ANSI yellow at half opacity:

    printf "\e]1337;SetColors=badge=i:[email protected]\a"
    

    Session Status

    Because the badge can show any variable, it can show a session's status with \(session.status), or count the sessions that need you with \(iterm2.waitingSessionCount).


    Dynamic Profiles

    Dynamic Profiles is a feature that allows you to store your profiles in a file outside the usual macOS settings database. Profiles may be changed at runtime by editing one or more plist files (formatted as JSON, XML, or in binary). Changes are picked up immediately.

    Availability

    Dynamic Profiles are available in iTerm2 2.9.20140923 and later.

    Usage

    When iTerm2 starts, it creates a folder:

    ~/Library/Application Support/iTerm2/DynamicProfiles
    

    While iTerm2 runs, it monitors the contents of that folder. Any time the folder's contents change, all files in it are reloaded.

    Files in this folder are expected to be formatted as Apple Property Lists. No particular file extension is required. All files in the folder must be valid property lists. If any is malformed, then no changes will be processed.

    Property List Format

    A property list describes a data structure consisting of arrays, dictionaries, strings, integers, and boolean values. Property lists may be written in JSON or XML. Here's an example of the skeletal structure of a JSON property list that iTerm2 expects for Dynamic Profiles:

    {
      "Profiles": [
        {
           [attributes for the first profile go here]
        },
        {
           [attributes for the second profile go here]
        },
        [more profiles]
      ]
    }
    

    There are two required fields for each profile:

    • Guid
    • Name

    The "Guid" is a globally unique identifier. It is used to track changes to the profile over time. No other profile should ever have the same guid. One easy way to generate a Guid is to use the uuidgen program, which comes standard with macOS.

    The "Name" is the name, as seen in the Profiles window or in Settings.

    Here is a fully formed (but minimal) Dynamic Profiles plist:

    {
      "Profiles": [
        {
          "Name": "Example",
          "Guid": "ba19744f-6af3-434d-aaa6-0a48e0969958"
        }
      ]
    }
    

    Editing

    The only way to change a dynamic profile is to modify its parent profile or to modify the property list file. If you change its properties through the Settings UI those changes will not be reflected in the property list.

    Attributes

    Every profile preference that iTerm2 supports may be an attribute of a Dynamic Profile. Since there are dozens of attributes, you usually won't specify them all. Any attribute not specified will inherit its value from the default profile, or a specified "parent" profile (see below).

    The easiest way to find the name and legal value of a profile attribute is to copy it from a known-good reference. To get the JSON for a profile you already have, follow these steps:

    1. Open Settings > Profiles
    2. Select a profile
    3. Open the Other Actions menu beneath the list of profiles
    4. Select Save Profile as JSON
    5. Open the file in your favorite editor.

    If you use this as the basis of a Dynamic Profile, remember to change the Guid. A Dynamic Profile with a Guid equal to an existing Guid of a regular profile will be ignored.

    Parent Profiles

    Normally, a dynamic profile inherits any attributes you don't explicitly specify from the default profile. You may also specify a particular profile to inherit from using the Dynamic Profile Parent Name attribute. The value it takes is a profile name (that is, the name you see listed in the list of profiles in Settings box). Profile names are not guaranteed to be unique, but they are more convenient than GUIDs. If no profile with the specified name is found, the default profile is used instead. For example:

    Starting in version 3.4.9, Dynamic Profile Parent GUID is another way to specify a parent. It takes precedence over Dynamic Profile Parent Name.

    {
      "Profiles": [
        {
          "Name": "Example",
          "Guid": "ba19744f-6af3-434d-aaa6-0a48e0969958",
          "Dynamic Profile Parent Name": "Light Background"
        }
      ]
    }
    

    Rewritable

    You can mark a dynamic profile as "rewritable" which means iTerm2 can make changes to the file on disk to reflect changes made in the settings UI. Simply add "Rewritable": true to your profile to enable rewritability.

    Minutiae

    Dynamic profiles are loaded in alphabetical order by filename. Within a particular file, they are loaded in the order they're listed in. This only matters if one dynamic profile references another dynamic profile as its parent; the parent should be placed so it loads before any of its children. For all other purposes, the filenames don't matter.

    The Dynamic will automatically be added to all Dynamic Profiles.

    Troubleshooting

    If something goes wrong loading a Dynamic Profile, iTerm2 shows an alert describing the problem. Click View Log in the alert to see every error in the Script Console, which you can also open with Scripts > Manage > Console.

    Triggers

    By default, Highlight triggers save colors in a large inscrutable mess of a format. For dynamic profiles, you can use {#rrggbb,#rrggbb} in place of the large inscrutable mess. The first value gives the foreground color and the second value gives the background color. Replace either #rrggbb with an empty string to not change that color. For example, to make the foreground red without changing the background use #{ff0000,}.

    Example

    Here's an example for a common use case: a list of profiles for sshing to various hosts. In this example, I've used the hostname as the Guid, which makes constructing this file a little easier and works well enough.

    {
      "Profiles": [
        {
           "Name": "foo.example.com",
           "Guid": "foo.example.com",
           "Custom Command" : "Yes",
           "Command" : "ssh foo.example.com",
        },
        {
           "Name": "bar.example.com",
           "Guid": "bar.example.com",
           "Custom Command" : "Yes",
           "Command" : "ssh bar.example.com",
        },
      ]
    }
    


    Profile Search Syntax

    When iTerm2 presents a list of profiles, it usually includes a search box. The search box uses a special syntax that lets you tailor your searches to quickly find what you're looking for.

    Searching Profiles

    Each word in the search query must match at least one word in either the title or the tags of a profile in order for that profile to be matched by the query. For a word to be a match, it must be a substring.

    Query      Profile Name    Matches?
    Linux      Linux    Yes
    x      Linux    Yes
    z      Linux    No
    George L      George's Linux Machine    Yes

    Operators

    You may prefix a phrase in the search query with an operator to narrow your query. These operators are defined:

    • The name: operator only tries to match words in the profile's name.
    • The tag: operator only tries to match words in the profile's tags.
    • The command: operator only tries to match words in the profile's command. Note that the command is only searched for words that explicitly use the command operator. Available in iTerm2 version 3.5.5 and later.

    Quoting

    You can require that two or more words occur in order by putting quotes in your query. For example:

    Query      Profile Name Matches?
    "Linux machine"      George's Linux machine Yes
    "machine Linux"      Linux machine No

    Anchoring

    Normally, words in a query must match a substring of a word in the title or tags of a profile. You can require that a word in your query matches a prefix of a word in the title or tags by inserting a caret (^) before the word. You can require that a word in your query matches the suffix of a word in the title or tags by appending a dollar sign ($) after the word. For example, the query ^a matches only profiles with words starting with "a". The query a$ matches words ending in "a". The query ^a$ matches only the word "a".

    Query      Profile Name Matches?
    ^root      [email protected] Yes
    ^root      Groot! No
    root$      Groot Yes
    ^root$      Groot No
    ^root$      root Yes

    Combining Features

    You may combine quoting, operators, and anchors. The operator always comes first, followed by a caret, followed by a quoted string, followed by a dollar sign. Consider the following examples:

    name:^"George's Linux Machine"$

    Three consecutive whole words in the profile's name must equal "George's Linux Machine".

    name:"George's Linux Machine"$

    Would match a profile named "XGeorge's Linux Machine", unlike the previous example.

    name:^"George's Linux Machine"

    Would match a profile named "George's Linux MachineX", unlike the first example.

    name:"George's Linux Machine"

    Would match a profile named "XGeorge's Linux MachineX", unlike the first example.

    name:^George's
    name:George's$
    name:^George's$
    

    A word having the prefix, suffix, or exactly matching "George's" must occur in the profile's name to match these queries, respectively.


    Automatic Profile Switching

    iTerm2 can use information it knows about your current path, host name, user name, and foreground job name to change profiles. For example, your window's background color or the terminal's character encoding could change when connecting to different hosts.

    Shell Integration Required

    You must install Shell Integration on all machines and all user accounts where you plan to use Automatic Profile Switching (either by using the scripts or the Triggers workaround described in the Shell Integration docs).

    Rule Syntax

    In Settings>Profiles>Advanced, you may specify a set of rules.

    When any session satisfies a rule in a given profile, it will switch to that profile. Rules consist of three optional components: the user name, the hostname, and the path. At least one component must be present, since an empty rule is not allowed. The hostname is required only when both a user name and a path are specified.

    A user name is a unix accont name (e.g., root) followed by an @.

    A path always begins with a /. Any time a hostname is followed by a path, they are separated by a :. For example, iterm2.com:/users/george. It may include * wildcards.

    A hostname can be a DNS name, like iterm2.com or an IP address like 127.0.0.1. A hostname may contain one or more * characters, which act as a wildcard (like globbing in Unix).

    The job name is the name of the executable. For example, "vim" or "bash". It must be prefixed with an ampersand &. For example, &emacs*. Starting with version 3.6, the rule is matched against the full command line rather than only the job name.

    Additionally, a rule may be designated as sticky by beginning with a !. This will be described below, in the Automatic Reversion section.

    Some examples:

    • [email protected]:/users/george
    • george@*:/users/george
    • *:/users/george
    • *.iterm2.com:/users/george
    • dev.*.com:/users/george
    • [email protected]
    • iterm2.com
    • george@
    • iterm2.com:/users/george
    • /users/george
    • /users/*
    • &vim
    • iterm2.com&vim
    • !iterm2.com

    Because more than one rule may match at any given time, rules with higher quality matches prevail over those with lower-quality matches. Quality is determined by a rule's score, which is computed by summing the scores for its matching parts. In order for a rule to be considered, all of its parts that are specified must match the current state.

    The scoring is defined as:

    • An exact match for the hostname scores 16 points.
    • A partial match for the hostname using a wildcard scores 8 points.
    • A match on the job name (wildcard or not) scores 4 points.
    • A match on the user name scores 2 points.
    • An exact match on the path scores one point.
    • A partial match on the path using a wildcard scores zero points, but does count as a match for the rule.

    The highest scoring rule, if any, will be used and the session's profile will be switched.

    The UI tries to prevent you from entering the same rule in two different profiles, but if that does happen then one profile is chosen arbitrarily.

    Automatic Reversion

    After APS switches a session's profile, its rules may eventually cease to match (for example, the hostname changes back to "localhost" because an ssh session ends). If no profile has a matching rule, the session's original profile will be restored. The exception is if the last-matched rule was "sticky". A sticky rule is prefixed with an !.

    Implementation

    Each session maintains a stack of profiles. Initially, the stack contains the profile the session was created with. When the username, hostname, or path changes, iTerm2 finds the best-matching profile. If some profile has a matching rule, one of two things happens:

    • If that profile is already on the stack, profiles above that one will be removed from the stack and the session will switch to that profile.
    • Failing that, the profile will be pushed on the stack and the session will switch to that profile.

    If no profile has a matching rule, the stack is emptied (except for the first entry, the original profile for the session) and the session reverts to its original profile.

    Rules may begin with ! to indicate "stickiness". A sticky rule causes its profile to stay even after the rule no longer applies, so long as no other rule matches.

    Triggers

    Since it's impractical to install shell integration everywhere (for example, as root), there will be times when you need to write a trigger to detect the current username or hostname. Please see the Triggers section of Shell Integration for details.

    Troubleshooting

    There are a few ways things can go wrong. Please see the Why doesn't secure copy/automatic profile switching work? document for help diagnosing and fixing these issues.


    Coprocesses

    iTerm2 offers support for "coprocesses". This very powerful feature will allow you to interact with your terminal session in a new way.

    What is a Coprocess?

    A coprocess is a job, such as a shell script, that has a special relationship with a particular iTerm2 session. All output in a terminal window (that is, what you see on the screen) is also input to the coprocess. All output from the coprocess acts like text that the user is typing at the keyboard.

    One obvious use of this feature is to automate interaction. For instance, suppose you want to automate your presence in a chat room. The following script could be used as a coprocess:

    #!/usr/bin/python
    import sys
    while True:
      line = raw_input()
      if line.strip() == "Are you there?":
        print "Yes"
      sys.stdout.flush()
    

    You could disappear for years before your friends discover you're gone.

    How Do I Start a Coprocess?

    There are two ways to start a coprocess.

    1. Select "Run Coprocess..." from the Session menu. Enter the name of a command to run as a coprocess.

    2. Create a Trigger in Prefs>Profiles>Advanced and select Run Coprocess... as the action. Give the script to run as a parameter. Triggers also have Silent Coprocesses, which prevent any output from going to the screen. This is useful for ZModem, for example.

    Usage

    A session can not have more than one coprocess at a time. When a coprocess is active, an icon will indicate that in the top right of the session.

    Technical Details

    The coprocess's stdin is a byte-for-byte copy of the input from the session's pty, beginning at the time the coprocess starts. In the case of a trigger-started coprocess, the line of input that triggered it MAY be the first line of input to the coprocess, but this is not guaranteed. If a coprocess is running, triggers with a Run Coprocess action will not fire. The coprocess's stdout stream will be treated the same as keyboard input. A small amount of buffering is provided for both input and output of the coprocess. When a buffer fills, the coprocess will block.


    Session Restoration

    Session restoration works by running your jobs within long-lived servers rather than as child processes of iTerm2. If iTerm2 crashes or upgrades, the servers keep going. When iTerm2 restarts, it searches for running servers and connects to them. The OS's window restoration feature preserves the content of your window, including scrollback history. iTerm2 marries the restored session to the appropriate server so you can pick up where you were.

    tl;dr watch this: Demo Video

    Notes

    • You must turn off System Settings > Desktop & Dock > Close windows when quitting an application. For more information on system window restoration, please see Apple's docs.

    • You must set Settings > General > Startup > Window restoration policy to Use System Window Restoration Setting.

    • Force quitting iTerm2, causing it to crash, or upgrading it when prompted should restore your sessions. NOTE: Quitting iTerm2 with Cmd-Q will terminate your jobs and they won't be restored. There is an advanced preference to change this behavior, though.

    • You can toggle this feature with Settings > Advanced > Enable session restoration, but you must restart iTerm2 after changing this setting.

    • A session that has had only its window contents restored and not the running processes will get a reverse video Session Restored banner. A properly restored session will pick up right where you left it.

    • If you reboot, your jobs will terminate and not be restored. The window contents should be restored.

    If you prefer for sessions not to be terminated when you quit iTerm2, turn off Settings > Advanced > User-initiated Quit (⌘Q) of iTerm2 will kill all running jobs.

    What Is Restored

    Restored windows keep their tabs, tab groups, split panes, and floating panes, along with settings such as Window > Lock Location.

    Undo Close After Restarting

    If a profile archives sessions when they close (Settings > Profiles > Session > Archive sessions on closure), Shell > Undo Close can bring back the 20 most recently closed of those sessions even after you restart iTerm2. They come back from their archives in their original split panes, tabs, and windows, with their contents but not their running jobs.


    Session Archives

    A session archive is a saved copy of a session's scrollback that you can restore later. It captures the session's contents so you can set aside a terminal's history and reopen it whenever you need it.

    Saving and Restoring Archives

    The archive commands live under Shell > Archives.

    Choose Save Archive of Current Session… to write the current session's scrollback to a file. Choose Restore Archive… to pick a saved archive and reopen it. iTerm2 remembers your ten most recent archives and lists them in the Archives submenu, so you can restore a recent one without hunting for the file.

    Restoring an archive reopens the session's scrollback in a new window.

    Archiving Sessions Automatically

    You can have iTerm2 archive a session for you when it closes. In Settings > Profiles > Session, turn on Archive sessions on closure and choose a destination directory. When a session using that profile closes, iTerm2 automatically writes an archive of its scrollback to that directory. See Profiles > Session for the related settings.

    Undo Close and Archives

    Normally Shell > Undo Close can revive a closed session only until the time limit set in Settings > Profiles > Session > “Undo” can revive a closed session for up to this many seconds runs out. If the session’s profile has Archive sessions on closure turned on, Undo Close keeps working after that: the session’s job has ended, but its contents come back from its archive in its original split pane, tab, and window. The 20 most recent of these can be undone even after you restart iTerm2.


    Session Notes

    A Session Note is a floating, resizable panel of freeform text attached to a session. Use it to jot down anything you want to keep alongside the terminal, such as a reminder, a snippet of output, or a running to-do list. The note floats above the terminal content and stays with the session.

    Showing a Session Note

    Select View > Show Session Note (⌥⌘G) to show the note for the current session and put the keyboard focus in it. If the note is collapsed, this expands it first. The menu item shows a checkmark while the note is visible; selecting it again hides the note.

    Each session has its own single note. A new note starts near the top-right corner of the session, out of the way of the prompt.

    Editing

    The note holds plain, multiline text. It has its own undo stack, and it uses the session's font, so it tracks changes to the font. Pasted content is inserted as plain text, and automatic substitutions such as smart quotes, dash replacement, and link detection are turned off so the text stays exactly as you type it. When the content is taller than the note, a scroller appears. Return and Shift-Return both insert a newline.

    A note with no text is not kept: if you leave an empty note, iTerm2 removes it.

    Moving, Resizing, and Collapsing

    Drag the title bar to move the note anywhere within the session. Drag any edge or corner to resize it. The note is constrained to stay inside the session's bounds.

    Click the chevron button in the title bar to collapse the note down to just its title bar, or press Escape while editing, which also returns the keyboard focus to the terminal. When collapsed, the title bar shows the first line of the note instead of the label "Session Note," and you can still drag it and resize it horizontally. Click the chevron again to expand it.

    When the Session Resizes

    The note keeps its distance from the top-right corner of the session rather than the bottom-left. When you resize the window or split pane, the note moves along with that corner so it stays in the same relative spot near the top-right. If the session becomes smaller than the note, the note is clamped to fit.

    Persistence

    A note that has text is saved with the session, so it survives restarts and is stored in saved arrangements. Its text, size and position, and collapsed state are all preserved. An empty note is not saved.


    Session Status

    A session can report a status: a short bit of state that iTerm2 surfaces on the session's tab as a custom subtitle, a colored dot indicator, and a subtitle color. Status lets you see at a glance which of your sessions is working, which is waiting for you, which finished while you were away, and which is idle, without switching to each one.

    Status is most useful when you run many long-lived sessions at once, such as several coding agents. The Claude Code integration uses Session Status to show, tab by tab, whether Claude is thinking, waiting for your input, or done, and the same mechanism can follow Codex CLI. Any program can report its own status with the Program Status Protocol.

    Statuses

    A status is free-form text, but iTerm2 and the programs that integrate with it use a common vocabulary. The Claude Code integration, Codex CLI hooks, and the Program Status Protocol all write these statuses with these colors:

    StatusColorMeaning
    waitingBlueThe program is blocked until you do something, such as approve an action or answer a question.
    doneGreenThe program finished its work and you haven't looked at the result yet.
    errorRedThe program's work failed and you haven't looked at the result yet.
    workingOrangeThe program is busy.
    backgroundPurpleThe program's turn is over and it will take input, but agents or commands it started are still running in the background.
    idleGreen dot, gray textNothing needs you.

    “done” and “error” mean a result is waiting for you. Pressing a key in the session marks it as seen: a status of exactly “done” or “error” (in any case) becomes “idle”, keeping its detail text. This applies no matter how the status was set.

    The current status text is also available in the session's status variable, so you can show it in a badge, a title, or a status bar component. The global variables iterm2.workingSessionCount and iterm2.waitingSessionCount count the sessions that are working (or in the background) and waiting.

    Setting a Session's Status

    There are several ways to set a session's status. They all write the same status, so whichever wrote last is what the tab shows.

    Program Status Protocol (OSC 7501)

    A program can report what it is doing with the OSC 7501 control sequence. Instead of choosing text and colors itself, the program reports a state (idle, working, blocked, done, or error), optionally with a message and a progress percentage, and iTerm2 decides how to show it. For example:

    printf '\e]7501;state=working:progress=40\a'
    

    iTerm2 maps the states to the statuses above (blocked is shown as “waiting”) and draws the progress on the tab's progress indicator. A program that is blocked can say why with kind=permission, kind=question, or kind=auth, which iTerm2 shows as “Waiting for approval”, “Waiting for an answer”, or “Waiting for login” when there is no message.

    A program can also report on several tasks at once by giving each report an id. iTerm2 keeps one record per id, and the tab shows the most urgent one: blocked first, then error, done, working, and idle, with the most recent report winning a tie. When a session has more than one record, the Session Status tool lists them under the session's row, and each task that changes to a status you've asked to be notified about posts its own notification.

    A report can also carry app=, the program's name, which labels the program's row in the Session Status tool, and title=, a base64-encoded name for a task, which labels that task's row and is shown before its message in the detail text.

    Records for a program that is working, blocked, or idle go away when the program exits or a new shell prompt begins. Done and error records stay until you press a key in the session, which turns them idle. A program can remove records itself with state=clear: with an id it removes that task and the tasks beneath it, and without one it removes them all.

    See Proprietary Escape Codes for the full syntax.

    OSC 21337

    A program running in a session can also set the status text and colors directly with the OSC 21337 control sequence. The payload is a list of key=value pairs separated by semicolons:

    OSC 21337 ; status=[text] ; indicator=[color] ; status-color=[color] ; detail=[text] ST
    

    The keys are:

    • status: the subtitle text (for example, working or waiting).
    • indicator: the color of the dot shown on the tab.
    • status-color: the color of the subtitle text.
    • detail: optional extra text shown alongside the status in the Session Status tool and the Cockpit.
    • expires-on: makes the status end by itself. The only value is progress-end; see below.
    • then-status, then-indicator, then-status-color, and then-detail: what to show when a status with expires-on ends.

    Colors use xterm's format: either #RRGGBB or rgb:RR/GG/BB. Set any key to an empty value to clear it, and unknown keys are ignored. To include a literal semicolon or backslash in a value, escape it as \; or \\. For example, to mark a session as working with an orange dot:

    printf '\e]21337;status=working;indicator=#ff9500\a'
    

    And to clear everything:

    printf '\e]21337;status=;indicator=;status-color=\a'
    

    A status can say when it stops being true, so it doesn't outlive a program that was stopped partway through. With expires-on=progress-end, the status ends about three seconds after a progress indicator (OSC 9;4) that was running in the session stops, unless the program sets a new status first. It is then replaced by the then- fields, or cleared if there are none. For example:

    printf '\e]21337;status=working;indicator=#ff9500;expires-on=progress-end;then-status=idle\a'
    

    See Proprietary Escape Codes for the conventions used above.

    The it2 Command Line

    The it2 command-line tool sets the status of a session from a script:

    it2 session set-status --status working --dot-color '#ff9500'
    

    Pass --session to choose which session it acts on; without it, it acts on a default session as described in the it2 documentation. The main options are --status (the status text), --dot-color and --text-color (each a #rrggbb value), and --detail (optional detail text). Pass an empty value to clear a field. it2 session get-status prints a session's status. See Session Status in the it2 documentation for the rest of the options, including those for expiring a status and drawing a progress indicator.

    The Set Tab Status Trigger

    A trigger can set the status when a session's output matches a regular expression. Add a Set Tab Status trigger in Settings > Profiles > Advanced > Triggers. It gives you a combo box for the status text (with Working, Waiting, and Idle as suggestions) plus two color wells, one for the dot color and one for the subtitle text color. This is handy for programs that don't set status themselves: match their output and label the tab automatically.

    Claude Code and Codex CLI

    With the Claude Code integration installed, Claude Code's hooks report its status: “working” during a turn, “waiting” when it needs permission or an answer, “done” when a turn finishes (with Claude's last message as the detail), “error” when a turn ends with an API error, and “background” when a turn is over while agents or commands it started keep running.

    Recent versions of Claude Code also report their own status through the Program Status Protocol. When they do, the tab follows those reports, and the integration's hooks fill in what the reports leave out: the “background” status and Claude's last message when a turn is done. Claude Code doesn't report through the protocol inside tmux, so there the hooks drive the status by themselves. Claude Code sessions in tmux integration panes on this Mac are listed in the Session Status tool like any other session.

    Codex CLI runs the same kind of hooks. Point them at it2 handle-agent-hook --agent codex and the tab shows Codex's status, including “done”, “error”, and “background”, with a progress indicator through each turn. Codex has no installer yet; see the Claude Code integration page for setup.

    The Session Status Tool

    The Session Status tool shows the status of every session in a window in one place. Add it with View > Toolbelt > Session Status (open the toolbelt first with View > Toggle Toolbelt if it isn't showing). Each row lists a session's name, its colored dot, its status text, and a keyboard shortcut that jumps to that session. Click a row to reveal the session it names.

    Rows are sorted by priority, so the sessions that need attention rise to the top. The default order is waiting, done, error, working, background, then idle.

    A session whose program reports on several tasks through the Program Status Protocol lists up to four of them, most urgent first, beneath its row. If there are more, a final row shows how many more there are; hover over it to see them.

    The tool's gear button opens a settings popover with:

    • A priority list of patterns. Each pattern is a case-insensitive substring matched against the status text, and patterns near the top sort higher. Drag to reorder, click a pattern to edit it, and use the + and - buttons to add and remove patterns. Turn on Notify for a pattern to post a notification whenever a session's status changes to one that matches it.
    • Merge workgroup statuses: collapse every session in a Workgroup to a single representative row.
    • Show status on tabs: turn this off to hide the status on tabs entirely, both the colored dot and the status text. The Session Status tool and the Cockpit still show it.

    If you customized the priority list in an earlier version, iTerm2 adds the newer statuses to it where the defaults have them: “done” and “error” just below “waiting” (notifying if your “idle” pattern did), and “background” just below “working”.

    To snooze a session, select its row and click the snooze button (the moon icon next to the bell), or right-click the row and choose Snooze. A snoozed session moves below a divider at the bottom of the list and is dimmed. It automatically un-snoozes the next time its status changes, so you can quiet a session you're done with and still be shown when something new happens. Click the snooze button again to un-snooze the selected session.

    The bell button at the bottom of the tool arms notify-on-status-change. With a row selected it watches that session; with nothing selected it watches the whole window. The next time the target's status changes, iTerm2 shows an alert and disarms the bell. Pressing a key to mark a “done” or “error” result as seen doesn't count as a change.

    Notify on Status Change

    Window > Notify on Status Change arms an alert for the current window. The next time any session in the window changes its status, iTerm2 shows a notification. The alert has a Reveal button that jumps straight to the session that changed. This is the menu-driven equivalent of the Session Status tool's bell, and the two stay in sync.

    The Cockpit

    The Cockpit is a floating panel that shows session status across every window at once, not just the front one. Open it with Window > Cockpit (⌥⇧⌘C). It floats above your terminal windows while iTerm2 is active and gets out of the way when you switch to another app.

    The Cockpit organizes its list three ways, selectable from the toolbar:

    • Status: grouped by window, then by status.
    • Window: grouped by window, then by tab and split pane.
    • Workgroup: only sessions that belong to a Workgroup, grouped by Workgroup.

    Every grouping shows each session's live status and detail line. A filter bar along the top narrows the list to sessions with one status and shows how many sessions have each. A search field filters the list to sessions whose name matches what you type, keeping the grouping you chose. Click any row to jump to that session, tab, window, or Workgroup. The bell in the toolbar arms notify-on-status-change for the selected row, per window or per session, and armed rows show a bell so you can see at a glance what you're watching.

    A composer docked along the bottom of the Cockpit sends a command to many sessions at once. Type @ to pick a session, tab, or window (selecting rows in the list does the same), then type the command and press Shift-Return to send it to every chosen session.


    Tab Groups

    Tab groups let you organize the tabs in a window the way Chrome and Firefox do. A named, colored chip heads each group, and its member tabs sit next to the chip in the tab bar. Use groups to keep related tabs together, tell projects apart at a glance, and tuck a set of tabs out of the way without closing them.

    Creating a Group

    Right-click a tab and choose Add Tab to Group > New Group…, or choose Window > Tab > Add Tab to New Group…. iTerm2 asks for a name (it suggests the tab's current title) and gives the new group a color that no other group in the window is using. The tab moves next to its new chip.

    To add another tab to a group that already exists, right-click that tab and choose Add Tab to Group and then the group's name from the submenu. A checkmark marks the group the tab already belongs to. To take a tab back out, right-click it and choose Remove Tab from Group (also in Window > Tab). Removing a tab from a sub-group moves it into the sub-group’s parent group.

    The members of a group always stay contiguous in the tab bar, so adding a tab from elsewhere moves it next to the rest of the group.

    Managing a Group

    Right-click a group's chip to act on the whole group:

    • New Tab in Group opens a new tab in the group.
    • Collapse Group or Expand Group hides or shows the group’s tabs.
    • Rename Group… changes its name.
    • The color swatches just below Rename recolor the group; pick a preset or open the full color picker.
    • Duplicate Group makes a copy of the group and its tabs.
    • Move Group to New Window tears the whole group off into its own window.
    • Move Group Into makes the group a sub-group of another group, and Move Group Out of Parent Group makes a sub-group a top-level group again. See Nested Groups below.
    • Save Group as Window Arrangement… saves the group’s tabs as a window arrangement.
    • Remove All Tabs from Group ungroups the tabs, leaving them in place without a chip.
    • Close Group closes every tab in the group.
    • Close Other Tabs closes the tabs that are not in the group.
    • Close Tabs to the Right closes the tabs after the group. When the tab bar is on the left or right side of the window, this is Close Tabs Below instead.

    You can rearrange groups by dragging. Drag a chip to move the entire group within its window or into another window. Drag a single tab to move it around inside its group, into a different group, or out of a group entirely. You can drag a tab into a collapsed group, too: while you drag over it, the group's chip highlights to show the tab will drop inside it. The group stays collapsed unless the tab you dragged is the active tab, in which case it expands. A tab dragged out of the tab bar into empty space becomes an ungrouped tab in a new window.

    Window > Tab > Move Tab > Move Tab Left and Move Tab Right move just the current tab, not its whole group. Moving a tab past the edge of its group takes it out of the group, and moving an ungrouped tab into a neighboring group adds it to that group. Window > Tab > Select Tab > Select Next Tab Group and Select Previous Tab Group jump from group to group.

    Nested Groups

    A group can contain sub-groups, one level deep: a sub-group can't have sub-groups of its own. A sub-group’s chip and tabs sit inside its parent’s tabs in the tab bar.

    To make a sub-group:

    • Right-click a tab in a top-level group and choose Move Tab to New Sub-group… (also in Window > Tab). iTerm2 asks for a name and creates a new group inside the tab’s group, containing the tab.
    • Drag a group by its chip into an expanded top-level group.
    • Right-click a group’s chip and choose a group from Move Group Into.

    A group that has sub-groups of its own can't be nested in another group. To make a sub-group top-level again, right-click its chip and choose Move Group Out of Parent Group, or drag it out of its parent. A sub-group that is moved to another window also becomes top-level.

    Collapsing a Group

    Click a group's chip (or choose Collapse Group from its menu) to hide the group's tabs behind the chip. The chip then shows how many tabs it holds. Click the chip again, or choose Expand Group, to bring the tabs back. Collapsing and expanding are animated.

    Each level of nesting collapses on its own. Collapsing a parent group hides its sub-groups too, and collapsing a sub-group leaves its collapsed chip showing inside its expanded parent.

    Selecting a tab that lives in a collapsed group automatically expands the group, so the active tab is never hidden. For the same reason, a group cannot collapse when it is the only group of tabs in the window.

    Collapsing works on both horizontal and vertical tab bars and in every theme.

    Persistence

    A group carries its name, color, and nesting with its member tabs, so the grouping survives everything that saves and restores windows, including window arrangements and restart. A group's collapsed or expanded state persists across restarts as well.

    Tab groups of tmux integration tabs are remembered by the tmux session, so they come back with their names and colors when you detach and reattach.


    Utilities

    iTerm2 has a collection of shell scripts that help you take advantage of some of its unique features. When you install Shell Integration from the iTerm2 > Install Shell Integration menu, you're asked if you'd like to install the Utilities Package as well. This page describes these utilities.

    If you prefer to install only the utilities (without also installing Shell Integration) you can find them here. Most of the utilities work without Shell Integration.

    Components

    The Utilities Package contains the following programs:

    imgcat

    The imgcat program displays images inline in your terminal.

    It supports all standard image formats, including animated GIFs.

    Usage:
    imgcat filename [filename...]
    
    or
    
    cat image | imgcat
    

    imgls

    Lists the files in a directory with thumbnail previews for images.

    Usage:
    imgls [filename...]
    

    it2

    it2 is a command-line tool that lets you drive iTerm2 from the shell. iTerm2 adds the folder holding its bundled utilities, including it2, to the end of PATH in new local sessions, so it is available without any extra setup. (The advanced setting Add path to iTerm2 utilities to $PATH for new sessions? controls this and is on by default.) On a host reached through SSH Integration, iTerm2 installs it as described in Using it2 over SSH Integration below.

    With it2 you can create windows, tabs, and split panes, send text to sessions, run commands, manage profiles, set a session's status, add Clippings, send a notification to your phone, monitor iTerm2 for events, and more.

    Usage:
    it2 subcommand [options]
    

    The available subcommands are:

    alias              Execute an alias from config file.
    app                Control iTerm2 application.
    auth               Manage authentication with iTerm2.
    clear              Shortcut for 'it2 session clear'.
    config-path        Show configuration file path.
    config-reload      Reload configuration file.
    handle-agent-hook  Report an AI coding agent’s hook event as the session status.
    load               Load a custom profile from config file.
    ls                 Shortcut for 'it2 session list'.
    monitor            Monitor iTerm2 events.
    new                Shortcut for 'it2 window new'.
    newtab             Shortcut for 'it2 tab new'.
    notify             Send a push notification to the paired companion device.
    profile            Manage iTerm2 profiles.
    run                Shortcut for 'it2 session run'.
    send               Shortcut for 'it2 session send'.
    session            Manage iTerm2 sessions.
    set-status         Shortcut for 'it2 session set-status'.
    split              Shortcut for 'it2 session split'.
    tab                Manage iTerm2 tabs.
    vsplit             Shortcut for 'it2 session split --vertical'.
    window             Manage iTerm2 windows.
    

    The session subcommand has these subcommands of its own:

    add-clipping          Add a clipping to a session (e.g., a code review comment).
    archive-clippings     Archive a session's clippings, clearing the live list and adding a history entry.
    capture               Capture screen to file.
    clear                 Clear screen.
    close                 Close session.
    copy                  Copy selection to clipboard.
    delete-clipping       Delete a session’s clipping by the ID add-clipping printed.
    focus                 Focus a specific session.
    get-background-tasks  Print the background-task count last stored via set-status --background-tasks.
    get-status            Print a session’s status indicator as JSON.
    get-var               Get session variable value.
    list                  List all sessions.
    read                  Display screen contents.
    restart               Restart session.
    run                   Execute command in session with newline.
    send                  Send text to session without newline.
    set-color             Set session tab color.
    set-name              Set session name.
    set-status            Set session status indicator.
    set-var               Set session variable value.
    split                 Split current session.
    

    Run it2 --help, or it2 help subcommand, for details on any of these. The rest of this section describes the parts that need more explanation than --help gives.

    Choosing a Session

    Most commands that act on a session take --session (or -s) with a session's unique ID. The value of $ITERM_SESSION_ID (such as w0t1p0: followed by the ID) is accepted too. A few take session IDs as positional arguments instead: session focus takes the ID of the session to focus (the bare unique ID, without the w0t1p0: prefix), and app broadcast add takes a list of them. monitor activity takes no session; it watches the current session, or every session with --all. When you leave out --session, which session is used depends on the command:

    • send, run, split, clear, close, and profile apply act on the active session: the current session of the frontmost window.
    • The other session commands (such as read, capture, copy, set-name, set-color, restart, get-var, set-var, get-status, set-status, get-background-tasks, and the Clipping commands) and the monitor commands act on the session it2 is running in. Inside tmux, that is the session showing its tmux pane, found from $TMUX and $TMUX_PANE. Elsewhere on this Mac, it's the session named by $TERM_SESSION_ID. On a host reached through SSH Integration, it's the session the command arrived over. When it2 isn't running in a session it can identify (for example, from cron or another terminal app), these commands fall back to the active session.

    Targeting a tmux Pane

    A program running in a tmux pane can't learn its iTerm2 session ID, because the tmux server, not iTerm2, starts it. Instead it can name its pane. These commands take --tmux and --tmux-pane: session get-var, set-var, get-status, set-status (and the top-level set-status shortcut), get-background-tasks, add-clipping, archive-clippings, and delete-clipping. Pass the values of $TMUX and $TMUX_PANE from inside the pane, and it2 acts on the iTerm2 session showing that pane through tmux Integration:

    it2 session set-status --tmux "$TMUX" --tmux-pane "$TMUX_PANE" --status working
    

    Both options must be given together, and they must be well-formed even when --session is also given (an explicit --session takes precedence). This works on a host reached through SSH Integration, too: there it finds a pane of a tmux -CC running over that same connection. It does not work for a pane of a plain tmux session (one not using tmux Integration), since iTerm2 can't tell which tab, if any, is showing it. If no session is showing the pane, the command fails; add --quiet-if-unresolved to have it exit successfully without a message instead, which suits a program that runs on every event.

    For these commands, an empty --session, --tmux, or --tmux-pane counts as not given. A script can always pass all three, with empty values for the ones it doesn't have, and let it2 pick.

    Session Status

    it2 session set-status (or the shortcut it2 set-status) sets a session's status. With no --session it acts on the session it runs in, as described above. Its options are:

    • --status: the status text, such as waiting, done, error, working, or idle.
    • --dot-color and --text-color: the dot indicator color and the status text color, as #rrggbb.
    • --detail: optional detail text shown alongside the status.
    • --background-tasks: the number of background tasks still running. --background-tasks-delta adds to the count instead (clamped at zero), reading and writing it in one step so two callers can't lose an update. It can't be combined with --background-tasks.
    • --turn-open (true or false): records whether the program reporting status is in the middle of a turn.
    • --if-turn-open and --if-background-tasks: apply the update only if the turn flag or the background task count currently has this value.
    • --progress (running or stopped): starts or stops the tab's progress indicator, for a program that reports through hooks but doesn't emit the progress escape sequence (OSC 9;4) itself.
    • --json: instead of the usual message, prints the status as it stood after the update, in the form get-status prints.

    An empty value clears a field. A status can also say when it stops being true, so it doesn't outlive a program that was stopped partway through. --expires-on progress-end makes the status expire when the session reports through the progress protocol (OSC 9;4) that the operation running when the status was set has ended (by stopping or failing). iTerm2 waits a few seconds after the operation ends, so a status the program sets itself at that moment wins, and it waits until the background task count is zero. When the status expires, it is replaced by the values you give with --then-status, --then-dot-color, --then-text-color, and --then-detail. Without them, the status is cleared.

    it2 session get-status prints a session's status as JSON with the keys status, text_color, dot_color, detail, background_tasks, and turn_open. An unset field is null; turn_open stays null until set-status --turn-open has been used for the session.

    Listing Sessions

    it2 session list prints one line per session with its ID, name, title, size, and tty, or a JSON array with --json. With --format, it evaluates an interpolated string in each session, as a badge does, and prints the result instead of the usual columns. This prints every session's directory or job in one command:

    it2 session list --format '\(session.id)\t\(session.path)\t\(session.jobName)'
    

    An undefined variable becomes an empty string. With --json, the result is added to each session as formatted. (The it2 ls shortcut doesn't take --format.)

    Clippings

    it2 session add-clipping type title detail adds a Clipping to a session and prints the new Clipping's unique ID. it2 session delete-clipping id removes a Clipping by that ID; only live Clippings can be deleted, not archived ones. it2 session archive-clippings archives the session's Clippings, clearing the live list and adding a history entry.

    Notifications

    it2 notify title body sends a push notification to the companion device paired with iTerm2 (iTerm2 Buddy). Keep the title to a few words and the body to a sentence or two.

    AI Agent Hooks

    it2 handle-agent-hook is the hook command for Claude Code and Codex CLI. It reads a hook event's JSON payload from standard input and turns it into a session status for the session the agent is running in. It's meant to be named as the hook command in the agent's hook configuration: the Claude Code integration installer does that for you. For Codex, pass --agent codex; the default is --agent claude.

    Using it2 over SSH Integration

    When you run it2 on a host you reached through iTerm2's SSH Integration, its requests are routed back to your local iTerm2 and run there. iTerm2 uploads it to ~/.iterm2/bin/it2 (with the Python script it runs in ~/.iterm2) and puts ~/.iterm2/bin on the PATH of the shell or command it starts, so it's a real command: scripts, sh -c, and tools such as Claude Code's Bash tool can run it, not just an interactive shell. This also holds for a command you give to it2ssh (as in it2ssh host command) or that an SSH profile runs. Commands that read standard input receive it. The remote it2 needs python3 on the host.

    The upload happens when shell integration is set to load (see it2ssh), whatever the remote shell, tcsh included. When shell integration isn't loaded, iTerm2 copies nothing to the host, but an it2 already installed there (for example, by an earlier connection that loaded shell integration) still works.

    Remote control is gated by permission. The first time a remote it2 command tries to control iTerm2, an announcement asks whether to allow it, with the choices Allow (for this session), Always Allow This Host (so it isn't asked again on later connections), and Deny. Review or remove the always-allowed hosts with Settings > General > Magic > Manage Permissions…, on the API Access over SSH tab. The Shell > SSH > Remote host can control iTerm2 menu item toggles the permission for the current connection and shows a checkmark while it is granted. it2 auth can't be run over SSH Integration, since it would hand the host a reusable credential.

    it2api

    An older command-line tool built on the Python API. Most of what it does is now easier with it2, which doesn't need Python; it2api remains for scripts that use it. It needs Python 3 with the iterm2 module installed (python3 -m pip install iterm2) and Settings > General > Magic > Enable Python API turned on. Run it2api -h for the full list of subcommands and it2api subcommand -h for each one's arguments.

    Usage:
    it2api subcommand [arguments]
    
    Some subcommands:
      list-sessions          List sessions
      show-hierarchy         Show all windows, tabs, and sessions
      send-text              Send text as though the user had typed it
      create-tab             Create a new tab or window
      split-pane             Split a pane into two
      get-buffer             Get screen contents
      get-prompt             Get info about prompt, if available
      get-profile-property   Get a session's profile settings
      set-profile-property   Set a session's profile setting
      inject                 Inject a string as though it were program output
      set-variable           Set a user-defined variable in a session
      get-variable           Get a variable in a session
      saved-arrangement      Saves and restores window arrangements
      list-tmux-connections  List tmux integration connections
      send-tmux-command      Send a tmux command to a tmux integration connection
      monitor-variable       Monitor changes to a variable
      monitor-screen         Monitor screen contents
    

    it2attention

    Requests attention. Can bounce the dock icon or show a fireworks animation at the cursor position.

    Usage:
    it2attention start
      Begin bouncing the dock icon if another app is active
    it2attention stop
      Stop bouncing the dock icon if another app is active
    it2attention fireworks
      Show an explosion animation at the cursor
    

    it2cat

    Displays a text file with iTerm2's native rendering, such as formatted Markdown or syntax-highlighted code, instead of printing it raw. It sends the file with the same inline-file escape sequence imgcat uses, so it works over ssh. The file type is usually inferred from the file name or contents; -t gives a hint when there's no file name, as when reading from a pipe.

    Usage: it2cat [-w] [-t file-type] [-u] [-f] filename ...
           cat filename | it2cat [-w] [-t file-type]
    
    Options:
        -h, --help              Display help message
        -u, --url               Interpret following filename arguments as remote URLs
        -f, --file              Interpret following filename arguments as regular Files
        -t, --type file-type    Provides a type hint
        -w, --wide              Render in wide mode with a horizontal scrollbar
    
    The file type can be a mime type like text/markdown, a language name like Java,
    or a file extension like .c
    
    Examples:
        it2cat file.txt
        it2cat -u http://example.com/path/to/file.txt -f otherfile.txt
        it2cat -w -t application/json config.json
    

    -u fetches each URL with curl on the machine where it2cat runs.

    it2check

    Checks if the terminal emulator is iTerm2.

    Example:
    
    it2check && echo This is iTerm2 || echo This is not iTerm2
    

    it2copy

    Copies text to the pasteboard. Works over ssh. Accepts either standard input or a named file.

    Examples:
    
    cat file.txt | it2copy
    it2copy file.txt
    

    For this to work you must enable Settings > General > Selection > Applications in terminal may access clipboard.

    it2dl

    The it2dl program downloads files. This is useful when you are ssh'ed to a remote host.

    Usage:
    it2dl filename
    

    In iTerm2 3.7 and later, a terminal-initiated download asks whether to save the file to your Downloads folder or to choose a destination with a save panel. This prompt is silenceable: you can make it always save to Downloads or always show a save panel.

    it2getvar

    Fetches a session variable. For a list of session variables, see the Badges page.

    Example:
    
    it2getvar session.name
    

    it2git

    Reports the state of the git repository in the current directory to iTerm2 as user-defined variables (user.gitBranch, user.gitDirty, user.gitPushCount, user.gitPullCount, and others), which the git status component in the status bar uses. iTerm2 finds a local repository's state by itself, and it runs git on a host reached through SSH Integration, so it2git is only needed on a remote host you reach some other way. Call it from your shell's iterm2_print_user_vars function, which Shell Integration calls at each prompt:

    iterm2_print_user_vars() {
      it2git
    }
    

    It counts changes the same way iTerm2 does for a repository on this Mac: every untracked file counts, a conflicted file makes the repository dirty but isn't included in the counts of changed files and lines, and a detached HEAD shows its full commit ID.

    it2profile

    Changes the current session's profile on the fly, or prints its name.

    Usage: it2profile -s profile_name
           it2profile -g
    
    Options:
        -s      Set current iTerm2 session profile to specified profile name
                    empty string refers to profile marked as Default
        -g      Get current iTerm2 session profile name
        -r      Reset to the session initial profile
    

    -r switches back to the profile named by $ITERM_PROFILE, which iTerm2 sets when the session starts. -g reads the session's profileName variable, so it must be run in the terminal itself (it talks to /dev/tty). The it2 command it2 profile apply is related: it applies a profile’s settings to a session.

    it2setcolor

    Configures iTerm2's colors.

    Usage
    
    1) To set a specific color to an RGB value:
      it2setcolor name color [name color...]
    For example:
      it2setcolor fg fff
    
    name is one of:
      fg bg bold link selbg selfg curbg curfg underline tab
      black red green yellow blue magenta cyan white
      br_black br_red br_green br_yellow br_blue br_magenta br_cyan br_white
    
    color is of the format:
      RGB        (three hex digits, like fff)
      RRGGBB     (six hex digits, like f0f0f0)
      cs:RGB     (cs is a color space name)
      cs:RRGGBB  (cs is a color space name)
    
      The color space names accepted in the color are:
        srgb       (sRGB, the default if none is specified)
        rgb        (Apple's old device-independent colorspace)
        p3         (Apple's fancy large-gamut colorspace)
    
    2) To switch to a named color preset:
      it2setcolor preset name
    For example:
      it2setcolor preset 'Light Background'
    
    3) To reset the current tab's color to the system default:
      it2setcolor tab default
    

    it2setkeylabel

    Configures touch bar function key labels.

    Usage:
       it2setkeylabel set Fn Label
         Where n is a value from 1 to 20
       it2setkeylabel set status Label
         Sets the Touch Bar "status" button's label
       it2setkeylabel push [name]
         Saves the current labels with an optional name. Resets labels to their default value, unless name begins with a . character.
       it2setkeylabel pop [name]
         If name is given, all key labels up to and including the one with the matching name are popped.
    

    Recommended usage for customizing an application is to set key labels and then push with a name of a concatenation of the app's name (e.g., “emacs”) and a random number. When the app exits, pop to that same name.

    it2ssh

    Connects to a host with SSH Integration, the same as an SSH profile. It takes the same arguments as ssh, including a command to run on the host after the host name.

    Usage:
    it2ssh [--no-shell-integration] [ssh options] host [command]
    

    By default it2ssh loads Shell Integration on the remote host, whatever the current profile's Load shell integration automatically setting, and uploads it2 there. Pass --no-shell-integration to skip both; it must be the first argument, before any ssh options and the host. (An SSH profile follows its own Load shell integration automatically setting instead.) A command given after the host runs exactly as ssh would run it, and can use it2. it2ssh exits with ssh's exit status.

    it2tip

    Prints an iTerm2 tip, a different one each time it runs, with a link to learn more. It keeps its place in ~/.it2totd (in $XDG_DATA_HOME if that's set) and prints nothing once it has shown every tip. Pass -w to wrap around to the first tip after the last. Running it from your shell's startup file gives you a tip of the day.

    Usage:
    it2tip [-w]
    

    it2ul

    Uploads a file. Works over ssh.

    Usage: it2ul [destination [tar flags]]
      If given, the destination specifies the directory to place downloaded files.
      Further options are passed through to tar. See your system's manpage for tar for details.
    

    If used without arguments, the file goes to the current directory. When you run this, you'll be prompted to select one or more files. Next, iTerm2 creates a tar.gz file containing those files and base-64 encodes them. The it2ul script receives it, decodes it, and untars it with -xzfC. Any arguments you provide go after a lone - argument,

    it2universion

    Sets the unicode version for the current session. The key difference is that unicode 8 and unicode 9 use different width tables for emoji. Most apps aren't updated to use the unicode 9 tables, but Unicode 9 produces nicer results with fewer overlapping characters.

    Usage:
      it2universion set 8
      it2universion set 9
      it2universion push [name]
         Saves the current version with an optional name.
      it2universion pop [name]
         If name is given, all versions up to and including the one with the matching name are popped.
    

    Location

    The Utilities Package places shell scripts in $HOME/.iterm2/ and creates aliases to them at the bottom of $HOME/.iterm2_shell_integration.$SHELL.


    Claude Code Integration

    The Claude Code integration connects Anthropic's Claude Code CLI with iTerm2. Once you set it up, iTerm2 shows each Claude session's state (such as working, waiting, or done) on its tab and in the Session Status tool, and a ready-made Workgroup puts your Claude conversation, a diff viewer, and a code-review session a single click apart.

    The integration is optional, and you can undo it as easily as you install it. It lists everything it changes up front, and iTerm2 > Uninstall Claude Code Integration reverses all of it.

    Requirements

    You need the Claude Code CLI installed and runnable as claude. The integration uses iTerm2's Python API to convey each session's status to iTerm2 and to add Code Review findings to the Workgroup's shared Clippings panel, so the installer offers to turn the Python API on if it is not already on.

    Installing

    Select iTerm2 > Install Claude Code Integration to open the setup window. It opens with a summary of everything it will change, and walks you through the steps one at a time. Each step is optional except enabling the Python API.

    The installer performs the following actions:

    • Enables the Python API.
    • Adds hooks to ~/.claude/settings.json that report status updates to iTerm2.
    • If you opened the installer from a session on a host reached through SSH Integration, adds the same hooks to Claude Code's settings on that host.
    • Shows the toolbelt and enables the Session Status tool.
    • Adds a Claude Code Workgroup to iTerm2's settings.
    • Adds Enter/Exit Workgroup triggers to the profiles you pick.

    Enable Python API

    The integration relies on it to convey Claude's status to iTerm2 and to share Code Review findings through the Clippings panel, so setup can't continue until you enable it. macOS asks you to confirm before the API turns on.

    Install Hook

    Adds hooks to your Claude Code settings (~/.claude/settings.json) that run automatically as Claude works. The hook is what lets iTerm2 detect Claude's state (working, waiting, done, and so on) and show it in the Session Status tool. Each hook runs it2 handle-agent-hook, using a copy of it2 at a stable location inside iTerm2's configuration directory, so upgrading or moving iTerm2 does not break it. Installs made by older versions of iTerm2 ran a program called cc-status instead; they keep working, and reinstalling updates them to the new command.

    If you set CLAUDE_CONFIG_DIR to keep Claude Code's settings somewhere else, the hook goes in the settings.json in that directory. iTerm2 reads the variable from the shell your profile starts. When that could give a different answer than your login shell (for example, a profile that runs a different shell or a custom command), the installer shows the candidates and asks Which Settings Location Should the Claude Code Hook Be Installed In?

    Install on Remote Host

    This step appears only when you open the installer from a session on a host reached through SSH Integration, including a tmux Integration pane on such a host, and the installer starts at it. It adds the hook to Claude Code's settings on that host, so Claude Code running there reports its status too. The hook there runs the it2 command that SSH Integration keeps up to date on the host, so the host's login shell must be one SSH Integration supports (zsh, bash, fish, or xonsh). If the host is this Mac, the installer says so and leaves it to the Install Hook step.

    The hook reports Claude's status through the iTerm2 API, so the installer asks whether to Always Allow the host to use it or to Ask Each Connection. Always allowing a host means any program running as you on that host can see and control your terminal sessions without asking. You can change this later in Settings > General > Magic: click Manage Permissions… and use the API Access over SSH tab.

    Show Toolbelt

    Shows the toolbelt (on the right side of the window) and enables the Session Status tool. You can toggle the toolbelt at any time from View > Toolbelt > Show Toolbelt or with ⌘⇧B.

    Install Workgroup

    Adds the Claude Code Workgroup to your settings. See The Claude Code Workgroup below. You can customize the layout afterward in Settings > Arrangements > Workgroups.

    Auto-Enter Workgroup

    Lets you pick the terminal profiles you run claude in. iTerm2 adds triggers to each one so it enters the Workgroup automatically when claude starts and exits when the main session's claude stops. This step is optional; you can always enter the Workgroup by hand from Shell > Workgroups > Claude Code. For how these triggers behave at runtime, see Entering the Workgroup Automatically below.

    Session Status

    The Session Status tool in the toolbelt lists your sessions with the status each one reports. Show it with View > Toolbelt > Session Status (the installer does this for you). Each Claude session shows a colored dot and a label for its state, on its tab and in the tool:

    • working (orange) while Claude is running a prompt or a tool.
    • waiting (blue) when Claude needs your input, for example to approve a permission request.
    • done (green) when Claude has finished a turn and you haven't looked at the result yet. Pressing a key in the session turns it idle.
    • background (purple) when Claude's turn is over, so it is ready for your next message, but background agents or background commands it started are still running. The detail line says how many.
    • error (red) when the turn ended in an error, such as one from Anthropic's API.
    • idle (green dot, gray label) when there is nothing new, for example once you have seen a finished turn’s result.

    A row may also show a short detail line, such as the tool a permission request is for or a snippet of Claude's last message. The tool sorts sessions by priority, so the ones that need attention rise to the top. Click a row to jump to that session.

    Recent versions of Claude Code report their own status to iTerm2 with the Program Status Protocol (OSC 7501), even without the integration. When those reports arrive, the tab follows them, and the integration's hook adds what they leave out: the background status and Claude's last message when a turn is done. When Claude Code doesn't send them, the hook reports the whole status by itself.

    Claude Code sessions running in tmux Integration panes are listed too, whether the tmux server is on this Mac or on a host reached through SSH Integration. A Claude Code running in a plain tmux session (one not using tmux Integration) does not report its status.

    The same hook program can report the status of OpenAI's Codex CLI. There is no installer for Codex: you add the hooks to Codex's hooks.json yourself and pass --agent codex to it2 handle-agent-hook. See Session Status for details.

    The Claude Code Workgroup

    A Workgroup defines how to build a set of related sessions from a single one. Entering the Claude Code Workgroup creates two Peers alongside your main Claude session:

    • Chat is your main Claude conversation.
    • Diff shows a side-by-side view of your working-tree changes.
    • Code Review is a dedicated session for reviewing changes. When you start a review, Claude Code adds its findings to the Workgroup's Clippings panel, and withdraws any it no longer stands by. A model picker in its toolbar chooses which Claude model the next review uses. See Code Review in the Workgroups documentation.

    Switch between the Peers with one click using the Workgroup's toolbar, and customize the whole layout (commands, toolbar items, additional Peers) in Settings > Arrangements > Workgroups. Workgroups are a general iTerm2 feature; the Claude Code Workgroup is just a preset the installer adds as ordinary, editable settings. To learn what else Workgroups can do, see the Workgroups documentation.

    Entering the Workgroup Automatically

    If you installed the Auto-Enter Workgroup triggers, iTerm2 enters the Workgroup for you whenever claude starts in one of the profiles you chose, and exits it when the main session's claude stops. The triggers filter on the claude job, so they don't fire for anything else. The Exit trigger is leader-only: only the main (leader) session's claude ending tears the Workgroup down, so ending or reloading claude in a Peer like the Diff or Code Review session leaves the rest of the Workgroup intact.

    To enter the Workgroup by hand at any time, use Shell > Workgroups > Claude Code. To leave it, use Shell > Workgroups > Exit Workgroup.

    Trying It Out First

    When Claude Code is running in a session and you have not set up the integration yet, iTerm2 offers a one-time banner: “Claude Code is running. Want to try the Claude Code integration?” Click Try It Now to enter the Workgroup on the spot (the entry is temporary and ends when Claude stops). If the hook isn’t installed and working in the settings directory that session’s Claude Code reads, Try It Now also opens the setup window so you can install it. Click Don't Show Again to dismiss the offer for good. Installing the integration from the menu makes the Workgroup permanent.

    Repairing a Broken Installation

    Claude Code occasionally rewrites ~/.claude/settings.json and can drop iTerm2's hook. If that happens after you have set the integration up, iTerm2 notices the next time Claude runs and offers to reinstall the hook so the status indicators keep working. Choose Reinstall to reopen the setup window, or Not Now to dismiss. You can also reinstall at any time from iTerm2 > Reinstall Claude Code Integration.

    The same check runs for Claude Code on a host reached through SSH Integration. If the hook there is broken, iTerm2 offers to reinstall it; if it was never installed there, iTerm2 offers to install it. Either way, the setup window opens at the Install on Remote Host step.

    Uninstalling

    Select iTerm2 > Uninstall Claude Code Integration. This removes iTerm2's hook from ~/.claude/settings.json (or the settings file in CLAUDE_CONFIG_DIR), the Claude Code Workgroup from your settings, and the Enter/Exit Workgroup triggers from every profile.

    It also removes the hook from Claude Code's settings on every host you are connected to through SSH Integration at the time. Hosts that aren't connected keep their hook; connect to one and uninstall again to remove it there. For a host that is always allowed to use the iTerm2 API, iTerm2 asks whether to stop allowing it too, since other uses of it2 there may rely on it.

    If a hook command in the settings file refers to iTerm2's hook but also runs other programs, Uninstall leaves it in place and lists it so you can edit the file by hand.

    If the Python API is enabled, iTerm2 asks whether to leave it on, since other scripts or integrations may now depend on it. You can reinstall the integration any time from iTerm2 > Install Claude Code Integration.


    Companion App

    iTerm2 Buddy is an iOS app that pairs with your Mac so you can interact with iTerm2 from your phone. Once paired, you can browse your sessions, watch their output live, and type into them; carry on an AI chat; answer iTerm2's warnings; and receive terminal alerts on your iPhone, even when the two devices are on different networks. Features that are new on the Mac side may also need an up-to-date version of iTerm2 Buddy.

    Pairing

    To pair a device, choose iTerm2 > Companion Device Settings. The first time you set this up, iTerm2 opens a guided wizard, Set Up a Companion Device, that walks you through the whole process:

    1. It asks how you want to use the companion:
      • Set Up with AI Features lets you chat with the orchestrator and per-session agents from your phone.
      • Terminal Viewing & Control Only lets you browse sessions, watch live output, and type from your iPhone, with no AI plugin or API key needed. Chat features appear disabled in iTerm2 Buddy, with an explanation, until you turn AI on in Settings > General > AI.
    2. It installs the plugins it needs (the AI and Companion plugins, or just the Companion plugin) and turns those features on. (After this, iTerm2 can send data off the Mac, but only with your explicit consent.) If you chose AI features, this step also takes your AI provider and API key, unless AI already works or you chose a model yourself in Settings > General > AI, in which case it uses that model. If that model still needs an API key or other setup, the wizard says so and lets you install now and finish setting up the model later.
    3. It helps you install iTerm2 Buddy on your iPhone.
    4. It shows a pairing QR code. On your phone, open iTerm2 Buddy and tap Scan. On the Mac, click Show Pairing Code (macOS asks you to authenticate first) and point the phone's camera at the code.
    5. It asks you to type the 6-digit code shown on your phone, which verifies that you are pairing with your own device.

    Once you have paired before, choosing Companion Device Settings opens the settings window directly instead of the wizard.

    Paired devices connect through a relay, so they can reach each other even when the Mac and phone are on different networks. The connection is end-to-end encrypted over a Noise channel, so your data is visible only to your own devices and not to the relay.

    Sessions

    iTerm2 Buddy lists your sessions, and the list updates live as sessions are opened, closed, or renamed on the Mac. Open a terminal session to watch its output live, shown as a live video feed. The feed's bitrate scales with the window's resolution, so quality tracks the size of the window rather than being pinned to a fixed rate. From the phone you can type into the session, paste text, and copy its selection.

    You can also control web browser sessions from your phone: tap, scroll, and type into the page, and use back, forward, reload, and an address field. The phone's keyboard comes up when a text field on the page has focus.

    Answering Warnings

    When iTerm2 shows a warning while you are away from your Mac, iTerm2 Buddy stays connected, shows the warning, and lets you answer it. This includes warnings that offer to not ask again and ones that ask for a password, such as a password manager's master password or an scp password. Other kinds of dialogs, and buttons that only make sense at the Mac (for example, ones that open a file panel or another window), can't be answered from the phone; for those, iTerm2 Buddy says that the Mac is waiting instead of appearing disconnected.

    AI Chat

    With AI features set up, you can read and continue your AI chats from the phone. Editing or deleting a message on the Mac also updates the phone, and you can delete messages from the phone. Watches and timers can send a push notification to your phone when they fire.

    While watching a session, you can also send a message to the AI about it. The message goes to the chat linked to that session (its most recent one, or a new chat). The first time you do this for a session, unless that chat already sends the session’s terminal state and screen automatically, iTerm2 Buddy asks “Share This Session with the AI?”: Allow includes the session’s terminal state and current screen with your messages by setting that chat’s Check Terminal State and View Contents permissions to Always Allow (and allowing iTerm2 to send them automatically); Not Now sends the message without them and doesn’t ask again for that session until iTerm2 Buddy restarts. You can change this later in the chat’s permissions on the Mac.

    Push Notifications

    The Companion app can receive push notifications for terminal alerts. To enable this for a profile, open Settings > Profiles > Terminal, click Filter Alerts, and turn on Send alerts to paired iPhone. With this on, the profile's “alert on next mark” and Post Notification triggers also notify your phone. See Terminal profile settings for the alert options this filters.

    A script can send a push notification of its own with it2 notify title body. See it2.

    These pushes are content-free: the notification that travels through the relay and Apple's servers carries no message text. Instead, it wakes the phone, which then fetches the alert text over the encrypted Noise channel. As a result, neither the relay nor Apple sees the content of your alerts.

    Muting

    You can mute a chat from iTerm2 Buddy. A muted chat sends no push notifications, and its messages are withheld from the phone, until you unmute it.


    Workgroups

    A Workgroup is a set of related sessions that iTerm2 builds from a single one. You define the layout once; entering the Workgroup spawns all of its sessions at once, and exiting it closes them again and leaves your original (main) session running. Each session can run its own command and carry its own toolbar.

    Workgroups grew out of a specific problem. Running a coding assistant like Claude Code, I wanted two companion sessions beside it: one showing a live diff of my changes, and one for code review. Setting that up by hand every time, splitting panes or juggling tabs and keeping them together as you work, is clumsy. A Workgroup lets you define that layout once and summon the whole set on demand (or automatically, with a trigger). The related sessions always travel with your main one and stay a keystroke away.

    Peers are the key idea

    The one concept to understand first is the Peer, because it does not behave like a tab.

    Peers are several sessions that share a single pane, as though they were tabs living inside that one pane. Only one Peer is visible at a time; you switch among them in place, instantly, without opening a new tab or disturbing any other pane. That is the whole point: your diff and code-review sessions stay one keystroke away in the exact same spot, instead of scattered across the tab bar.

    The main session and its Peers occupy the same pane and share one toolbar. That toolbar has a row of buttons, one per Peer, for switching among them.

    Peers are not macOS tabs and not the Workgroup's own Tabs (described below). If you press ⌘T, you get an ordinary new tab that is not part of the Workgroup. Peers are added when you define the Workgroup, not on the fly.

    How a Workgroup is Built

    Every Workgroup has one main session: the session you are in when you enter the Workgroup. To it you can add any number of related sessions of three kinds:

    Peers

    Multiple sessions sharing one pane, switched in place (see above). Peers are the heart of the feature. Each Peer has a name, which labels its switch button.

    Splits

    An independent pane that sits alongside its parent. You choose its orientation (vertical or horizontal), which side it goes on, and how much of the parent's area it takes.

    Tabs

    A new tab that opens when you enter the Workgroup. Like splits, each tab is an independent session with its own toolbar.

    Entering and Leaving a Workgroup

    To enter a Workgroup by hand, choose it from Shell > Workgroups. Entering spawns the Workgroup's Peers, splits, and tabs and wires up the toolbars. The session you were in becomes the main session.

    The Workgroup you are currently in is marked with a checkmark in this menu, so you can always tell which one is active.

    To leave, select Shell > Workgroups > Exit Workgroup. This closes the sessions the Workgroup created and returns the main session to its normal toolbar. The main session itself keeps running.

    You can also enter and exit automatically using triggers (see Automatic Entry with Triggers below).

    Switching Between Peers

    When a Workgroup has Peers, its toolbar shows a Peer switcher: a row of buttons, one per Peer. Click a Peer's button to switch to it. If you prefer the keyboard:

    • ⌥⇧⌘1 through ⌥⇧⌘8 activate the first eight Peers (⌥⇧⌘9 activates the last Peer when there are nine or more).
    • Window > Select Split Pane > Previous Peer (⌥⌘[) and Next Peer (⌥⌘]) step through the Peers in order.

    Each Peer can also define its own custom shortcut in place of the default.

    Workgroups on Remote Hosts and in tmux

    When the main session is on a host reached through SSH Integration, the Workgroup's other sessions run on that host too, since that's where the files a diff or a code review looks at are. Each one connects the way the main session did and starts in the main session's directory. Its command runs under /bin/sh with the PATH your login shell sets up there, so programs installed in your home directory (such as claude) are found.

    When the main session is a tmux Integration pane and the tmux server is version 3.2 or later, the Workgroup lives on the tmux server. Its splits and tabs are tmux panes and windows, and its Peers are tmux panes that wait in hidden tmux windows until you switch to them. Because everything is on the server, the Workgroup survives detaching. When you attach again, from this Mac or another one, iTerm2 picks it back up using a Workgroup from your settings with the same layout. If more than one of your Workgroups matches, it asks which to use; if none does, it tells you, and the panes are shown as ordinary panes. When programs from a Workgroup are left running in hidden tmux windows that no tab here can show, iTerm2 offers to Open in Tabs or Stop Them. With an older tmux, the Workgroup's sessions are created on this Mac as usual.

    Toolbars

    Every session in a Workgroup, the main session and its Peers, splits, and tabs alike, has its own toolbar, and that toolbar can hold tools specific to that session's purpose. A session's toolbar always shows its name automatically. You build each session's toolbar from these items:

    Peer Mode Switcher

    The row of buttons, one per Peer, for switching between them (shown above). It only appears on Peer toolbars.

    Git Status

    Shows the working directory's current git status and updates it live. While it shows a branch name (not during a rebase or similar), right-click it and choose Copy to copy the name, or drag it into a text field to paste it, or onto the Finder to make a text clipping.

    Changed File Selector

    A popup of the files that have changed. Picking one runs that session's per-file command, for example to show the diff of just that file.

    Git Base Selector

    Chooses the git revision to diff against. It defaults to HEAD, and commands can read the chosen value as the gitBase variable.

    Navigation Buttons

    Back and forward buttons for stepping through the changed-file list. Each has an optional keyboard shortcut.

    Reload

    A standalone reload button, with an optional keyboard shortcut.

    Auto-Send Clippings When Idle

    A toggle offered on Code Review sessions (off by default). When on, the review session's Clippings are sent to the Workgroup's main session each time the review session goes idle.

    Auto-Request Review When Idle

    A toggle offered on the main session (off by default). When on, a review is automatically requested from the Workgroup's code-review session each time the main session goes idle. It requires the Workgroup to have exactly one code-review session.

    Code Review Model

    A combo box, offered on Code Review sessions, that chooses the model the next review uses. Pick default (whatever model claude would use on its own), fable, opus, sonnet, or haiku, or type any model name; names you type are remembered in the menu. The choice applies the next time a review starts. Click the star beside it to make the shown model the one Code Review sessions start with in new Workgroups; click a filled star to go back to Claude's default model. The model reaches the review's command through the codeReviewModelFlag variable (see Variables), so a custom review command needs \(codeReviewModelFlag) for the picker to have any effect.

    AI Usage

    A gauge showing how much of your Claude subscription's weekly usage limits you have used, as progress bars with percentages: one for all models, plus one for each model-specific weekly limit Claude Code reports. Hover over it for details such as when the limit resets. It gets the numbers by running the Claude Code command-line tool (claude -p /usage), which can take several seconds, so claude must be installed and signed in to a Claude subscription. If it can't get your usage, it says why (for example, that Claude Code took too long to report it); click it for details. This item has three settings:

    • Provider: whose usage to show. Anthropic (Claude Code) is the only choice.
    • Command: leave this empty to use the script bundled with iTerm2, or enter your own command. A custom command must print JSON in the same form as the bundled script, for example {"bars":[{"label":"Week","short":"W","fraction":0.25,"detail":"resets Monday"}],"error":null}: one bar per entry in bars, with fraction from 0 to 1, or an empty bars and a human-readable error.
    • Every (sec): how often to refresh. The default is 60 seconds and the minimum is 5. A command that runs longer than 40 seconds is stopped.

    Spacer

    Flexible whitespace for arranging the other items.

    Session Modes

    Each session in a Workgroup runs in one of three modes:

    Regular

    Runs its command immediately when you enter the Workgroup. This is the default.

    Diff

    Waits until there are pending changes in the working directory before running its command. This avoids launching a diff tool against a clean tree. As soon as changes appear, the command runs.

    Code Review

    Shows a prompt overlay before the command runs. You type a free-form instruction (or pick a saved one from the Prompts menu) and click Start. iTerm2 exposes the text you enter to the command as the codeReviewPrompt variable, so the session can pass it to whatever program it launches. See Code Review below for how the Claude Code Workgroup uses it.

    Code Review

    The Code Review Peer in the Claude Code Workgroup and the Coding Agent + Diff + Code Review preset runs this command when you click Start:

    claude \(codeReviewModelFlag) \(codeReviewPrompt) --append-system-prompt-file '\(codeReviewSystemPromptFile)' --settings '\(codeReviewSettingsFile)'

    Your instruction is Claude's prompt. A reusable system prompt that shapes how the review is conducted is appended to Claude's own; you can edit it in Settings > General > AI > Prompts > Code Review System Prompt. iTerm2 writes it to a file when the review starts and passes the file's path as codeReviewSystemPromptFile. codeReviewSettingsFile is a small Claude Code settings file that lets Claude add and delete Clippings without asking for permission each time. codeReviewModelFlag comes from the Code Review Model toolbar item.

    The system prompt tells Claude to report its findings with it2 session add-clipping, so they appear in the Clippings panel, which every session in the Workgroup shares. This is how you pass comments from the review to a coding-assistant session: the review adds its findings as Clippings, and the other sessions in the Workgroup see the same panel. With Auto-Send Clippings When Idle on, they are sent to the main session for you. At the start of each review, Claude archives the previous review's Clippings. add-clipping prints each new Clipping's ID, and if Claude later decides a finding was wrong, a duplicate, or already fixed, it withdraws it with it2 session delete-clipping. See it2 for these commands.

    Reviews work in tmux Integration panes and on hosts reached through SSH Integration. If you customized the Code Review system prompt in an earlier version, your copy may run it2 in a way that doesn't work there. In that case, the next time a review starts, iTerm2 offers to update it. If your prompt is an unchanged copy of an older default, Update Prompt replaces it with the current default, which then stays up to date. If you edited it, iTerm2 shows exactly which lines it would change (only the it2 commands) and leaves the rest of your prompt as you wrote it. Keep My Prompt leaves it alone, and iTerm2 won't ask again about that prompt.

    Configuring Workgroups

    Open Settings > Arrangements > Workgroups. The left side lists your Workgroups; use + and - to add or remove them, and the Add Preset popup to start from a built-in template (see Presets).

    Select a Workgroup to edit it in the middle, where its sessions appear as the buttons above a layout preview. Select a session to configure it on the right. The settings available depend on the session: the main session has only a name, shortcut, and toolbar items (its command is whatever you were already running when you entered), while an added Peer also has a profile, mode, and command.

    The main session, here named “Chat”.

    A Diff-mode Peer. Because its toolbar includes the Changed File Selector, it also gets a File command.

    A Code Review Peer, whose command passes \(codeReviewPrompt) to Claude.

    The settings a session can have are:

    • Profile: which iTerm2 profile the session uses.
    • Mode: Regular, Diff, or Code Review.
    • Command: the command to run (for terminal sessions), or a starting URL for browser sessions.
    • File command: the command that runs when you pick a file in the Changed File Selector. It can interpolate the picked file and the git base. This setting appears only when the session's toolbar includes the Changed File Selector.
    • Name and Shortcut (Peers only): the label that appears on the Peer's switch button and an optional custom keyboard shortcut.
    • For splits: orientation, side, and the fraction of the parent the split occupies.

    This is also the only place you add or remove sessions in a Workgroup. Membership is fixed by the definition, so ⌘T and ⌘W do not add to or subtract from the group; edit it here instead.

    Workgroups you create from a preset are ordinary, fully editable settings; the presets are just starting points.

    Presets

    Two built-in presets appear in the Add Preset popup:

    • Coding Agent + Diff: a main session plus a Diff Peer that shows git diff of your changes and lets you drill into individual files.
    • Coding Agent + Diff + Code Review: the same, plus a Code Review Peer that prompts you for a review request and runs a coding agent against it.

    Variables

    Commands and file commands support iTerm2's interpolated string syntax, \(name). The variables most useful in Workgroups are:

    • \(gitBase): the revision you choose in the Git Base Selector (default HEAD).
    • \(file): the file you pick in the Changed File Selector, for use in a session's file command.
    • \(codeReviewPrompt): the text you enter in a Code Review session's prompt overlay, quoted for the shell.
    • \(codeReviewModelFlag): --model followed by the model chosen in the Code Review Model toolbar item, quoted for the shell, or empty when it's set to default.
    • \(codeReviewSystemPromptFile): the path of a file holding the system prompt from Settings > General > AI > Prompts > Code Review System Prompt.
    • \(codeReviewSettingsFile): the path of the Claude Code settings file that lets a review add and delete Clippings without asking.

    iTerm2 shell-escapes file and git-base values before substitution, so names with spaces or special characters are safe.

    Automatic Entry with Triggers

    Two triggers let a Workgroup come and go on its own:

    • Enter Workgroup… enters a Workgroup you choose when its condition matches.
    • Exit Workgroup leaves the current Workgroup.

    In terminal profiles these fire on matching output or on session events such as a job starting or ending; in browser profiles they fire on a URL matching a regular expression. This is how the Claude Code integration auto-enters its Workgroup: an Enter Workgroup trigger fires when the claude job starts, and an Exit Workgroup trigger fires when it ends. Re-entering a Workgroup you are already in does nothing, so the triggers are safe to fire repeatedly.

    A Job Started trigger set to Enter Workgroup “Claude Code” when the claude job begins.

    A Job Ended trigger set to Exit Workgroup when claude ends. “Only on the workgroup leader” makes only the main session's exit tear the Workgroup down.

    For a concrete, ready-made example of Workgroups in action, see the Claude Code integration.


    Clippings

    Clippings are a panel of saved text snippets you can send to the terminal or copy to the clipboard. Each Clipping has a title and a body, and the body can use Markdown. The panel is handy for collecting things you want to reuse or hand off, such as commands, notes, or review comments.

    Showing the Panel

    Toggle the Clippings panel with View > Show Clippings (⇧⌘=). It appears on the right side of the window. Drag its left edge to make it wider or narrower; iTerm2 remembers the width per machine.

    Adding, Sending, and Copying

    Click the + button to open the New Clipping dialog, give the Clipping a Title and Detail (the body), and click Add. To remove one, select it and click − (or press Delete).

    Select one or more Clippings and use the panel's buttons to send them to the terminal or copy them to the clipboard. When a Clipping has a title, iTerm2 puts the title in bold Markdown above the body. When you send or copy several at once, iTerm2 joins them with a separator, an advanced setting that defaults to a line of two dashes. (You can change it in Settings > Advanced; search for "Separator inserted between multiple clippings.")

    History

    The archive button snapshots the current list and clears it, which gives you a fresh list while keeping the old one. The back and forward buttons walk through your archived snapshots, and a counter shows where you are in the history. From a script you can archive with the it2 session archive-clippings command or the iterm2.archive_clippings API call, and add Clippings with the it2 session add-clipping command or the iterm2.add_clipping API call.

    Scripting

    it2 session add-clipping <type> <title> <detail> adds a Clipping and prints its unique ID. it2 session delete-clipping <id> removes the Clipping with that ID, which lets a program withdraw something it added earlier. Only live Clippings can be deleted, not archived ones. These commands, and archive-clippings, act on the session it2 runs in unless you pass --session. From inside a tmux integration pane, pass --tmux "$TMUX" --tmux-pane "$TMUX_PANE" to act on the session showing that pane. See it2 for details.

    Clippings in Workgroups

    Every session in a Workgroup shares one Clippings panel. iTerm2 routes each session's Clippings to the Workgroup's main session, so all of its sessions see the same list. This is what lets a Code Review session hand its findings to a coding-assistant session: the review adds Clippings, and the agent's session sees them in the same panel.

    A program running in the review session adds a Clipping with the it2 session add-clipping <type> <title> <detail> command (for example, a type of "Code Review Comment"). This is how the Claude Code Workgroup's review session posts its comments to the coding session. The review uses it2 session delete-clipping to withdraw a finding it no longer stands by.


    Proprietary Escape Codes

    iTerm2 supports several non-standard escape codes. These may not work properly in tmux or screen, and may have unknown effects on other terminal emulators. Proceed with caution.

    The control sequences use the following notation:

    • ESC means "Escape" (hex code 0x1b) .
    • ST means either BEL (hex code 0x07) or ESC \\.
    • Spaces in control sequences are to be ignored.
    • Values in [brackets] are variable parameters, not literals.
    • OSC means ESC ]
    • CSI means ESC [
    • SP means a literal "space" character (not ignored!)

    The OSC command 50 used to be used but it conflicts with xterm, so it is now 1337.

    Report Foreground/Background Colors (OSC 4)

    The xterm-defined OSC 4 control sequence has a mode where it reports the RGB value of a color. iTerm2 extends its reporting mode to add two additional color indices representing the default foreground and background color.

    To get the background color:

    OSC 4 ; -2; ? ST
    

    And this gets the foreground color:

    OSC 4 ; -1 ; ? ST
    

    For background and foreground respectively, the terminal will write back:

    OSC 4 ; -2 ; rgb : [red] / [green] / [blue] ST
    OSC 4 ; -1 ; rgb : [red] / [green] / [blue] ST
    

    Where [red], [green], and [blue] are either 2 or 4-digit hex values like 14a7 or ff. For 4-digit values, you can get an approximation of the 2-digit value by taking the first two digits.

    Anchor (OSC 8)

    VTE and iTerm2 support OSC 8 for defining hyperlinks, much like HTML's anchor tag.

    OSC 8 ; [params] ; [url] ST
    

    [params] consists of zero or more colon-delimited key-value pairs. A key-value pair is formatted as key=value. The only currently defined key is id. Two adjacent hyperlinks with the same URL but different ids will highlight separately when Command is pressed during hover.

    If the url is absent then that ends the hyperlink. Typical usage would look like:

    OSC 8 ; ; https://example.com/ ST Link to example website OSC 8 ; ; ST
    

    To open a link, hold Command and click the link.

    Note: in iTerm2 version 3.4 and later, if the URL has the file scheme and a # fragment is present then the semantic history rules will apply for opening the file. It may optionally include a line number, like file:///tmp/file.txt#123 or line number and column number like file:///tmp/file.txt#123:45.

    Set cursor shape

    OSC 1337 ; CursorShape=[N] ST
    

    where [N]=0, 1, or 2.

    • 0: Block
    • 1: Vertical bar
    • 2: Underline

    Add this to your .vimrc to change cursor shape in insert mode:

    let &t_SI = "\<Esc>]1337;CursorShape=1\x7"
    let &t_EI = "\<Esc>]1337;CursorShape=0\x7"
    

    This is derived from Konsole.

    Set pointer shape

    To change the shape of the mouse pointer while it is over the session's text:

    OSC 22 ; [name] ST
    

    [name] is an X11 cursor name. iTerm2 maps these names to the closest macOS pointer:

    NamePointer
    `xterm`I-beam
    `arrow`, `left_ptr`, `watch`Arrow
    `hand1`, `hand2`Pointing hand
    `fleur`Open hand
    `cross`, `cross_reverse`, `crosshair`, `tcross`Crosshair
    `X_cursor`Operation not allowed
    `left_side`, `sb_left_arrow`Resize left
    `right_side`, `sb_right_arrow`Resize right
    `based_arrow_up`, `sb_up_arrow`Resize up
    `based_arrow_down`Resize down
    `sb_h_double_arrow`Resize left and right
    `sb_v_double_arrow`Resize up and down
    `plus`, `minus`Zoom in and zoom out on macOS 15 and later; crosshair on earlier versions

    Any other name, including an empty one, restores the default pointer.

    Set Mark

    The "Set Mark" (cmd-shift-M) command allows you to record a location and then jump back to it later (with cmd-shift-J). The following escape code has the same effect as that command:

    OSC 1337 ; SetMark ST
    

    Steal Focus

    To bring iTerm2 to the foreground:

    OSC 1337 ; StealFocus ST
    

    Clear Scrollback History

    To erase the scrollback history:

    OSC 1337 ; ClearScrollback ST
    

    Set current directory

    To inform iTerm2 of the current directory to help semantic history:

    OSC 1337 ; CurrentDir=[current directory] ST
    

    Post a notification

    To post a notification:

    OSC 9 ; [Message content goes here] ST
    

    Post a rich notification

    To post a notification with a title, subtitle, or image:

    OSC 1337 ; Notification=[key]=[value] ; [key]=[value] ... ST
    

    Every value is base64-encoded UTF-8. The keys are:

    KeyDescription
    messageThe body of the notification.
    titleThe notification's title.
    subtitleThe notification's subtitle.
    imageThe path to an image file on the Mac running iTerm2, shown as an attachment to the notification.

    All keys are optional. Like OSC 9, this is subject to the profile's notification settings, and it fires “Notification Posted” event triggers, which see the title, message, and subtitle.

    Example in bash:

    printf '\e]1337;Notification=title=%s;message=%s\a' "$(printf 'Build' | base64)" "$(printf 'Finished' | base64)"
    

    Progress Bar

    The progress bar can be controlled using OSC 9 with a leading 4 parameter:

    OSC 9 ; 4 ; [st] ; [pr] ST
    

    [st] specifies the state:

    • 0: Stop/clear the progress bar
    • 1: Set progress to `[pr]` percent (success state)
    • 2: Set error state, optionally with `[pr]` percent
    • 3: Set indeterminate state (a band that scrolls back and forth in the session's progress bar, and a spinner in the tab)
    • 4: Set paused state (the ConEmu "paused" state), optionally with `[pr]` percent

    [pr] is the progress value as a number from 0 to 100. It is required for state 1. For state 2 it is optional; when omitted, the progress indicator shows an error state without a specific percentage. For state 4 it is also optional; when omitted, the current percentage is kept and simply recolored. Pausing an indeterminate indicator without a percentage shows a paused spinner: a still yellow band in the session and a pause symbol in the tab.

    To stop the progress bar, you can also use the abbreviated form:

    OSC 9 ; 4 ST
    

    A progress bar that goes 15 seconds without an update is hidden, so one left behind by a program that exited without clearing it doesn't stay up forever. A program that keeps a bar up for a long time should send it again at least that often. The timeout can be changed in Settings > Advanced (“Hide a progress bar reported with OSC 9;4 after this many seconds without an update”); 0 keeps the bar until the program clears it.

    Examples in bash:

    # Show 50% progress
    echo -e "\033]9;4;1;50\a"
    
    # Show indeterminate progress
    echo -e "\033]9;4;3\a"
    
    # Show error state at 75%
    echo -e "\033]9;4;2;75\a"
    
    # Show indeterminate error state
    echo -e "\033]9;4;2\a"
    
    # Show paused state at 25%
    echo -e "\033]9;4;4;25\a"
    
    # Clear the progress bar
    echo -e "\033]9;4;0\a"
    

    Change profile

    To change the session's profile on the fly:

    OSC 1337 SetProfile=[new profile name] ST
    

    Set profile property

    To change one or more of the current session's profile properties at runtime:

    OSC 1337 ; SetProfileProperty=[Key]=[base64-JSON] [ ; [Key2]=[base64-JSON] ...] ST
    

    Each [Key] is a profile property key and each [base64-JSON] is a base64-encoded JSON value for that key. Multiple key-value pairs may be separated by semicolons.

    For example, to set the Cursor Type property to 2 (underline), base64-encode the JSON value 2 (which is Mg==) and send:

    echo -e "\033]1337;SetProfileProperty=Cursor Type=Mg==\a"
    

    Copy to clipboard

    To place text in the pasteboard:

    OSC 1337 ; CopyToClipboard=[clipboard name] ST
    

    Where name is one of "rule", "find", "font", or empty to mean the general pasteboard (which is what you normally want). After this is sent, all text received is placed in the pasteboard until this code comes in:

    OSC 1337 ; EndCopy ST
    

    Set window title and tab chrome background color

    To set the window title and tab color use this escape sequence:

    OSC 6 ; 1 ; bg ; red ; brightness ; [N] ST
    OSC 6 ; 1 ; bg ; green ; brightness ; [N] ST
    OSC 6 ; 1 ; bg ; blue ; brightness ; [N] ST
    

    Replace [N] with a decimal value in 0 to 255.

    Example in bash that turns the background purple:

    echo -e "\033]6;1;bg;red;brightness;255\a"
    echo -e "\033]6;1;bg;green;brightness;0\a"
    echo -e "\033]6;1;bg;blue;brightness;255\a"
    

    To reset the window title and tab color, use this code:

    OSC 6 ; 1 ; bg ; * ; default ST
    

    For example:

    echo -e "\033]6;1;bg;*;default\a"
    

    Session Status

    To set the tab's dot indicator, subtitle text, and subtitle color:

    OSC 21337 ; indicator=[color] ; status=[text] ; status-color=[color] ; detail=[text] ST
    

    indicator is the color of the tab's dot indicator, status is the subtitle text, status-color is the color of that text, and detail is extra text shown in the Session Status tool and the Cockpit. Colors are given as #rrggbb or rgb:rr/gg/bb. Any field may be omitted, and sending a field with an empty value clears it. Unknown keys are ignored. Within a value, write \; for a literal semicolon and \\ for a literal backslash.

    Two more keys let a status end by itself:

    • `expires-on=progress-end`: the status ends about three seconds after a progress bar (OSC 9;4) that was running in the session stops, unless a newer status is set first.
    • `then-status`, `then-indicator`, `then-status-color`, `then-detail`: the fields to show once the status expires. With none of them, the status is cleared when it expires.

    See Session Status for more about this feature.

    Program Status Protocol

    A program can report what it is doing, rather than choosing status text and colors itself, with:

    OSC 7501 ; [key]=[value] : [key]=[value] ... ST
    

    Pairs are separated by colons. Keys are lowercase letters (at most 16 bytes), and values may contain only letters, digits, and _ . , + / = -. A pair without = or with invalid characters is skipped. The whole sequence may be at most 4096 bytes; a report that exceeds a length limit is discarded.

    KeyDescription
    stateRequired. One of `idle`, `working`, `blocked` (waiting on the user), `done`, `error`, or `clear`. A report without a valid state is ignored.
    idOptional. Names the task this report is about, as one to eight segments separated by `/` (at most 128 bytes). Each segment is 1 to 32 characters from `A-Z a-z 0-9 _ . + -`. A report with no id is about the program as a whole.
    progressOptional, for `working` and `blocked` only. An integer from 0 to 100.
    kindOptional, for `blocked` only. Why the program is waiting: `permission`, `question`, or `auth`.
    appOptional. The program's name, using the same characters as an id segment (at most 32 bytes). It labels the program's own row (the record with no id) in the Session Status tool. A task without one uses the nearest enclosing task's.
    titleOptional. A name for the task, as base64-encoded UTF-8 (padding optional, at most 192 bytes decoded). A task's row in the Session Status tool is labeled with the titles along its id path (an id segment stands in for a missing title), and for a task with an id the detail text reads “title: message”.
    msgOptional. What the program is doing or waiting for, as base64-encoded UTF-8 (padding optional, at most 2048 bytes decoded).

    Text that doesn't decode as UTF-8 or that contains control characters causes the report to be discarded.

    iTerm2 keeps one record per id, up to 256 per session, and each report replaces its record completely. state=clear removes the record and any records whose ids are beneath it; state=clear with no id removes them all. The tab shows the most urgent record (blocked, then error, done, working, and idle; the most recent wins a tie) using the statuses “waiting”, “error”, “done”, “working”, and “idle”. A record's progress is drawn on the tab's progress indicator; a blocked record pauses it and an error record turns a bar it drew red.

    Records in the working, blocked, and idle states are removed when the program exits or a new shell prompt begins. done and error records become idle when the user presses a key in the session. A full terminal reset removes every record.

    For example, to report that the program is waiting for approval, with a message:

    printf '\e]7501;state=blocked:kind=permission:msg=%s\a' "$(printf 'Run tests?' | base64)"
    

    To find out whether the terminal supports this protocol, send:

    OSC 7501 ; ? ST
    

    iTerm2 answers with the same sequence, ESC ] 7501 ; ? ESC \. This works in tmux integration panes too.

    See Session Status for how reports are shown.

    Change the color palette

    To change the current session's colors use this code:

    OSC 1337 ; SetColors=[key]=[value] ST
    

    [key] gives the color to change. The accepted values are: fg bg bold link match selbg selfg curbg curfg underline badge tab black red green yellow blue magenta cyan white br_black br_red br_green br_yellow br_blue br_magenta br_cyan br_white

    [value] gives the new color. The following formats are accepted:

    • RGB (three hex digits, like fff)
    • RRGGBB (six hex digits, like f0f0f0)
    • cs:RGB (like RGB but cs gives a color space)
    • cs:RRGGBB (like RRGGBB but cs gives a color space)
    • i:N (a palette index; see below)

    If a color space is given, it should be one of:

    • srgb (the standard sRGB color space)
    • rgb (the device-specific color space)
    • p3 (the standard P3 color space, whose gamut is supported on some newer hardware)

    A value of i:N, where N is 0 to 255, makes the color follow palette index N instead of setting a fixed RGB value. Indices 0 to 15 are the ANSI colors, so they follow the loaded color preset and switch with light and dark mode; 16 to 255 are the fixed color cube and grayscale ramp. For example, SetColors=badge=i:3 makes the badge ANSI yellow, and keeps it matching yellow if the preset changes. For the badge only, you can add an opacity from 0 to 1 after @, as in badge=i:[email protected]. Setting the color to a fixed value later replaces the binding.

    The following alternate schemes are also supported: * If key is preset then value should be the name of a color preset. * If key is tab then a value of default removes the tab color and restores it to the system default.

    A second escape sequence is also supported, but its use is not recommended:

    OSC P [n] [rr] [gg] [bb] ST
    

    Replace [n] with:

    • `0`-`f` (hex) = ansi color
    • `g` = foreground
    • `h` = background
    • `i` = bold color
    • `j` = selection color
    • `k` = selected text color
    • `l` = cursor
    • `m` = cursor text

    [rr], [gg], [bb] are 2-digit hex value (for example, "ff"). Example in bash that changes the foreground color blue:

    echo -e "\033]Pg4040ff\033\\"
    

    Annotations

    To add an annotation use one of these sequences:

    OSC 1337 ; AddAnnotation=[message] ST
    OSC 1337 ; AddAnnotation=[length] | [message] ST
    OSC 1337 ; AddAnnotation=[message] | [length] | [x-coord] | [y-coord] ST
    OSC 1337 ; AddHiddenAnnotation=[message] ST
    OSC 1337 ; AddHiddenAnnotation=[length] | [message] ST
    OSC 1337 ; AddHiddenAnnotation=[message] | [length] | [x-coord] | [y-coord] ST
    
    • `[message]`: The message to attach to the annotation.
    • `[length]`: The number of cells to annotate. Defaults to the rest of the line beginning at the start of the annotation.
    • `[x-coord]` and `[y-coord]`: The starting coordinate for the annotation. Defaults to the cursor's coordinate.

    AddHiddenAnnotation does not reveal the annotation window at the time the escape sequence is received, while AddAnnotation opens it immediately.

    Cursor Guide

    OSC 1337 ; HighlightCursorLine=[boolean] ST
    

    The [boolean] should be yes or no. This shows or hides the cursor guide.

    Attention

    OSC 1337 ; RequestAttention=[value] ST
    

    The [value] should be yes to request attention by bouncing the dock icon indefinitely, once to bounce it a single time, or no to cancel a previous request. If it is fireworks then fireworks explode at the cursor's location.

    Background Image

    OSC 1337 ; SetBackgroundImageFile=[base64] ST
    

    The value of [base64] is a base64-encoded filename to display as a background image. If it is an empty string then the background image will be removed. User confirmation is required as a security measure.

    Report Cell Size

    OSC 1337 ; ReportCellSize ST
    

    The terminal responds with either:

    OSC 1337 ; ReportCellSize=[height];[width] ST
    

    Or, in newer versions:

    OSC 1337 ; ReportCellSize=[height];[width];[scale] ST
    

    [scale] gives the number of pixels (physical units) to points (logical units). 1.0 means non-retina, 2.0 means retina. It could take other values in the future.

    [height] and [width] are floating point values giving the size in points of a single character cell. For example:

    OSC 1337 ; ReportCellSize=17.50;8.00;2.0 ST
    

    iTerm2 also answers the xterm sequence CSI 16 t with CSI 6 ; [height] ; [width] t. Unlike xterm, which reports pixels, iTerm2 gives the cell size in points rounded to whole numbers, consistent with its answer to CSI 14 t.

    Window and Screen Frames

    These sequences move and resize the window anywhere on any display, using macOS global coordinates in points: the origin is the bottom-left corner of the main display (the one with the menu bar), and y increases upward. Unlike CSI 3 ; x ; y t, they are not limited to the display the window is already on.

    To set the window's frame:

    OSC 1337 ; SetWindowFrame=[x];[y];[width];[height] ST
    

    [x] and [y] give the window's bottom-left corner. All four values are required and may be decimal numbers; otherwise the sequence is ignored. The window is kept at least as large as its minimum size and no larger than all displays together, and is moved if needed so its top edge and part of it remain on a display. It is ignored in full screen, and when the profile doesn't allow the session to resize the window (Settings > Profiles > Terminal).

    To get the window's current frame:

    OSC 1337 ; ReportWindowFrame ST
    

    iTerm2 responds with:

    OSC 1337 ; WindowFrame=[x];[y];[width];[height] ST
    

    To get the layout of all displays:

    OSC 1337 ; ReportScreenFrames ST
    

    iTerm2 responds with each display's usable frame (excluding the menu bar and Dock), main display first:

    OSC 1337 ; ScreenFrames=[x],[y],[width],[height];[x],[y],[width],[height]... ST
    

    This report is not sent when potentially insecure escape sequences are disabled in Settings > Advanced.

    Copy to Pasteboard

    You can place a string in the system's pasteboard with this sequence:

    OSC 1337 ; Copy=:[base64] ST
    

    Where [base64] is the base64-encoded string to copy to the pasteboard.

    Report Variable

    Each iTerm2 session has internal variables (as described in Scripting Fundamentals). This escape sequence reports a variable's value:

    OSC 1337 ; ReportVariable=[base64] ST
    

    Where [base64] is a base64-encoded variable name, like session.name. It responds with:

    OSC 1337 ; ReportVariable=[base64] ST
    

    Where [base64] is a base64-encoded value.

    Badge

    The badge has custom escape sequences described here.

    Downloads

    For information on file downloads and inline images, see here.

    Uploads

    To request the user select one or more files to upload, send:

    OSC 1337 ; RequestUpload=format=[type] ST
    

    In the future the [type] may be configurable, but for now it must always be tgz, which is a tar and gzipped file.

    When iTerm2 receives this it will respond with a status of ok or abort followed by a newline. If the status is ok then it will be followed by a base-64 encoded tar.gz file.

    If the user selects multiple files they will be placed in a directory within the tar file.

    Set Touch Bar Key Labels

    You can configure touch bar key labels for function keys and for the "status" button. The code used is:

    OSC 1337 ; SetKeyLabel=[key]=[value] ST
    

    Where [key] is one of F1, F2, ..., F24, to adjust a function key label; or it can be status to adjust the touch bar status button. You can also save and restore sets of key labels using a stack. To push the current key labels on the stack use:

    OSC 1337 ; PushKeyLabels ST
    

    To pop them:

    OSC 1337 ; PopKeyLabels ST
    

    You can optionally label the entry in the stack when you push so that pop will pop multiple sets of key labels if needed. This is useful if a program crashes or an ssh session exits unexpectedly. The corresponding codes with labels are:

    OSC 1337 ; PushKeyLabels=[label] ST
    OSC 1337 ; PopKeyLabels=[label] ST
    

    Where [label] is an ASCII string that works best if it is unique in the stack.

    Unicode Version

    iTerm2 by default uses Unicode 9's width tables. The user can opt to use Unicode 8's tables with a preference (for backward compatibility with older locale databases). Since not all apps will be updated at the same time, you can tell iTerm2 to use a particular set of width tables with:

    OSC 1337 ; UnicodeVersion=[n] ST
    

    Where [n] is 8 or 9

    You can push the current value on a stack and pop it off to return to the previous value by setting n to push or pop. Optionally, you may affix a label after push by setting n to something like push mylabel. This attaches a label to that stack entry. When you pop the same label, entries will be popped until that one is found. Set n to pop mylabel to effect this. This is useful if a program crashes or an ssh session ends unexpectedly.

    File Transfer

    OSC 1337 ; File=[args] ST

    See Images for details.

    Note that if the file is not an image but would benefit from native rendering, you can use this control sequence to display it with syntax highlighting and proportionally spaced typography. For example, this is a good way to view a markdown file. In that case, the following optional arguments may be provided:

    • type= mime type or extension
    • mode= regular or wide

    When you pass mode=wide then horizontal scrolling will be allowed for the contents of the document.

    Custom Control Sequences

    iTerm2 allows scripts to define custom control sequences. See the Create Window example for a working demo. The control sequence is:

    OSC 1337 ; Custom=id=[secret]:[pattern] ST
    

    Where [secret] is a secret shared between the script implementing the control sequence and the program producing it, as a security measure to make it more difficult for untrusted text to invoke a custom control sequence. [pattern] is used to identify the sequence and may contain any parameters the script needs to handle it.

    Drag and Drop

    iTerm2 supports kitty's drag-and-drop protocol, which uses OSC 72:

    OSC 72 ; [metadata] ; [payload] ST
    

    A program that registers to accept drops can receive files, text, and other data dropped onto the session, and a program can start a drag from the session that you drop into another app. When the program runs on another machine over SSH integration, dropped files are transferred in-band rather than passed as local paths. See kitty’s documentation of the protocol for the message format.

    Shell Integration/FinalTerm

    iTerm2's Shell Integration feature is made possible by proprietary escape sequences pioneered by the FinalTerm emulator. FinalTerm is defunct, but the escape sequences are documented here.

    Concepts

    The goal of the FinalTerm escape sequences is to mark up a shell's output with semantic information about where the prompt begins, where the user-entered command begins, and where the command's output begins and ends.

    [PROMPT]prompt% [COMMAND_START] ls -l
    [COMMAND_EXECUTED]
    -rw-r--r-- 1 user group 127 May 1 2016 filename
    [COMMAND_FINISHED]

    Escape Sequences

    FinalTerm originally defined various escape sequences in its original spec that are not supported by iTerm2 and are not described in this document. The best remaining references to these codes are in iTerm2's source code.

    FTCS_PROMPT

    OSC 133 ; A ST
    

    Sent just before start of shell prompt.

    FTCS_COMMAND_START

    OSC 133 ; B ST
    

    Sent just after end of shell prompt, before the user-entered command.

    FTCS_COMMAND_EXECUTED

    OSC 133 ; C ST
    

    Sent just before start of command output. All text between FTCS_COMMAND_START and FTCS_COMMAND_EXECUTED at the time FTCS_COMMAND_EXECUTED is received excluding terminal whitespace is considered the command the user entered. It is expected that user-entered commands will be edited interactively, so the screen contents are captured without regard to how they came to contain their state. If the cursor's location is before (above, or if on the same line, left of) its location when FTCS_COMMAND_START was received, then the command will be treated as the empty string.

    FTCS_COMMAND_FINISHED

    OSC 133 ; D ; [Ps] ST
    OSC 133 ; D ST
    

    The interpretation of this command depends on which FTCS was most recently received prior to FTCS_COMMAND_FINISHED.

    This command may be sent after FTCS_COMMAND_START to indicate that a command was aborted. All state associated with the preceding prompt and the command until its receipt will be deleted. Either form is accepted for an abort. If the [Ps] argument is provided to an abort it will be ignored.

    If this command is sent after FTCS_COMMAND_EXECUTED, then it indicates the end of command prompt. Only the first form with [Ps] should be used in this case. [Ps] is the command's exit status, a number in the range 0-255 represented as one or more ASCII decimal digits. A status of 0 is considered "success" and nonzero indicates "failure." The terminal may choose to indicate this visually.

    If neither FTCS_COMMAND_START nor FTCS_COMMAND_EXECUTED was sent prior to FTCS_COMMAND_FINISHED it should be ignored.

    Prompt Kinds and Right Prompts

    iTerm2 also accepts the newer Semantic Prompt forms of these sequences:

    OSC 133 ; A ; k=[kind] ; aid=[id] ST
    OSC 133 ; N ; k=[kind] ; aid=[id] ST
    OSC 133 ; P ; k=[kind] ; aid=[id] ST
    

    N behaves like A. P marks the start of a prompt without moving to a new line. The optional k attribute gives the kind of prompt: i for the initial prompt (the default), s for a secondary prompt such as a PS2 continuation line, c for a continuation, or r for a right-hand prompt. Only an initial prompt starts a new command. The optional aid attribute identifies the shell, so nested shells can be told apart; it is also accepted on B, C, and D.

    A right-hand prompt is marked by sending OSC 133 ; P ; k=r ST before it and OSC 133 ; B ST after it. Its text is left out of the command iTerm2 records, so it doesn't show up in command history or in Edit > Select Current Command. iTerm2's zsh, fish, and tcsh shell integration scripts mark the right-hand prompt this way.

    iTerm2 Extensions

    iTerm2 extends FinalTerm's suite of escape sequences.

    SetUserVar

    OSC 1337 ; SetUserVar=[Ps1]=[Ps2] ST
    

    Sets the value of a user-defined variable. iTerm2 keeps a dictionary of key-value pairs which may be used within iTerm2 as string substitutions. See Scripting Fundamentals for more information on variables and how they can be used.

    [Ps1] is the key.

    [Ps2] is the base64-encoded value.

    ShellIntegrationVersion

    Two forms are accepted. The second form is deprecated and should not be used:

    OSC 1337 ; ShellIntegrationVersion=[Pn] ; [Ps] ST
    OSC 1337 ; ShellIntegrationVersion=[Pn] ST
    

    Reports the current version of the shell integration script.

    [Pn] is the version.

    [Ps] is the name of the shell (e.g., bash).

    iTerm2 has a baked-in notion of the "current" version and if it sees a lower number the user will be prompted to upgrade. The version number is specific to the shell.

    RemoteHost

    OSC 1337 ; RemoteHost=[Ps1]@[Ps2] ST
    

    Reports the user name and hostname.

    [Ps1] is username. [Ps2] is fully-qualified hostname.

    The following synonym is available as a combination of RemoteHost and CurrentDir:

    OSC 7 [Ps] ST
    

    where [Ps] is a file URL with a hostname and a path, like file://example.com/usr/bin.

    CurrentDir

    OSC 1337 ; CurrentDir=[Ps1] ST
    

    Reports the current directory.

    [PS1] is the current directory.

    The following synonym is available as a combination of RemoteHost and CurrentDir:

    OSC 7 ; [Ps] ST
    

    where [Ps] is a file URL with a hostname and a path, like file://example.com/usr/bin.

    ClearCapturedOutput

    OSC 1337 ; ClearCapturedOutput ST
    

    Erases the current captured output.

    DECSCUSR 0

    CSI 0 SP q 
    

    This will reset the cursor to its default appearance. This is an intentional deviation from the behavior of DEC virtual terminals.

    Curly Underlines

    CSI 4 : 3 m
    

    This turns on curly underlines.

    Dual-mode Colors (light/dark variants)

    iTerm2 extends SGR so that a program can specify different colors for the light and dark appearances. iTerm2 shows the appropriate variant for the current appearance, so scrollback written in one appearance stays readable after the appearance is toggled.

    For 24-bit color, give a light RGB triple followed by a dark RGB triple:

    CSI 38 : 12 : Rl : Gl : Bl : Rd : Gd : Bd m
    

    For 256-color (indexed) color, give a light index followed by a dark index:

    CSI 38 : 13 : Nl : Nd m
    

    Use 38 for the foreground color, 48 for the background color, and 58 for the underline color. For example, CSI 48 : 12 : ... m sets a dual-mode 24-bit background and CSI 58 : 13 : Nl : Nd m sets a dual-mode indexed underline color.

    Double-width and Double-height Lines

    iTerm2 supports the DEC line-size control sequences, which affect the line containing the cursor:

    • `ESC # 3` (DECDHL): top half of a double-width, double-height line.
    • `ESC # 4` (DECDHL): bottom half of a double-width, double-height line.
    • `ESC # 5` (DECSWL): single-width, single-height line (the default).
    • `ESC # 6` (DECDWL): double-width, single-height line.

    Right-to-left Text Control

    When Enable support for right-to-left scripts is on in Settings > General > Experimental, iTerm2 reorders right-to-left text for display. A full-screen app that lays out its own text can be scrambled by this, so it can control reordering with the ECMA-48 BDSM and SCP sequences:

    • `CSI 8 l`: explicit mode. Text written after this is drawn exactly as written, without reordering.
    • `CSI 8 h`: implicit mode (the default). Text is reordered again.
    • `CSI 1 SP k`: reordered lines are laid out left-to-right.
    • `CSI 2 SP k`: reordered lines are laid out right-to-left.
    • `CSI 0 SP k`: restores the default direction.

    Each line records the mode and direction in effect as text is written to it. A second SCP parameter is accepted and ignored. CSI 8 $ p (DECRQM) reports the current mode, or “permanently reset” when right-to-left support is off. Both sequences can be turned off in Settings > Advanced (“Let apps control right-to-left reordering with the BDSM and SCP escape sequences”).

    Extended Device Attributes

    Report terminal name and version.

    CSI > q
    

    iTerm2 will respond with:

    ESC P > | iTerm2 [version] ST
    

    Where [version] is the version of iTerm2, such as 3.4.0.

    Open URL

    To request that iTerm2 open a URL:

    OSC 1337 ; OpenURL=: [url] ST
    

    Where [url] is a base64-encoded URL. The user must grant permission, and the feature can also be disabled.

    Disinter

    To disinter a buried session, send:

    OSC 1337 ; Disinter ST
    

    Blocks

    To define a region as a code block:

    OSC 1337 ; Block=id=[identifier] ; attr=start|end
    

    Use attr=start to begin a block and attr=end to end it, Use the same identifier for both.

    Update Block

    Available in iTerm2 3.6.9 and later.

    To fold or unfold an existing block:

    OSC 1337 ; UpdateBlock=id=[identifier] ; action=fold|unfold ST
    

    Where [identifier] is the ID of a previously defined block. Use action=fold to collapse the block into a single line, or action=unfold to expand it back to its full content.

    Example in bash:

    # Fold a block
    echo -ne "\033]1337;UpdateBlock=id=myblock;action=fold\a"
    
    # Unfold a block
    echo -ne "\033]1337;UpdateBlock=id=myblock;action=unfold\a"
    

    Buttons

    To create a copy button that, when clicked, copies a code block:

    OSC 1337 ; Button=type=copy ; block=[identifier]
    

    The identifier should reference the identifier of a code block defined with OSC 1337;Block=....

    Available in iTerm2 3.6.9 and later.

    To create a custom button that sends an escape sequence when clicked:

    OSC 1337 ; Button=type=custom ; code=[code] ; icon=[sf-symbol] ST
    

    Where [code] is a positive integer and [sf-symbol] is the name of an SF Symbol (e.g., star.fill, checkmark.circle). When the button is clicked, the terminal sends the following escape sequence to the running application:

    CSI ? 1337 ; [code] ~
    

    For example, if [code] is 42, clicking the button sends ESC [ ? 1337 ; 42 ~ (hex: 1b 5b 3f 31 33 33 37 3b 34 32 7e).

    To invalidate all custom buttons (making them appear grayed out and non-interactive):

    OSC 1337 ; Button=type=custom ST
    

    Example in bash:

    # Create a custom button with code 42 and a star icon
    echo -ne "\033]1337;Button=type=custom;code=42;icon=star.fill\a"
    
    # Invalidate all custom buttons
    echo -ne "\033]1337;Button=type=custom\a"
    

    Feature Reporting

    To detect which features the terminal supports, use the protocol described in feature reporting.

    To request the report, send:

    OSC 1337 ; Capabilities ST
    

    iTerm2 replies with OSC 1337 ; Capabilities=[features] ST, where [features] is encoded as described in the specification.


    URL Scheme

    iTerm2 registers a custom URL scheme, iterm2:, that lets other apps, scripts, links, and the open command ask iTerm2 to perform certain actions. For example, opening iterm2:reveal?sessionid=$ITERM_SESSION_ID brings a particular session to the front.

    You can open one of these URLs in many ways: with open 'iterm2:...' from the shell, by clicking a link in another app, or with an OSC 8 hyperlink printed in the terminal. Most handlers are also used internally by iTerm2 itself, for instance in the messages shown by clicking the indicators at the top right of a session.

    Security Model

    Because any app on the system can open an iterm2: URL, these handlers are designed to be safe to trigger from an untrusted source:

    • Handlers that only reveal existing content (such as reveal, annotation, and reveal-mark) take no destructive action.
    • The command handler always shows a dialog that lets you review and edit the command before it runs, and the option to run a command silently in the background is only available for links generated by iTerm2 itself.
    • The triggers handler shows a confirmation dialog listing what will be imported and into which profiles.

    The scheme name is always iterm2. Note that the exact number of slashes matters: some handlers use an opaque path like iterm2:reveal?... (no slashes) while others use a leading slash like iterm2:/command?.... Follow the exact form given for each handler below.

    command

    Runs a command. This is the URL created by the Share button on a selected command (see Command Selection) and by Copy Command URL to Clipboard in the Command Info panel.

    A simple example is iterm2:/command?c=date. The path is always /command.

    Query parameters:

    • c (required): the command to run. Leading and trailing whitespace is removed.
    • d (optional): a directory to change into before running the command.
    • silent (optional): a value-less flag requesting that the command run in the background without showing its output. This only takes effect for links generated inside iTerm2; when it applies, a confirmation dialog is shown first.

    If a hostname is present, iTerm2 offers to ssh to that host to run the command. For example, iterm2://[email protected]/command?c=date runs date on example.com as user gnachman.

    When you open a command URL, iTerm2 presents a window describing what will be done and lets you edit the command, directory, and ssh destination before choosing how to run it: in a new window, a new tab, or the current session.

    reveal

    Brings a specific session to the front, searching visible tabs, buried sessions, and other windows.

    iterm2:reveal?sessionid=<id>
    

    The sessionid parameter takes the value of the session's ITERM_SESSION_ID environment variable (for example, w0t0p0:ABCD-EFGH-...). This is useful for jumping back to a session from an external script, note, or other application: record the session ID when starting a long-running job and open the URL later to return to it.

    triggers

    Imports one or more triggers into profiles you select. This is the URL produced when you export triggers from iTerm2.

    iterm2:triggers?<trigger>&<trigger>&...
    

    Each query parameter is a URL-encoded JSON dictionary describing one trigger, given as the parameter name with no value. When opened, iTerm2 shows a dialog listing the triggers and asks which profiles to add them to. Because of the encoding involved, these URLs are meant to be generated by iTerm2 rather than written by hand.

    copy-block

    Copies the text of a command block (the output of a single command, when Shell Integration is installed) to the clipboard.

    iterm2:copy-block?guid=<session-guid>&block=<block-id>
    

    Query parameters:

    • guid (optional): the GUID of the session containing the block. If omitted, the current session is used.
    • block (required): the identifier of the block to copy.

    annotation

    Reveals a particular annotation and brings its session to the front.

    iterm2:annotation?s=<session-guid>&ann=<annotation-id>
    

    Query parameters:

    • s (required): the GUID of the session containing the annotation.
    • ann (required): the identifier of the annotation to reveal.

    reveal-mark

    Scrolls to and reveals a named or prompt mark, bringing its session to the front.

    iterm2:reveal-mark?s=<session-guid>&m=<mark-guid>
    

    Query parameters:

    • s (required): the GUID of the session containing the mark.
    • m (required): the identifier of the mark to reveal.

    compound-location

    Reveals a selection within a session, restoring an exact range of selected text. This is used by iTerm2 to link back to a specific location.

    iterm2:/compound-location?session=<session-guid>&sub=<selection>&sub=...
    

    Query parameters:

    • session (required): the GUID of the session.
    • sub (one or more): a serialized sub-selection. Multiple sub parameters may be given to describe a discontiguous selection.
    Table of Contents