Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I scroll in tmux using the mouse?

I'm using tmux 1.8 on Mac OS X 1.9.3 in the Terminal.app with an Apple magic mouse. I'm also using oh-my-zsh.

I can't scroll at all with the mouse when tmux is running. It just scrolls the whole terminal window up which goes beyond the output of tmux.

I've tried these settings in the tmux.conf file but nothing works:

set -g mode-mouse on
setw -g mode-mouse on
set -g terminal-overrides 'xterm*:smcup@:rmcup@' 

I made sure to reload the tmux.conf and also killed a sessions and created new ones just to make sure. And it still doesn't work.

Please help. Here is my entire tmux.conf

set -g default-terminal "xterm-256color"
set -g history-limit 10000
set -g status-interval 60

# status config
set -g status-utf8 on
set -g status-position top
set -g status-fg colour15
set -g status-bg colour24


# status line left side
set -g status-left-length 40
set -g status-left "#[fg=colour214,bold] #S #[fg=colour45] "

# status line right side
set -g status-right "#(~/.dotfiles/bin/tmux_battery_status) | %I:%M %p | %D "

# no more machine counting
set -g base-index 1
setw -g pane-base-index 1

# enable activity alerts
setw -g monitor-activity on
set -g visual-activity on

# window list colors
setw -g window-status-fg colour250
setw -g window-status-bg default
setw -g window-status-format " #I #W "
setw -g window-status-current-format "  #W "
setw -g window-status-current-fg colour118
setw -g window-status-current-bg default
setw -g window-status-activity-attr underscore,bold

# center the window list
set -g status-justify left

# pane colors
set -g pane-border-fg colour24
set -g pane-border-bg default
set -g pane-active-border-fg colour15
set -g pane-active-border-bg colour15

# command / message line colors
set -g message-fg colour15
set -g message-bg black
set -g message-attr bright

# rebind clear screen with Ctrl-l
bind C-l send-keys 'C-l'

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

# setup reattach-to-user-namespace for copy and paste
set-option -g default-command "reattach-to-user-namespace -l $SHELL"

# use vim keybindings in copy mode
setw -g mode-keys vi

setw -g mode-mouse on
setw -g mouse-utf8 on
setw -g mouse-select-pane on
setw -g mouse-select-window on
setw -g mouse-resize-pane on

# setup 'v' to begin selection as in vim
bind -t vi-copy v begin-selection
bind -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"

# update default binding of 'enter' to also use copy-pipe
unbind -t vi-copy Enter
bind -t vi-copy enter copy-pipe "reattach-to-user-namespace pbcopy"

# splitting panes
bind | split-window -h
bind - split-window -v

# fast resizing (-r for repeatable)
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

# tmux navigator with vim (-n allows binding without tmux prefix)
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim(diff)?$' && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim(diff)?$' && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim(diff)?$' && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim(diff)?$' && tmux send-keys C-l) || tmux select-pane -R"
bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim(diff)?$' && tmux send-keys 'C-\\') || tmux select-pane -l"
like image 286
RantriX Avatar asked Jun 04 '14 00:06

RantriX


People also ask

How do you scroll with a mouse?

To move up or down through the pages on a screen, move your mouse cursor over to the scroll bar on the right-hand side. Click on and hold the scroll bar thumb and then move your mouse forward or back over the mouse mat to move up or down on the screen.

Can not scroll in tmux?

Just press ctrl + b then [ to move around with the arrow keys. Just as with the mouse settings you have to add them to your . tmux. conf to make them permanent.

How do I navigate between tmux Windows?

Switching between panes To get from one pane to another, press Ctrl+B followed by O (as in other).


1 Answers

I figured out the problem. If you use the default Terminal.app, the mouse events are not being passed to the applications running inside the terminal. To fix this problem, you need to install MouseTerm, which requires SIMBL to be installed. You can find all of the instructions here:

https://bitheap.org/mouseterm/

Note that if you're using Mac OS X 10.9, when you try to run the install script for MouseTerm it will say that the file is corrupted. To solve this problem, just manually copy the bundle file to the SIMBL plugins folder and restart Terminal.app for it to work. You can find the SIMBL plugins folder at this path:

/Library/Application Support/SIMBL/Plugins

like image 130
RantriX Avatar answered Sep 20 '22 18:09

RantriX