Copy to Clipboard – KiTTY or Putty

I sometimes forget to add this function to the .bashrc file in a new server that I setup for Oracle database or middleware, and then I end up needing it when copying the content of a script/log file into Windows’ clipboard.

So here it is, if you don’t know, just add this to the end of your .bashrc file and then change KiTTY’s Remote-controlled printing option (Terminal page, look at the bottom) to “Windows clipboard”…

## WindowsClipboard Function, only use with KiTTY or modified Putty
function wclip {
  echo -ne '\e''[5i'
  cat $*
  echo -ne '\e''[4i'
  echo "Copied to Windows clipboard" 1>&2
}

… and voila! you can use this function like:

cat somescript.ksh | wclip