Back openDesk Edu for a sovereign, open-source education â every vote counts.
Vote nowSave products you love by clicking the heart icon.
Essential reference for GNU Nano â keybindings, configuration, search/replace, and common usage for quick text editing.
A practical guide to scrolling in tmux sessions â especially when running tmux inside tmux. Includes mouse support, keyboard shortcuts, copy-mode, and prefix handling for multi-level navigation.
Nested tmux is a special challenge â when you run tmux inside tmux, the scrollback handling becomes a battle between two competing terminal multiplexers. By default:
Why this matters: Nested tmux isn't just a curiosity â it's a critical workflow for:
Without proper configuration, you lose access to the inner session's scrollback â the very thing you need when debugging or reviewing output.
| Binding | Action | When to Use |
|---|---|---|
| Mouse Wheel | Scroll pane directly | Default, works everywhere |
| Alt+â/â | Scroll line by line | Quick history navigation |
| Alt+PageUp/PageDown | Scroll page by page | Faster browsing |
| Alt+Space | Enter copy-mode | Select and copy text |
| Prefix + PgUp/PgDn | tmux copy-mode | Traditional tmux workflow |
# =============================================================================
# PREFIX KEY (change from Ctrl+B to Ctrl+A)
# =============================================================================
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# =============================================================================
# MOUSE SUPPORT (recommended)
# =============================================================================
set -g mouse on
# Direct mouse scroll in panes
bind-key -n MouseWheelUpPane send-keys -X scroll-up
bind-key -n MouseWheelDownPane send-keys -X scroll-down
# =============================================================================
# ALT-KEY SCROLLING (no prefix needed)
# =============================================================================
bind-key -n M-Up send-keys -X scroll-up
bind-key -n M-Down send-keys -X scroll-down
bind-key -n M-PageUp send-keys -X scroll-up
bind-key -n M-PageDown send-keys -X scroll-down
# Open copy-mode with Alt+Space
bind-key -n M-Space copy-mode
# =============================================================================
# VI-STYLE COPY-MODE
# =============================================================================
set-window-option -g mode-keys vi
# Copy-mode navigation
bind-key v copy-mode
bind-key -T copy-mode-vi k send-keys -X cursor-up
bind-key -T copy-mode-vi j send-keys -X cursor-down
bind-key -T copy-mode-vi h send-keys -X cursor-left
bind-key -T copy-mode-vi l send-keys -X cursor-right
bind-key -T copy-mode-vi Space start-selection
bind-key -T copy-mode-vi Enter copy-pipe-and-cancel "xclip -selection clipboard"
# =============================================================================
# NESTED TMUX HANDLING
# =============================================================================
# Double prefix for nested sessions
set -g prefix2 C-a
# Extended keys for better scroll support
set -g extended-keys on
# =============================================================================
# PANE NAVIGATION (bonus)
# =============================================================================
bind-key -n M-H select-pane -L
bind-key -n M-J select-pane -D
bind-key -n M-K select-pane -U
bind-key -n M-L select-pane -R
# =============================================================================
# WINDOW NAVIGATION (bonus)
# =============================================================================
bind-key -n M-Left previous-window
bind-key -n M-Right next-window
# =============================================================================
# GENERAL SETTINGS
# =============================================================================
set -g default-terminal "screen-256color"
set -g history-limit 10000
set -g status-interval 5
# Reload tmux config
tmux source-file ~/.tmux.conf
# Or from within tmux: Prefix + :
# Then type: source-file ~/.tmux.conf
Once in copy-mode (via Alt+Space or Prefix + [):
| Key | Action |
|---|---|
h/j/k/l | Move cursor |
0/$ | Beginning/end of line |
w/b | Next/previous word |
gg/G | Top/bottom of buffer |
Space | Start selection |
v | Toggle visual mode |
Enter | Copy selection |
q | Quit copy-mode |
Inner tmux: Mouse wheel or Alt+â/â
Outer tmux: Prefix (C-a) then scroll keys
1. Alt+Space (enter copy-mode in inner)
2. Navigate with hjkl
3. Space to select
4. Enter to copy
Prefix + Prefix (C-a C-a) â switches to outer
Solution: Ensure set -g mouse on is in your config
Solution: Add set -g escape-time 0 and ensure terminal supports meta keys
Solution: Use Prefix + Prefix (C-a C-a) to reach outer session
Solution: Increase with set -g history-limit 10000 (or higher)
To deploy this configuration across multiple hosts:
# ansible/roles/tmux/tasks/main.yml
- name: Deploy tmux configuration
copy:
src: files/tmux.conf
dest: ~/.tmux.conf
owner: "{{ ansible_user_id }}"
mode: '0644'
notify: reload tmux
- name: Ensure tmux is reloaded
command: tmux source-file ~/.tmux.conf
ignore_errors: yes
After applying the config, test with:
# 1. Start tmux
tmux
# 2. Test mouse scroll (should work immediately)
# 3. Test Alt+Up/Down (scrolls history)
# 4. Test Alt+Space (opens copy-mode)
# 5. Create nested session
tmux
# 6. Test nested scroll (Alt-keys work in inner, C-a C-a for outer)