LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-18-2003, 06:03 PM   #1
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
I need help changing bash keybindings


I wanted to change the key bindings for command line editing. It defaults to emacs and I was thinking I preferred vim. I managed that by editing inputrc but got some weird results I can't quite recall clearly enough to describe. And I wanted to extend the remapping by changing the home and end keys to, um, act like "home" and "end" keys - instead of being in command mode and doing "0" or Ctrl-E and so on. But that part didn't work at all. I looked up man/info first, before failing. Then I came here and searched but didn't turn up anything relevant. (I suck at search engines and it drives me nuts when people tell me to search - I understand that, but I just suck at it. I get no results or a billion. I tried "bash AND bind" this time, as well as some vim key-related searches.)

I just need "home" and "end" to act like I want them in case I get confused or flustered on the command line and need to edit it. I still forget key combos at important times at this point. So any help on the specifics or any clarification of the whole concept of key bindings would be great. It's dumb, because it's not like I can't move around a zillion other ways, but...

In case it matters, I'm, um, using Caldera OpenLinux 2.3 and bash 1.14 (iirc) on an IBM 350-P100.
 
Old 02-18-2003, 06:28 PM   #2
nxny
Member
 
Registered: May 2002
Location: AK - The last frontier.
Distribution: Red Hat 8.0, Slackware 8.1, Knoppix 3.7, Lunar 1.3, Sorcerer
Posts: 771

Rep: Reputation: 30
Bash looks up the value of the EDITOR env variable to see what keybindings it should use. I export it systemwide in /etc/profile
Code:
export EDITOR=vi
 
Old 02-18-2003, 06:49 PM   #3
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Original Poster
Rep: Reputation: Disabled
Thanks for replying. But I checked that and the variable wasn't listed one way or the other. It was inputrc that had a few specifications in it. So I just edited inputrc directly. Do I need to do both or do the variable in favor of inputrc? And like I say, I got that much of it working, more or less - it just didn't seem perfectly mapped to vim, but it *was* "vim-ish" so to speak. *g* But that still wouldn't help me with the home/end thing would it? I think did something like

home:beginning-of-line
end:end-of-line

in inputrc. Is that the wrong stuff - I think that's what the man pages said to do. Or do those keys have some special representation like ^ and so on and I should use that in place of the key name?

Crap. I've got to go hit the tube now, but I'll be back and try to post what my inputrc is and what I did to it. Should have done that first, but was being stupid.
 
Old 02-18-2003, 07:28 PM   #4
nxny
Member
 
Registered: May 2002
Location: AK - The last frontier.
Distribution: Red Hat 8.0, Slackware 8.1, Knoppix 3.7, Lunar 1.3, Sorcerer
Posts: 771

Rep: Reputation: 30
Nope, that's the EDITOR variable is pretty much all you need. Unless you want to customize on top of the vim bindings.

I wonder if anybody else who digs vi(m) uses the home/end keys at all. To me, half the beauty of vi lies in the fact that you dont need to move your hand to reach out for the arrows/insert/del/home keys and what not. So it lets me concentrate on the main area of the keyboard and forget about the rest. Of special mention in laptops because the extra keys ( as I call them) have non-standard locations with different brands/models . (I use '0' and '$' to get where to 'Home' and 'end' respectively)

HTH
 
Old 02-18-2003, 09:50 PM   #5
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Original Poster
Rep: Reputation: Disabled
Well, customizing on top is what I had in mind. I dunno - you're right about the vim bindings but, as it is, home and end don't do anything except produce a beep and a garbage character - kinda wasteful - and I can't think of anything better for them to be doing than being home and end keys. *g*

I do dig vim but it's a theoretical digging at this point - I'm still getting used to the keybindings and they don't come naturally to me yet, though I see the advantage. When I'm busily doing disastrous stuff on the command line my impulse is still to go to the usual keys and my impulse will be to go to the vim keys. So I wanted both so that if I was just wanting to fix bash screwups and not learn vim at the same time, I could fix stuff without garbaging the lines more but the vim keys would be there when I was just casually poking about and learning the stuff. I dunno - guess I'll forget about it.

I dunno why remembering the damn keys is so hard - just need to learn them, I guess. It's not so much that substituting home and end is so hard, obviously, but there's a thousand keys in dozens of programs and I'm just kind of swamped.

Thanks for taking the time.
 
Old 02-19-2003, 07:23 PM   #6
nxny
Member
 
Registered: May 2002
Location: AK - The last frontier.
Distribution: Red Hat 8.0, Slackware 8.1, Knoppix 3.7, Lunar 1.3, Sorcerer
Posts: 771

Rep: Reputation: 30
I have never felt the need, but if you want to customize, I suggest reading the readline man page.

I must've been out of my mind to suggest the EDITOR env variable. Jeez! To set the vi mode, what I meant was
Code:
set -o vi
in your .profile or /etc/profile for systemwide. Slip of tongue, sorry.

oh, and with my system ( in vi mode ) the 'home' and 'end' keys work just the way you want it so you may not want to customize after all.

Last edited by nxny; 02-19-2003 at 07:25 PM.
 
Old 02-20-2003, 03:59 AM   #7
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Original Poster
Rep: Reputation: Disabled
Okay, thanks. I'll look into that.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
changing bash resolution mlu Linux - Software 3 05-01-2005 09:18 PM
Changing Bash Prompt socks Slackware 11 02-09-2005 06:32 PM
Changing the BASH Prompt Blade_Powers Linux - Newbie 4 03-28-2004 09:21 PM
Changing the BASH promt Blade_Powers General 2 03-28-2004 07:34 PM
changing bash jackcy Linux - Newbie 2 03-21-2002 10:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:18 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration