Skip to content

Instantly share code, notes, and snippets.

@MichaelDimmitt
Last active April 18, 2024 12:50
Show Gist options
  • Save MichaelDimmitt/c639c62bab879e1b6e1e9ee9641ad157 to your computer and use it in GitHub Desktop.
Save MichaelDimmitt/c639c62bab879e1b6e1e9ee9641ad157 to your computer and use it in GitHub Desktop.
tmux questions that will be answered in future

Access choose

<prefix> s - show sessions in choose mode
<prefix> w - show windows in choose mode

Create a new session

<prefix> : new -s <name of session>

Rename an existing session

Ctrl + B, $ https://superuser.com/a/428025/644627

Attach current session to a new session path.

Ctrl+b : attach -c "#{pane_current_path}"

Resize current panel

https://tech.serhatteker.com/post/2022-05/how-to-resize-tmux-panesz≈

Vertically rezie current panel to have 3 less cells :resize-pane -D 3

Direction

:resize-pane -L 3 # Resizes the current pane Left by 3 cells
:resize-pane -R 3 # Resizes the current pane Right by 3 cells
:resize-pane -U 3 # Resizes the current pane Upward by 3 cells
:resize-pane -D 3 # Resizes the current pane Down by 3 cells

# Using variables to characterize the command:
DIRECTION=D
CellSize=3
:resize-pane -$DIRECTION $cell-size

links:

It was hard to find some information about tmux modes:
I ran into Josh Branchaud's post on the subject https://dev.to/jbranchaud/the-modes-of-tmux-3d86

This led me to searching mode on tmux man page: https://man7.org/linux/man-pages/man1/tmux.1.html

Searching for mode on the man page:

Default Mode - (not defined in the man page but is described in Getting Started with tmux - By Victor Quinn)

Control Mode

  • Control Mode (control mode is accessable through <prefix> : in a tmux session.)

Windows and Panes

  • Copy Mode
  • View Mode
  • Choose Mode
  • Client Mode
  • Tree Mode
  • Customize Mode

Formats

  • Pane Mode

Buffers

  • Buffer Mode

At that point I wanted to know what the normal / default mode would be called. ...
downloading the tmux source code: https://github.com/tmux/tmux

And searching, as far as I could tell from the c code. There was no enum and the pane modes actually have a case statement where they assign a screen mode and a cursor mode.

tmux/screen.c - screen_set_cursor_style()
default mode (made up term) is pane_in_mode: 0
command mode is definately pane_in_mode: 1

**Dump variable values in tmux **
https://superuser.com/a/1461746/644627

tmux display-message -a
tmux display-message -a | grep pane

https://man7.org/linux/man-pages/man1/tmux.1.html

This file has been truncated, but you can view the full file.
@MichaelDimmitt
Copy link
Author

MichaelDimmitt commented Oct 6, 2023

(Ignore this comment it has been added to the gist above.)

Found it!
Ctrl+b : attach -c ~/Desktop

source: https://unix.stackexchange.com/a/274551/188491

Running the following command before and after you will see the session path change.
tmux display-message -a | grep session

Ctrl+b : attach -c "#{pane_current_path}"

(Ignore this comment it has been added to the gist above.)

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