If you read my previous blog post, you would know that I resized my Ubuntu disk image size last week.  When I did this exercise, I somehow lost the capability to automatically copy mouse selection to clipboard in the Ubuntu terminal.  It is such a useful feature that I felt handicapped without it.  I needed it back badly that I set about looking for a solution.  Again, many solutions posted out there didn’t work for me.  This blog post I am covering what I did to get this feature working.

For my specific Ubuntu version, once I figured out it was just 3 easy steps to get this working.

Step1:  Install autocutsel

autocutsel tracks changes in the server’s cutbuffer and clipboard selection.  When the  clipboard is changed, it updates the cutbuffer.  When the cutbuffer is changed, it owns the clipboard selection.  The cutbuffer and clipboard selection are always synchronized. Since the VNC client synchronizes the Windows’ clipboard and the server’s cutbuffer, all three “clipboards” are always kept synchronized.  When you copy some text in Windows, the cutbuffer and the clipboard selection are updated.  When you copy text on the server using  either the cutbuffer or the clipboard selection, the Windows’s clipboard is always updated.

To install autocutsel open a terminal and run below command:

Step2:  Run autocutsel

After the install is completed, you need to run autocutsel.  In the terminal run below command:

Step 3:  Update .bashrc file:

In order to have this setup done automatically for every terminal you open, update the .bashrc file.

.bashrc is a shell script that Bash runs whenever it is started interactively. It initializes an interactive shell session. You can put any command in that file that you could type at the command prompt. You put commands here to set up the shell for use in your particular environment, or to customize things to your preferences. A common thing to put in .bashrc are aliases that you want to always be available.  .bashrc runs on every interactive shell launch.  In order for the autocutsel capability to be available for every shell/terminal you ever open follow the steps below:

Just scroll to the very end of the file and add the command from the previous step:

Save and exit.

That’s it.  You should now be able to copy selection to clipboard just by highlighting or selecting content using your mouse.  And it should work across your windows host and Ubuntu VM as well.  Enjoy.

Leave a comment

Your email address will not be published. Required fields are marked *