Skip to content

Instantly share code, notes, and snippets.

@AnatomicJC
Last active September 24, 2020 09:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AnatomicJC/32c0d9cffef5590b61d7f95af2d04f75 to your computer and use it in GitHub Desktop.
Save AnatomicJC/32c0d9cffef5590b61d7f95af2d04f75 to your computer and use it in GitHub Desktop.
tmux powerline / mouse / cheat sheet

Powerline

# apt install powerline
$ cat ~/.tmux.conf 
source "/usr/share/powerline/bindings/tmux/powerline.conf"
set -g default-terminal "screen-256color"
set -g mouse on
set -g history-limit 500000

bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"

# https://blog.jpalardy.com/posts/tmux-synchronized-panes/
bind C-x setw synchronize-panes

# Memos
# tmux list-keys | grep selection
# tmux show -wg mode-keys (must return vi, not emacs)

# For binding 'y' to copy and exiting selection mode
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -sel clip -i'

Cheat sheet

https://tmuxcheatsheet.com

Buffer, copy/paste, ...

Tmux copy-paste - the defaults

  1. Enter ‘copy mode’ by pressing ctrl+b then [
  2. Use the arrow keys to go to the position from where you want to start copying. Press ctrl+space to start copying.
  3. Use arrow keys to go to the end of text you want to copy. Press alt+w or ctrl+w to copy into Tmux buffer.
  4. Press ctrl+b then ] to paste in a possibly different Tmux pane/window.

Copy-paste with mouse

  1. Select with mouse what you want to copy
  2. Before release your left button, press Ctrl+b
  3. Press ctrl+w or alt+w to copy into Tmux buffer
  4. Press ctrl+b then ] to paste in another Tmux pane/window

Copy-paste with mouse to clipboard

$EDITOR must exists and be set to vim

In your ~/.bashrc, ~/.zshrc, ~/.otherrc:

export EDITOR="vim"

Install xclip:

$ sudo apt install xclip

Add this to your ~/.tmux.conf:

# For binding 'y' to copy and exiting selection mode
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -sel clip -i'

Then to copy/paste:

  1. Select with mouse what you want to copy
  2. Before release your left button, press Ctrl+b
  3. Press the y button
  4. press ctrl+v in any other application

Memos

tmux list-keys | grep selection
tmux show -wg mode-keys # must return vi, not emacs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment