Search code examples
macosterminalscrollmouseiterm

iTerm2 – scroll less output with mouse


I just switched from OSX Terminal to iTerm2, and I seem to have lost one piece of functionality. In Terminal, I could scroll through output of the less command with my mouse, because I had installed MouseTerm.

However, when I try scrolling less output in iTerm2, the window's scrollbar moves instead. Strangely, scrolling works as expected with vim.

How can I scroll less output with my mouse in iTerm2?


Solution

  • The iTerm2 issue is now marked as "fixed" - but the fix is to add a hidden option, so it is not immediately obvious how to enable the new AlternateMouseScroll option.

    As Filippo Valsorda (author of the patch) writes, once you install a nightly build (still not present in 1.0.0.20140629) of iTerm2, just run this command:

    $ defaults write com.googlecode.iterm2 AlternateMouseScroll -bool true
    

    restart iTerm2, and all your windows will report scroll events as up/down arrow-key escapes when the terminal is in the "alternate screen" (direct addressing) mode used by programs like less, vim, emacs, etcetera.

    For applications like vim and emacs that provide additional mouse support, you will still want to enable mouse reporting mode, as this automatic mode switch only enables scrolling.