Skip to content

Instantly share code, notes, and snippets.

@joxz
Last active April 6, 2021 19:25
Show Gist options
  • Save joxz/05314b4371c1e3d8851486817afb8d8c to your computer and use it in GitHub Desktop.
Save joxz/05314b4371c1e3d8851486817afb8d8c to your computer and use it in GitHub Desktop.
tmux
```bash
# file: ~/.tmux.conf
# reattach
set-option -g default-command "reattach-to-user-namespace -l zsh"
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# split panes using + and -
bind + split-window -h
bind - split-window -v
unbind '"'
unbind %
# pane movement
bind-key q choose-window 'join-pane -h -s "%%"'
bind-key s command-prompt -p "send pane to:" "break-pane -t '%%'"
# Resizing panes
bind -r j resize-pane -D 2
bind -r k resize-pane -U 2
bind -r h resize-pane -L 2
bind -r l resize-pane -R 2
# vi mode
set-window-option -g mode-keys vi
bind Enter copy-mode #enter copy mode
bind p paste-buffer
bind-key ? copy-mode \; send-key ? #enter copy mode and search up
# Enable mouse mode (tmux 2.1 and above)
set -g mouse on
# terminal
set -g default-terminal "xterm-256color"
# reload config
bind R source-file ~/.tmux.conf \; display-message "Config reloaded..."
#############################################
set -g history-limit 10000 # boost history
set -g base-index 1 # start windows numbering at 1
setw -g pane-base-index 1 # make pane numbering consistent with windows
setw -g automatic-rename on # rename window to reflect current program
set -g renumber-windows on # renumber windows when a window is closed
# plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-logging'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
run -b '~/.tmux/plugins/tpm/tpm'
```

Start new named session: tmux new -s [session name]

Detach from session: ctrl+a d

List sessions: tmux ls

Attach to named session: tmux a -t [name of session]

Kill named session: tmux kill-session -t [name of session]

Create new window: ctrl+a c

Split panes horizontally: ctrl+a -

Split panes vertically: ctrl+a +

Kill current pane: ctrl+a x

Move to another pane: ctrl+a [arrow key]

Kill tmux server, along with all sessions: tmux kill-server

Reload Config: This can be done either from within tmux, by pressing Ctrl+B and then : to bring up a command prompt, and typing: :source-file ~/.tmux.conf

Or simply from a shell: $ tmux source-file ~/.tmux.conf

Search up: ctrl+a ?

vi mode:

enter vi mode: ctrl+a ENTER

mark: ctrl+a SPACE

copy: ctrl+a ENTER

paste: ctrl+a p

plugins:

logging - screen capture: ctrl+a alt+p

save history of pane: ctrl+a alt+shift+p

start/stop logging: ctrl+a shift+p

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