Is it possible for me to make Ctrl+C perform a copy command if there is highlighted text in the terminal?
Otherwise, it should retain its normal behavior.
(If there is a terminal that can do this other than gnome-terminal, that's probably fine too.)
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
You can change the keybinding for Cut and Paste from the default Ctrl+Shift+C, Ctrl+Shift+V to what you say, namely Ctrl+C, Ctrl+V, in the Edit → Keyboard Shortcuts menu. Though you should also change the default terminal meaning associated with Ctrl+C (interrupt), for example in this way
stty intr ^J
(I chose Ctrl+J because I don't remember it is associate with some action, but you can make your own choice.)
I don't think it is possible to retain the default interrupt action for Ctrl+C only when there is no text highlighted.
Ctrl + C is already assigned to another command, which is the one that interrupts the program that is running in the terminal For example, ping www.google.com will start pinging Google until you tell it to stop. The way you do it, is by pressing Ctrl + C
So, they couldn't just change the assignment of that combination.
Highlight the text you want to copy, press Ctrl + Shift + C and it is copied to the clipboard. Ctrl + Shift + V and you paste it.
Let me know if it doesn't work...
Apart from what @Dan said, there's another option for copy-pasting text in Linux which I'm finding much faster and easier to use, since there's no need to swich from mouse (which you're using to make the selection) to keyboard:
This feature is especially useful in terminal, for example when assembling a command from bits of text which are already on screen.
This works in all applications, so it's possible to copy-paste text from a web page to terminal etc.
The clipboard buffer used for middle-click copy-paste is separate from the one used for Ctrl-C/Ctrl-V, which makes possible to have two different bits of text copied at the same time.
As already noted, Ctrl + C is typically used for interrupting a program. But instead of using Ctrl + Shift + C to copy, which I do much more frequently than interrupting a process, I change the setting to have Ctrl + C to copy and Ctrl + Shift + C to interrupt.
You can do this in GNOME Terminal by going to "Edit" -> "Keyboard Shortcuts..." and map the "Copy" action to Ctrl + C and "Paste" to Ctrl + V. The interrupt command will automatically be remapped to Ctrl + Shift + C.
Sorry for writing an answer on this, it looks like I spent too much of my reputation on a bounty for being able to post a comment.
There is no way to change the behavior of keyboard shortcuts depending on whether there is a text selection or not, and I would avoid reassigning the terminal's Ctrl-C.
BUT, you can easily get accustomed to
This works practically everywhere (except in Nautilus, sigh), and hardly ever interfers with anything!
Is someone wanted you could use:
> stty intr ^K # free Ctrl+C for copy use Ctrl+K instead > stty lnext ^- # free Ctrl+V for paste use ^- instead > stty -g > stty -g > ~/.stty # store the settings in home directory
Add the following to
case $- in *i*) stty `cat ~/.stty` # reload the stored stty settings bind -u quoted-insert # unbind the quoted-insert function of bash - free Ctrl+V for paste esac
And then gconf editor or somesuch to change terminals keybindings to CTRL+C for Copy and CTRL+V for paste.
in Lxterminal (default terminal in Lxde ), you can fully customize shortcuts:
As already stated, Ctrl-C won't work because of the interrupt usage, but I just figured out a way that worked for me. My goal was to have only two keys, not three, and preferably something I'm used to, and not in too inconvenient a place on the keyboard. The keyboard I have on my Linux box has a "Windows" key, in the same place as the Command key on a Mac. So I just went to Edit > Keyboard Shortcuts, when I changed the shortcuts to use this key, it says Super+C and Super+V. I sometimes use a Mac too, so this was easy to get used to.