Skip to content

Demonstrate how you can enter tmux commands via .cmd #2

Closed
@tony

Description

@tony

Its very valuable to know that you can have a window object and automatically be entering commands within the -t (target) context.

From tmux manual:

 This section contains a list of the commands supported by tmux.  Most
 commands accept the optional -t argument with one of target-client,
 target-session target-window, or target-pane.  These specify the
 client, session, window or pane which a command should affect.
 target-client is the name of the pty(7) file to which the client is
 connected, for example either of /dev/ttyp1 or ttyp1 for the client
 attached to /dev/ttyp1.  If no client is specified, the current client
 is chosen, if possible, or an error is reported.  Clients may be listed
 with the list-clients command.

 target-session is the session id prefixed with a $, the name of a ses‐
 sion (as listed by the list-sessions command), or the name of a client
 with the same syntax as target-client, in which case the session
 attached to the client is used.  When looking for the session name,
 tmux initially searches for an exact match; if none is found, the ses‐
 sion names are checked for any for which target-session is a prefix or
 for which it matches as an fnmatch(3) pattern.  If a single match is
 found, it is used as the target session; multiple matches produce an
 error.  If a session is omitted, the current session is used if avail‐
 able; if no current session is available, the most recently used is
 chosen.

 target-window specifies a window in the form session:window.  session
 follows the same rules as for target-session, and window is looked for
 in order: as a window index, for example mysession:1; as a window ID,
 such as @1; as an exact window name, such as mysession:mywindow; then
 as an fnmatch(3) pattern or the start of a window name, such as myses‐
 sion:mywin* or mysession:mywin.  An empty window name specifies the
 next unused index if appropriate (for example the new-window and
 link-window commands) otherwise the current window in session is cho‐
 sen.  The special character ‘!’ uses the last (previously current) win‐
 dow, ‘^’ selects the highest numbered window, ‘$’ selects the lowest
 numbered window, and ‘+’ and ‘-’ select the next window or the previous
 window by number.  When the argument does not contain a colon, tmux
 first attempts to parse it as window; if that fails, an attempt is made
 to match a session.

 target-pane takes a similar form to target-window but with the optional
 addition of a period followed by a pane index, for example: myses‐
 sion:mywindow.1.  If the pane index is omitted, the currently active
 pane in the specified window is used.  If neither a colon nor period
 appears, tmux first attempts to use the argument as a pane index; if
 that fails, it is looked up as for target-window.  A ‘+’, ‘-’ or ‘!’
 indicate the next, previous or last pane.  One of the strings top,
 bottom, left, right, top-left, top-right, bottom-left or bottom-right
 may be used instead of a pane index.

 The special characters ‘+’ and ‘-’ may be followed by an offset, for
 example:

       select-window -t:+2

 When dealing with a session that doesn't contain sequential window
 indexes, they will be correctly skipped.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions