Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.)

share|improve this question
1  
You don't have to use the mouse; on a Mac keyboard you can use shift+enter+fn. And, on a 'normal' keyboard, I think it's shift and insert. – David Thomas Sep 25 '11 at 21:16

7 Answers

up vote 28 down vote accepted

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.

share|improve this answer

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...

share|improve this answer
11  
Rather than saying that those keybindings have other specific meanings in the terminal, it is probably more correct to say that various console applications expect to be able to use them, so if the terminal emulator didn't pass them on it might make those apps unusable. – James Henstridge Sep 26 '11 at 0:28

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:

  • selecting text with mouse copies it to clipboard
  • middle-click pastes it.

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.

share|improve this answer
1  
Thanks, very useful tip. – Blue Pony Inc. Sep 30 '11 at 9:49

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.

share|improve this answer

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

  • Ctrl+Ins for copying
  • Shift+Ins for pasting

This works practically everywhere (except in Nautilus, sigh), and hardly ever interfers with anything!

share|improve this answer

I think that you cannot because in gnome terminal Ctrl+C, Ctrl+X, Ctrl+V do not work. For cutting, copying and pasting you have to highlight the text, right click and choose the action you want to do

share|improve this answer
you still can you use short cuts to cut in the terminal these are ctrl+shift+c (copy) and ctrl+shift+v (paste) and ctrl+shift+x. – Rens Jul 19 '11 at 7:16

Just use Ctrl+Shift+C for copy.

share|improve this answer
   
This does work... – davbren Jul 21 '11 at 14:30
Doesn't respond the question. – Rafael Vega May 21 '12 at 19:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.