Getting text out of your SSH sessions can be annoying. If it fits in a screen, I usually just select the text in PuTTY to copy it– no big deal. Otherwise, I have to either email it to myself or put it in a file, log in with WinSCP, and download the file. Way too much trouble.
Today I started searching for a better solution and found a patch for PuTTY by Diomidis Spinellis. Unfortunately it was for an old version of PuTTY. However with a little effort I updated the patch to PuTTY 0.60.
Here’s how it works:
- Use the modified PuTTY
- When connecting (or after) click on the Terminal setting, and under “Printer to send ANSI printer output to” select “Windows clipboard”
- Add the following to your .bashrc (or the appropriate startup file for your shell) To use it immediately, be sure to type “source .bashrc”
function wcl {echo -ne '\e''[5i'cat $*echo -ne '\e''[4i'echo "Copied to Windows clipboard" 1>&2
}
- Now when you want some text out of SSH, just pipe it to wcl. For instance, “ls -la |wcl” places the output of “ls -la” in your Windows clipboard.