Core Library0.xAPI Reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

method libtmux latest

Pane.swap

Swap this pane with another via $ tmux swap-pane.

Source and package
Qualified name
libtmux.Pane.swap
Module
libtmux
Declared in
Pane
Package
libtmux
Source
src/libtmux/pane.py
Other languages
Perl Erlang PowerShell Julia Elixir Haskell Common Lisp RubyLuaTypeScriptRustGoJavaC#C++ Swift Kotlin Scala OCaml F# Clojure
swap ( self, target: str | Pane | None = None, detach: bool | None = None, move_up: bool | None = None, move_down: bool | None = None, keep_zoom: bool | None = None, ) → None

Examples#

>>> pane1 = window.active_pane
>>> pane2 = window.split()
>>> pane1_id, pane2_id = pane1.pane_id, pane2.pane_id
>>> pane1.swap(pane2)
>>> pane1.refresh()
>>> pane2.refresh()
Parameters
  • target (str | Pane | None) # – Target pane to swap with. Can be a pane ID string or Pane object. Mutually exclusive with move_up / move_down. Now optional; required only when move_up / move_down are not set. Versionchanged: 0.56

  • detach (bool | None) # – Do not change the active pane (-d flag).

  • move_up (bool | None) # – Swap with the pane above (-U flag). Mutually exclusive with target and move_down.

  • move_down (bool | None) # – Swap with the pane below (-D flag). Mutually exclusive with target and move_up.

  • keep_zoom (bool | None) # – Keep the window zoomed if it was zoomed (-Z flag).

tmux command#

The tmux commands behind swap.

tmux C API#

The C declarations in tmux that implement these commands.

In other ports#

Exchange two panes

Equivalents of Exchange two panes in other languages
Language Equivalent
Ruby LibTmux::Pane#swap
Lua libtmux.Pane:swap
Erlang tmux_pane:swap/3
Haskell No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing.
TypeScript pane.Pane.swapWith
Rust pane.Pane.swap_with
Go tmux.Pane.Swap
Java io.github.libtmux.Pane.swapWith
C# LibTmux.Pane.SwapAsync
C++ libtmux::Pane::swap_with
Swift Server.swap(_:with:) swaps windows, not panes
OCaml Libtmux_unix.Client.swap_panes
Perl No dedicated equivalent in the selected Perl surface. Explicit Server::cmd remains available for native tmux commands.

No equivalent is recorded in PowerShell, Julia, Elixir, Common Lisp, Clojure, Kotlin, Scala or F#.

Esc

Type to search.

Reference previewOpen reference