iTerm2 – scroll less output with mouse

前端 未结 6 560
梦谈多话
梦谈多话 2021-01-31 02:43

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 comm

相关标签:
6条回答
  • 2021-01-31 03:31

    The latest version of less supports the --mouse and related flags so there's no need send arrow keys to alternate screens.

    0 讨论(0)
  • 2021-01-31 03:32

    Finally did it, I've been spending a lot of time on this looking here and there with no luck, the simplest steps are:

    1. Install the 2.9 beta version

    2. Done

    0 讨论(0)
  • 2021-01-31 03:33

    Now it is implemented in iTerm2 and can be activated by

    Settings -> Advanced -> Scroll wheel sends arrow keys when in alternate screen mode and change it to Yes

    image of "Scroll wheel sends arrow keys when in alternate screen mode" setting

    (defaults write com.googlecode.iterm2 AlternateMouseScroll -bool true still works but it just changes the same setting)

    0 讨论(0)
  • 2021-01-31 03:33

    Not the OP's question, but for anyone here trying to get this to work in tmux, with credit to choco via this github comment here's a snippet to add to your tmux.conf to get it to handle alternate screens (e.g. less, vim) correctly:

    # Check if copy-mode or any mouse flags, then send mouse events
    # or check if we're in alternate screen end send navigation keys (up, down)
    
    bind -n WheelUpPane if-shell -Ft='#{?pane_in_mode,1,#{mouse_any_flag}}' \
            'send -Mt=' 'if-shell -Ft= "#{alternate_on}" \
            "send -t= Up" "copy-mode -et= ; send -Mt="'
    bind -n WheelDownPane if-shell -Ft= '#{?pane_in_mode,1,#{mouse_any_flag}}' \
            'send -Mt=' 'if-shell -Ft= "#{alternate_on}" \
            "send -t= Down" "send -Mt="'
    

    Note, this doesn't require the Iterm preference change mentioned in other answers, but it also isn't hurt by it.

    0 讨论(0)
  • 2021-01-31 03:35

    This isn't implemented as of now.

    There is an open issue in the iTerm 2 issue tracker about implementing it.

    0 讨论(0)
  • 2021-01-31 03:43

    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.

    0 讨论(0)
提交回复
热议问题