LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-05-2010, 09:49 PM   #1
Mountain
Member
 
Registered: Nov 2007
Location: A place with no mountains
Distribution: Kubuntu, sidux, openSUSE
Posts: 214

Rep: Reputation: 41
change bash shortcut keys such as Ctrl-C?


I*am using Kubuntu 10.04. I would like to change some of the standard shortcut keys for bash (terminal).

I want:
Ctrl-C to copy the selected text to the clipboard.
Ctrl-V to paste from the clipboard into the terminal.
Ctrl-Z to undo.
Ctrl-Shift-C (or even better, Super-C) to terminate the command.
Ctrl-Shift-Z (or Super-Z) to be the background command.
I*don't even know what Ctrl-V did before, some I*won't worry about remapping it.

How do I*make these changes? Thanks.

EDIT:*I*have no idea what is putting the * char after each "I". Maybe this is a non-breaking space??? (I gotta stop blindly experimenting and get some proper advice!)

Last edited by Mountain; 07-05-2010 at 09:53 PM.
 
Old 07-05-2010, 11:05 PM   #2
GlennsPref
Senior Member
 
Registered: Apr 2004
Location: Brisbane, Australia
Distribution: Devuan
Posts: 3,654
Blog Entries: 33

Rep: Reputation: 283Reputation: 283Reputation: 283
Hi, this web page describes what, I think, you need to do.

http://ss64.com/bash/alias.html

There is also a link at the bottom of THIS page that may help too.

http://www.linuxquestions.org/questi...r-exit-554420/

I think /etc/bashrc and or /etc/inputrc

You may find that reinstalling bash easier.

Regards Glenn
 
Old 07-05-2010, 11:22 PM   #3
Mountain
Member
 
Registered: Nov 2007
Location: A place with no mountains
Distribution: Kubuntu, sidux, openSUSE
Posts: 214

Original Poster
Rep: Reputation: 41
Quote:
Originally Posted by GlennsPref View Post
Hi, this web page describes what, I think, you need to do.

http://ss64.com/bash/alias.html

There is also a link at the bottom of THIS page that may help too.

http://www.linuxquestions.org/questi...r-exit-554420/

I think /etc/bashrc and or /etc/inputrc

You may find that reinstalling bash easier.

Regards Glenn
The aliases option doesn't seem appropriate. I don't want to invoke a command. I want to remap key shortcuts.

The links at the bottom of THIS page include this one:
http://www.linuxquestions.org/questi...r-exit-554420/

I've read a bunch of articles like that. None (yet) show how to combine the shift key with the control key.
 
Old 07-05-2010, 11:46 PM   #4
Mountain
Member
 
Registered: Nov 2007
Location: A place with no mountains
Distribution: Kubuntu, sidux, openSUSE
Posts: 214

Original Poster
Rep: Reputation: 41
I found this post:
http://osdir.com/ml/shells.bash.bugs.../msg00039.html

Question: can shift key be used as modifier in .inputrc?

Answer: Only if it results in a different character returned by read(2).

My response: what the heck does that mean?
 
Old 07-05-2010, 11:49 PM   #5
Mountain
Member
 
Registered: Nov 2007
Location: A place with no mountains
Distribution: Kubuntu, sidux, openSUSE
Posts: 214

Original Poster
Rep: Reputation: 41
More info:
http://linuxgazette.net/issue55/henderson.html
Quote:
Things That Don't Work

Control-S, Control-Q, Control-C, and Control-Z are likely never to make it to Readline, being hijacked by the tty driver and acted on accordingly.
So, I'm still looking for an answer to my original question.
 
Old 07-06-2010, 12:22 AM   #6
GlennsPref
Senior Member
 
Registered: Apr 2004
Location: Brisbane, Australia
Distribution: Devuan
Posts: 3,654
Blog Entries: 33

Rep: Reputation: 283Reputation: 283Reputation: 283
sorry I can't help more.

I suggest reading Jerry Peek's "Wizard Bootcamp" series (this ten-part series)

Downloadable as html and .pdf

You may find them here...

http://www.jpeek.com/articles/linux_magazine.html

Cheers, and All the Best. Glenn
 
Old 07-06-2010, 03:31 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Ctrl-C to copy the selected text to the clipboard. Ctrl-V to paste from the clipboard into the terminal. Cannot be done by bash except possibly within readline. Generic copy and paste are functions of the terminal emulator.

Ctrl-Z to undo. Undo what?

Ctrl-Shift-C (or even better, Super-C) to terminate the command. Ctrl-Shift-Z (or Super-Z) to be the background command. May be possible with stty, perhaps in conjunction with a custom termcap or terminfo file

Last edited by catkin; 07-06-2010 at 03:31 AM. Reason: Prettification
 
Old 07-06-2010, 06:03 AM   #8
GlennsPref
Senior Member
 
Registered: Apr 2004
Location: Brisbane, Australia
Distribution: Devuan
Posts: 3,654
Blog Entries: 33

Rep: Reputation: 283Reputation: 283Reputation: 283
That is what I was thinking, but decided to not go that deep.
 
Old 07-06-2010, 07:37 AM   #9
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
I think that the OP's idea is a bad idea.

First of all, bash isn't aware of the GUI and it's features, like Copy/Paste.

