How to use mouse in Byobu

In Byobu, you will find that many mouse operations work just like in a raw terminal emulator. For example, you can select content by holding down the left-button and moving the mouse. And pasting by pressing the middle-button. However, you will find that the mouse operations are not Byobu-aware or Tmux-aware. For example, you can select text that spans across two split views.

Byobu/Tmux has support for mouse operations. When enabled, the mouse operations seem more natural and aware of the split views and windows of Byobu/Tmux. For example, it can be useful to use the mouse for operations such as selecting a split, resizing a split and for scrolling the console content to view history. However, note that such mouse support is turned off by default.

  • To toggle mouse support, press Alt+F12. (If it does not work, check if the keyboard shortcut is set for something else by your window manager.) When mouse support is on, the mouse cursor turns into an arrow. When it is off, the mouse cursor is an I-beam. When you toggle, you can see that Mouse: ON or Mouse: OFF is displayed at the bottom of Byobu.

  • To select a split window, just click anywhere inside it using the mouse.

  • To resize a split window, select the split and then drag its thick orange borders.

  • To scroll the content of a window, select the window and use the mouse scroller to scroll up and down. You will notice that the scrolling is split-aware. Only the console output inside a split will scroll, not the entire terminal contents.

  • To enable mouse support by default for all these operations, add these lines to your ~/.byobu/profile.tmux:

# Enable mouse support including scrolling
set -g mouse on 
# Versions prior to 2.1 may want this too:
set -g mouse-utf8 on

Restart Byobu to see the effect.

  • One side-effect of enabling mouse in Byobu is that you might find that the middle-click to paste might not work in some terminal emulators like XTerm. You can toggle the mouse support to paste in such situation.

Tried with: Byobu 5.77 and Ubuntu 14.04

How to enable mouse in virtual console

Mouse support is not enabled by default in virtual console (Ctrl+Alt+F1) in Ubuntu. This is a shame since many console applications like Vim or Htop have mouse support even when used at the terminal or TTY.

Enabling mouse support in virtual console is easy. Just install the General Purpose Mouse interface package:

$ sudo apt install gpm

No restart is needed since the package installation also starts the gpm server. Your mouse should start working immediately in terminal mode.

Tried with: GPM 1.20.4 and Ubuntu 14.04

How to get mouse position in wxWidgets

To get mouse position relative to top-left corner of display, add this in a mouse event handler:

const wxPoint pt = wxGetMousePosition();
int mouseX = pt.x;
int mouseY = pt.y;

To get mouse position relative to top-left corner of current window or canvas, add this in a mouse event handler:

const wxPoint pt = wxGetMousePosition();
int mouseX = pt.x - this->GetScreenPosition().x;
int mouseY = pt.y - this->GetScreenPosition().y;

Tried with: wxWidgets 3.0 and Ubuntu 14.04

How to enable use of mouse in terminal Vim

The mouse can be used naturally in GVim. But, it would be useful to have some mouse functionality in Vim, running in terminal mode too. For example, to scroll the code or to change the size of split windows. This is a nice feature to have, almost all the time we are using the terminal inside a windowing system anyway.

Thankfully, Vim has functionality built-in to use the mouse in terminal mode. The mouse can be enabled by putting this line in your vimrc file:

set mouse=a

Tried with: Vim 7.3