Wednesday, April 20, 2016

Tmux Comfortable Shortcuts

Working with tmux is all about short cuts.  To find out existing shortcuts in tmux, you can use
$ tmux list-keys
Usually tmux key configs are stored in ~/.tmux.conf file. By modifying this file, you can override these commands. Tmux has a prefix key which is ctrl + shift + b which is the default. But we can change it to an ergonomically comfortable position. Lets see how we can modify tmux.conf file. Following are some notations used in this file.

C    means ctrl
M   means alt
C-"    means ctrl + shift + "
M-Down means alt + down arrow key
-n means you can run this command without tmux prefix

Note that mouse mode is also enable in following file. You can scroll up through the pane.
If you want to select and copy text, then while holding select the text, relese shift copy the text.

# Tmux should be pretty, we need 256 color for that
set -g default-terminal "screen-256color"


# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix

# change prefix
bind-key -n C-q detach

# split panes using right and down
bind -n M-Right split-window -h
bind -n M-Down split-window -v
unbind '"'
unbind %

# switching between sessions
bind -n C-] switch-client -p
bind -n C-[ switch-client -n
unbind )
unbind (

# switch panes using Alt-arrow without prefix
bind -n C-Left select-pane -L
bind -n C-Right select-pane -R
bind -n C-Up select-pane -U
bind -n C-Down select-pane -D

# Enable mouse control (clickable windows, panes, resizable panes)
set -g mouse-select-window on
set -g mouse-select-pane on
set -g mouse-resize-pane on


# command delay? We don't want that, make it short
set -sg escape-time 1

# Set the numbering of windows to go from 1 instead
# of 0 - silly programmers :|
set-option -g base-index 1
setw -g pane-base-index 1

No comments:

Post a Comment