Skip to content

Instantly share code, notes, and snippets.

@qba73
Forked from sharjeelaziz/.tmux.conf
Created October 23, 2023 17:23
Show Gist options
  • Save qba73/6e4c697d12ae6197077a749f41aadb7f to your computer and use it in GitHub Desktop.
Save qba73/6e4c697d12ae6197077a749f41aadb7f to your computer and use it in GitHub Desktop.
tmux commands refresher with config
set -g @plugin 'tmux-plugins/tmux-logging'
#set prefix
set -g prefix C-a
bind C-a send-prefix
unbind C-b
set -g history-limit 100000
set -g allow-rename off
bind-key j command-prompt -p "Join pan from:" "join-pane -s :'%%'"
bind-key s command-prompt -p "Send pane to:" "join-pane -t :'%%'"
set-window-option -g mode-keys vi
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

tmux refresher

Start tmux as a session so that in case of a disconnection you session is still active on the host.

Sessions

Create new tmux session

tmux new -s session-name

Attach to a session

tmux ls
tmux attach -t session_name

Default prefix key is + b but we have changed it to + a

Detach from a Session

+ a d

Rename a session

+ a ,

Copy Mode

Move to Copy Mode

+ a [

Use page up and page down to move around. Hit space to enter into copy mode, select text, hit ⏎ Enter to copy into the vim buffer. Open vim to paste

+ a ] to paste

Navigation

Send window to a pane

+ a s

Veritcal split

+ a % to paste

Horizontal split

+ a "

Move around in windows

+ a

Zoom in/out to any windows

+ a z

Resize a window

+ a ^ hold ctrl in this case

Move the window to other layout

+ a {

Move the window to other layout

+ a }

Change the layout

+ a space

Logging

Toggle (start/stop) logging in the current pane.

  • Key binding: + a shift+p
  • File name format: tmux-#{session_name}-#{window_index}-#{pane_index}-%Y%m%dT%H%M%S.log
  • File path: $HOME (user home dir)
    • Example file: ~/tmux-my-session-0-1-20140527T165614.log

Screen Capture

Save visible text, in the current pane. Equivalent of a "textual screenshot".

  • Key binding: + a alt+p
  • File name format: tmux-screen-capture-#{session_name}-#{window_index}-#{pane_index}-%Y%m%dT%H%M%S.log
  • File path: $HOME (user home dir)
    • Example file: tmux-screen-capture-my-session-0-1-20140527T165614.log

Save complete history

Save complete pane history to a file. Convenient if you retroactively remember you need to log/save all the work.

  • Key binding: + a alt+shift+p
  • File name format: tmux-history-#{session_name}-#{window_index}-#{pane_index}-%Y%m%dT%H%M%S.log
  • File path: $HOME (user home dir)
    • Example file: tmux-history-my-session-0-1-20140527T165614.log

NOTE: this functionality depends on the value of history-limit - the number of lines Tmux keeps in the scrollback buffer. Only what Tmux kept will also be saved, to a file.

Use set -g history-limit 110000 in .tmux.conf, with modern computers it is ok to set this option to a high number.

Clear pane history

Key binding: + a alt+c

This is just a convenience key binding.

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