Force putty to use right click to paste, on linux

As user @ateijelo said in their answer it's not possible to use "Compromise (Middle extends, Right pastes)" on Unix because it's not implemented. I don't know why isn't it, you should ask Putty developers about that, most probably nobody has even requested it. But, thanks to the nature of open source you can always modify the program's source code to suit your needs and use it. The following patch will modify the default behavior of right click and will make it paste the text:

diff --git a/unix/gtkwin.c b/unix/gtkwin.c
index 5660ee9..4f2ec2b 100644
--- a/unix/gtkwin.c
+++ b/unix/gtkwin.c
@@ -447,7 +447,7 @@ static Mouse_Button translate_button(Mouse_Button button)
     if (button == MBT_MIDDLE)
         return MBT_PASTE;
     if (button == MBT_RIGHT)
-        return MBT_EXTEND;
+        return MBT_PASTE;
     return 0;                          /* shouldn't happen */
 }

diff --git a/unix/uxsftpserver.c b/unix/uxsftpserver.c
index a90344e..6fab0ba 100644
--- a/unix/uxsftpserver.c
+++ b/unix/uxsftpserver.c
@@ -412,16 +412,6 @@ static void uss_fstat(SftpServer *srv, SftpReplyBuilder *reply,
     }
 }

-#if !HAVE_FUTIMES
-static inline int futimes(int fd, const struct timeval tv[2])
-{
-    /* If the OS doesn't support futimes(3) then we have to pretend it
-     * always returns failure */
-    errno = EINVAL;
-    return -1;
-}
-#endif
-
 /*
  * The guts of setstat and fsetstat, macroised so that they can call
  * fchown(fd,...) or chown(path,...) depending on parameters.

You have to get Putty source code, apply the patch and re-build Putty. It's a simple process though.

Clone Putty repository:

git clone git://git.tartarus.org/simon/putty.git && cd putty

Save the patch I pasted above to MBT_PASTE.patch and apply it (if it fails download patch directly from http://drabczyk.org/MTB_PASTE.patch):

git apply MTB_PASTE.patch

Build Putty:

$ cd unix
$ ../mkfiles.pl  && ../mkauto.sh
$ make -j$(nproc) -f Makefile.gtk LDFLAGS="-Wl,--no-as-needed,-ldl"

Building takes only 6 seconds on my machine. Start the newly built Putty binary:

./putty

You should see all of your saved sessions and settings just as if you stared Putty installed system-wide using your distro's package manager. You should now be able to paste selected text with right click. If you don't want to recompile Putty on your own and you trust me you can get a precompiled binary from here http://drabczyk.org/putty.

This method has its disadvantages of course. The change I've introduced has not formally accepted by Putty developers what means you're now using a fork. If you replace Putty binary installed with your distro's package manager with this it will be replaced each time you update Putty using your distro's package manager (and sometimes you may not even realize that Putty is being updated, for example when running a massive system upgrade). Alternatively, you can put your fork of Putty elsewhere, for example in ~/bin and prepend ~/bin to your $PATH so that the fork will be picked before system-wide Putty binary. I also don't know which unwanted side effects can this small change cause, if any.

I was also thinking about using xdotool but I'm not sure if you run X or Wayland and I think that modifying a single line in the source code is all in all easier.