Second, X has a convenient Copy/Paste feature that only uses the mouse, no menus or shortcut keys. Just select some text to copy it, and click the middle button to paste it. No right-click menus or shortcut keys.

And finally, most terminal emulators use Ctrl+Shift+C and Ctrl+Shift+V to copy/paste, to avoid conflicts with bash.
 
Old 07-06-2010, 11:30 AM   #10
Mountain
Member
 
Registered: Nov 2007
Location: A place with no mountains
Distribution: Kubuntu, sidux, openSUSE
Posts: 214

Original Poster
Rep: Reputation: 41
Quote:
Originally Posted by MTK358 View Post
I think that the OP's idea is a bad idea.
I was waiting for a lecture about this. I anticipated your reasoning already and I decided I do indeed wish to proceed with my plan if there is a way to do it.

BTW, in Mac OS X, there is a nice solution for this. OS X uses the command key (super) instead of Ctrl. Copying is done via command-C. And this exact keystroke copies text in the terminal too. I got my first Mac a few months ago and I found the consistency for copy/paste to be so attractive and useful to me that I decided to try to achieve the same thing on Linux.

On the Mac I have remapped the command key to the capslock key. On Linux I remapped Ctrl to capslock. Switching back and forth doesn't give me the jolt it used it. This system actually suits me well.

If I can get bash to use ctrl-c to copy and ctrl-v to paste, it will be perfect. I'd be really surprised if there is absolutely not a way to do this in Linux.
 
Old 07-06-2010, 11:48 AM   #11
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
You didn't read my above post carefully enough.

bash is not aware of GUI features like Copy and Paste. The terminal emulator (xterm, Konsole, etc.) is!
 
Old 07-06-2010, 12:11 PM   #12
Mountain
Member
 
Registered: Nov 2007
Location: A place with no mountains
Distribution: Kubuntu, sidux, openSUSE
Posts: 214

Original Poster
Rep: Reputation: 41
Quote:
Originally Posted by MTK358 View Post
You didn't read my above post carefully enough.

bash is not aware of GUI features like Copy and Paste. The terminal emulator (xterm, Konsole, etc.) is!
I did read that. However, that doesn't mean I understood how to solve my problem based on that info.

The fact of the matter is that I don't care whether the solution is done at the level of the shell or at the level of the terminal emulator or even at a higher level (or some combination of those).

I read the other reply that said:
Quote:
May be possible with stty, perhaps in conjunction with a custom termcap or terminfo file.
in reference to a part of my request.

EDIT: and I don't even really care if bash ever sees the actual ctrl-C or the other remapped shortcuts. I just want ctrl-C to do a copy of the selected text. I'll remap the actual terminate command to any key combination.

Last edited by Mountain; 07-06-2010 at 12:16 PM.
 
Old 07-06-2010, 12:31 PM   #13
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
In Konsole:
Attached Thumbnails
Click image for larger version

Name:	konsole-shortcuts.jpeg
Views:	527
Size:	65.5 KB
ID:	4048  
 
Old 07-06-2010, 12:41 PM   #14
Mountain
Member
 
Registered: Nov 2007
Location: A place with no mountains
Distribution: Kubuntu, sidux, openSUSE
Posts: 214

Original Poster
Rep: Reputation: 41
Quote:
Originally Posted by MTK358 View Post
In Konsole:
Thank you! I had no idea it could be so simple! That accomplishes most of what I wanted to do.

Now I just need to do the replacement for the terminate command. Catkin said

Quote:
May be possible with stty, perhaps in conjunction with a custom termcap or terminfo file
I started by looking at man stty... not helpful.

EDIT: this seems a bit more helpful. Clearly I should be able to change the setting so that intr=^K for example.

Code:
$ stty -a
speed 38400 baud; rows 50; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon ixoff
-iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke

Last edited by Mountain; 07-06-2010 at 12:46 PM. Reason: added stty-a output
 
Old 07-06-2010, 12:54 PM   #15
Mountain
Member
 
Registered: Nov 2007
Location: A place with no mountains
Distribution: Kubuntu, sidux, openSUSE
Posts: 214

Original Poster
Rep: Reputation: 41
Any experts want to tell me if this is the solution?

$ stty intr \^k
$ stty -a
speed 38400 baud; rows 50; columns 80; line = 0;
intr = ^K; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon ixoff
-iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke

EDIT: it seems to be working. I tested with a find command that would have taken a long time to finish and I was able to terminate it with ^K instead of ^C. The copy/paste commands definitely do work. I was already using those to copy the output of stty -a and paste here.

Last edited by Mountain; 07-06-2010 at 01:18 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
VLC ctrl+H minimal view shortcut is not working wanas Linux - Software 0 08-11-2009 01:21 AM
mouse keys as modifier keys (ctrl & alt) belda Linux - Desktop 3 06-25-2009 10:37 AM
Any way to create bash short cuts (like CTRL+l for clear and Ctrl+D for exit) supersubu123 Linux - General 5 05-30-2007 03:02 AM
Keyboard and it's shortcut keys ZakuSage Linux - Hardware 4 06-13-2005 02:11 PM
Disabling KDE3.1 Konsole shortcut (CTRL+T) pablob Mandriva 2 09-14-2003 06:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration