How to Add Mouse and Scroll Shortcut for tmux
While tmux is a wonderful tool on its own, for mere mortals like myself, I jump back and forth between GUI and CLI. At least, that’s the impression I am getting from tmux why I am not getting 100% out of it. The shortcuts, quite frankly, are not intuitive for modern GUI users mind.
As I have covered previously, you can use mouse and scroll if you enable them on tmux. The problem arises when you wish to, say, copy some results from Terminal to clipboard. tmux doesn’t let you. As far I as I could look it up, there is a native way to do so — only that it was not exactly the method that would occur to me when I need it.
Instead, I recommend this. On your ~/.tmux.conf file, simply add the following line:
bind m set -g mouse \; display 'Mouse: #{?mouse,ON,OFF}'
Or, if the tmux session is already running, press CTRL+B, followed by : (colon), and run the same command. It will apply immediately to the session. Once applied by pressing CTRL+B, followed by M, you can toggle mouse mode on/off freely. You could also change the binding to any other keys you like, simply swap m to any other keys.
Again, there is no doubt tmux is a versatile tool. Sometimes it’s just different from what we are used to. I read some stellar reviews on other Terminal replacements that can handle the workload of tmux, not sure it’s an avenue I would take at the moment. After all ssh is quite literally lifeblood of all DIY projects.

Comments will be automatically closed after 30 days.