The Go Blog

how do i scroll pane in tmux

21 February 2017

"ctrl-b" then "["

now in vi mode.

you can use "j", "k", "gg", "G" vi mode command.

press enter/return back.

man tmux then prese "/" to find "function" see more.

my ~/.tmux.conf

# Ctrl-b sucks. lets bind ctrl-a instead
# unbind C-b
# set -g prefix C-a

# Changing the default prefix key:

set-option -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix

# Turning the status line off, or changing its colour:

set-option -g status off
set-option -g status-style bg=blue

# Setting other options, such as the default command, or locking after 30 minutes of inactivity:

set-option -g default-shell ${SHELL -l}
set-option -g lock-after-time 1800

# Creating new key bindings:

bind-key b set-option status
bind-key / command-prompt "split-window 'exec man %%'"
bind-key S command-prompt "new-window -n %1 'ssh %1'"

# no window renaming
set-option -g allow-rename off

bind-key l next-window
bind-key h previous-window

# Scroll your way into copy mode (scrollback buffer)
# and select text for copying with the mouse
set -g mouse on

# move x clipboard into tmux paste buffer
bind C-p run "tmux set-buffer \"$(xclip -o)\"; tmux paste-buffer"
# # move tmux copy buffer into x clipboard
bind C-y run "tmux show-buffer | xclip -i"

# Rebinding the pane splitting bindings
unbind % # Remove default bindings since we're replacing
bind | split-window -h
bind - split-window -v

# smart pane switching with awareness of vim splits
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R"
bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys 'C-\\') || tmux select-pane -l"

# resize pane
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5

# escape time
set -s escape-time 1

# color fix vim
set -g default-terminal "tmux-256color"

# Cursor shape doesn't change in tmux
set -g -a terminal-overrides ',*:Ss=\E[%p1%d q:Se=\E[2 q'

# reloading
bind r source-file ~/.tmux.conf \; display "Reloaded!"

# set -g mouse on
# #sane scrolling:
# bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e; send-keys -M'"
# set -g default-shell $SHELL
# set -g default-command "reattach-to-user-namespace -l ${SHELL}"
# # Use vim keybindings in copy mode
# setw -g mode-keys vi
# # Setup 'v' to begin selection as in Vim
# bind-key -t vi-copy v begin-selection
# bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"

# Update default binding of `Enter` to also use copy-pipe
# set -g mouse on
# bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
# bind -n WheelDownPane select-pane -t= \; send-keys -M
# bind -n C-WheelUpPane select-pane -t= \; copy-mode -e \; send-keys -M
# bind -t vi-copy    C-WheelUpPane   halfpage-up
# bind -t vi-copy    C-WheelDownPane halfpage-down
# bind -t emacs-copy C-WheelUpPane   halfpage-up
# bind -t emacs-copy C-WheelDownPane halfpage-down

setw -g mode-keys vi
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
# fish default command
# set -g default-command /usr/local/bin/fish
# set -g default-shell /usr/local/bin/fish

tmux use .bash_profile or .bashrc

set-option -g default-shell ${SHELL -l}