The
tmux API manages tmux windows/panes. For Neovim’s built-in terminal, see the Terminal API.gotoTerminal
Navigate to a tmux window/pane by index or identifier.- number: Window index (1-based), creates new window if doesn’t exist
- string: Tmux pane identifier (e.g.,
"%2","{right}","{top-left}")
Behavior
- Numeric index: Creates or selects a tmux window at that index
- String identifier: Selects a tmux pane using tmux target syntax
- Creates new tmux window if it doesn’t exist
- Uses
tmux select-windowfor windows,tmux select-panefor panes - Throws error if tmux command fails
Examples
Tmux Target Syntax
When using string identifiers, Harpoon passes them directly to tmux. Valid formats:Pane ID
%2, %5 - Direct pane identifiersDirectional
{left}, {right}, {top}, {bottom}Positional
{top-left}, {top-right}, {bottom-left}, {bottom-right}Special
{last}, {next}, {previous}sendCommand
Send a command to a tmux window/pane.- number: Window index (creates if doesn’t exist)
- string: Tmux pane identifier
Command string to send, or command index from config
Format arguments for string.format() if cmd contains format specifiers
Behavior
- Sends command using
tmux send-keys - Creates tmux window if using numeric index and doesn’t exist
- Appends newline if
enter_on_sendcmdis enabled in config - If
cmdis a number, retrieves command fromharpoon.setup({ ... term = { cmds = {...} } }) - Supports
string.format()style arguments - Throws error if tmux command fails
Examples
clear_all
Close and delete all Harpoon-managed tmux windows.Behavior
- Closes all tmux windows created by Harpoon (numeric indices)
- Uses
tmux kill-windowfor each tracked window - Does not affect manually created tmux windows
- Does not affect panes referenced by string identifiers
- Clears internal window registry
- Window indices can be reused after clearing
Example
Auto-close Configuration
You can configure Harpoon to automatically close tmux windows when exiting Neovim:Automatically call
clear_all() when exiting NeovimVimLeave autocmd that calls clear_all() automatically.
Configuration
The tmux API respects these configuration options:Config Options
Automatically append
\n to commands sent via sendCommand()Automatically save terminal command list when modified
Automatically close Harpoon-created tmux windows on VimLeave
List of preset commands accessible by index in
sendCommand()Complete Workflow Examples
Tmux Pane Identifiers Reference
Complete reference of valid pane identifiers for string-based targeting:Direct Identifiers
| Pattern | Description | Example |
|---|---|---|
%<id> | Pane ID | %2, %5 |
{start} | Start of range | {start}..{end} |
{end} | End of range | {start}..{end} |
{last} | Last active pane | {last} |
{next} | Next pane | {next} |
{previous} | Previous pane | {previous} |
Directional
| Pattern | Description |
|---|---|
{left} | Pane to the left |
{right} | Pane to the right |
{up} | Pane above |
{down} | Pane below |
{top} | Top pane |
{bottom} | Bottom pane |
Positional
| Pattern | Description |
|---|---|
{top-left} | Top-left pane |
{top-right} | Top-right pane |
{bottom-left} | Bottom-left pane |
{bottom-right} | Bottom-right pane |
Session/Window Targeting
| Pattern | Description | Example |
|---|---|---|
<session>:<window> | Specific session and window | dev:1 |
<session>:<window>.<pane> | Session, window, and pane | dev:1.2 |
<window>.<pane> | Window and pane in current session | mywindow.1 |
=<title> | Pane with specific title | =dev-server |