LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 04-22-2010, 07:03 PM   #1
Josh000
Member
 
Registered: Aug 2009
Distribution: Slackware 13 64bit
Posts: 534

Rep: Reputation: 35
Home and End keys in a terminal


I am having trouble using home and end keys in a terminal, to go to the end or beginning of a line.

With xterm it will only work with the bash shell, while under zsh nothing is output.

With urxvt, mrxvt and aterm pressing the keys in either bash or zsh always just results in a tilde being printed.

Is this perhaps because urxvt, aterm and mrxvt are emulating a different terminal type to xterm by default?

Why does xterm work for bash but not for zsh?

I don't just want a solution, I want to understand why it doesn't work by default.

Thankyou

P.S. As a side question, is there any way to press alt+enter within a terminal? I tried to use wicd-curses where you have to use alt+enter to save settings, and it didnt register in any of the terminals, even xterm.

Last edited by Josh000; 04-22-2010 at 07:04 PM.
 
Old 04-22-2010, 09:14 PM   #2
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,367

Rep: Reputation: 838Reputation: 838Reputation: 838Reputation: 838Reputation: 838Reputation: 838Reputation: 838
~/.inputrc
Code:
# /etc/inputrc - ~/.inputrc
# This file configures keyboard input for programs using readline.
# See "man 3 readline" for more examples.

# Configure the system bell.  Options are none, visible, and audible.
#set bell-style none

# Enable 8 bit input.
set meta-flag On
set input-meta On
set convert-meta Off
set output-meta On

# Set various nice escape sequences:
"\eOd": backward-word
"\eOc": forward-word

# for linux console
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert

# for rxvt                     #added
"\e[7~": beginning-of-line      
"\e[8~": end-of-line           

# for xterm
"\eOH": beginning-of-line
"\eOF": end-of-line

# for freebsd console
"\e[H": beginning-of-line
"\e[F": end-of-line
Compare that with /etc/inputrc. Also, throw
Code:
export INPUTRC=~/.inputrc
into ~/.bashrc (and log out and back in, or `. .bashrc` to source .bashrc in your current terminal without logging out+back in).

I believe this has to do with terminfo settings being incorrect for the specified terminal but I am no expert on the matter.
 
Old 04-22-2010, 10:35 PM   #3
Josh000
Member
 
Registered: Aug 2009
Distribution: Slackware 13 64bit
Posts: 534

Original Poster
Rep: Reputation: 35
Interesting.

Why does it work for root by default but not for a normal user in xterm?

Given that root or the normal user has no |/.inputrc, root must be reading from a system file but why does the normal user fail to do so?

Also in the non-xterm terminals it fails to work compeltely?

It doesn't seem like so much an inputrc problem as the terminals emulating the wrong terminal type perhaps?
 
Old 04-22-2010, 11:06 PM   #4
sahko
Senior Member
 
Registered: Sep 2008
Distribution: Slackware
Posts: 1,041

Rep: Reputation: Disabled
Quote:
Originally Posted by Josh000 View Post
P.S. As a side question, is there any way to press alt+enter within a terminal? I tried to use wicd-curses where you have to use alt+enter to save settings, and it didnt register in any of the terminals, even xterm.
http://wicd.sourceforge.net/moinmoin/FAQ
 
Old 04-23-2010, 01:53 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,577
Blog Entries: 31

Rep: Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196
Quote:
Originally Posted by Josh000 View Post
Why does it work for root by default but not for a normal user in xterm?

Given that root or the normal user has no |/.inputrc, root must be reading from a system file but why does the normal user fail to do so?
From the readline (3) man page:

Code:
INITIALIZATION FILE
       Readline  is  customized  by  putting commands in an initialization file (the inputrc file).  The name of this file is taken from the
       value of the INPUTRC environment variable.  If that variable is unset, the default is ~/.inputrc.  If that file  does  not  exist  or
       cannot  be  read,  the  ultimate default is /etc/inputrc.
Perhaps the/root's shell initialisation files set $INPUTRC or, more likely, there's a ~root/.inputrc file.

Alternatively other users may have .inputrc files while root defaults to using /etc/inputrc.
 
Old 04-23-2010, 01:35 PM   #6
Josh000
Member
 
Registered: Aug 2009
Distribution: Slackware 13 64bit
Posts: 534

Original Poster
Rep: Reputation: 35
Quote:
Originally Posted by catkin View Post
From the readline (3) man page:

Code:
INITIALIZATION FILE
       Readline  is  customized  by  putting commands in an initialization file (the inputrc file).  The name of this file is taken from the
       value of the INPUTRC environment variable.  If that variable is unset, the default is ~/.inputrc.  If that file  does  not  exist  or
       cannot  be  read,  the  ultimate default is /etc/inputrc.
Perhaps the/root's shell initialisation files set $INPUTRC or, more likely, there's a ~root/.inputrc file.

Alternatively other users may have .inputrc files while root defaults to using /etc/inputrc.

OK, both root and ~user definitly do not have an ~/.inputrc

Both root and user have $INPUTRC set to /etc/profile

Home and end keys etc only work for root, not user

They still do not work under urxvt, mrxvt or aterm, so this is not limited to a readline issue.
 
Old 04-23-2010, 04:33 PM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,577
Blog Entries: 31

Rep: Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196
Quote:
Originally Posted by Josh000 View Post
Both root and user have $INPUTRC set to /etc/profile
Is that a typo for /etc/inputrc?
 
Old 04-23-2010, 06:21 PM   #8
Josh000
Member
 
Registered: Aug 2009
Distribution: Slackware 13 64bit
Posts: 534

Original Poster
Rep: Reputation: 35
Quote:
Originally Posted by catkin View Post
Is that a typo for /etc/inputrc?
Oops, yes it certainly is.

So root and user both have the same inputrc info, and it doesn't work for the non xterm terminals regardless. (although that is most likely related to my other problem with them not having a proper termcap setup)
 
Old 04-24-2010, 06:54 AM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,577
Blog Entries: 31

Rep: Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196Reputation: 1196
There are a lot of variable factors here: root/user, bash/zsh and urxvt/mrxvt/aterm (and virtual terminal?). Presumably all the terminal types except virtual are running under X so X key mapping may also be playing a part. In the absence of any replies leading toward a solution, do you mind me exploring this with you? Unfortunately I don't have zsh, urxvt or aterm but I do have mrxvt and the End key does work. I, too, am interested in finding out how these things should work.
 
Old 04-24-2010, 11:25 AM   #10
imitheos
Member
 
Registered: May 2005
Location: Greece
Posts: 433

Rep: Reputation: 116Reputation: 116
Didn't we discuss the same thing in this thread ?
http://www.linuxquestions.org/questi...stions-777809/

bash uses the readline settings in /etc/inputrc so xterm+bash works fine.
zsh doesn't use readline. You need to bind the keys to specific actions
using "bindkey".
 
Old 04-24-2010, 11:41 AM   #11
Josh000
Member
 
Registered: Aug 2009
Distribution: Slackware 13 64bit
Posts: 534

Original Poster
Rep: Reputation: 35
Quote:
Originally Posted by catkin View Post
There are a lot of variable factors here: root/user, bash/zsh and urxvt/mrxvt/aterm (and virtual terminal?). Presumably all the terminal types except virtual are running under X so X key mapping may also be playing a part. In the absence of any replies leading toward a solution, do you mind me exploring this with you? Unfortunately I don't have zsh, urxvt or aterm but I do have mrxvt and the End key does work. I, too, am interested in finding out how these things should work.
I would be happy if you would help me in exploring different things to try and work it out.

OK, pointed out xterm and bash works fine. The reason user wasn't working was because it was zsh...when I went to bash it worked fine. I can't believe I didn't think to try that....yoi.

Now, with bash and aterm/mrxvt/urxvt for user or root, and inputrc definitely set the home and end keys do not work, which means it is definitly a terminal problem.

My theroy is that much like why I could not get the screen to refresh properly, it is related to them not using terminfo but termcap, and termcap not having the right entries.

If I set TERM=xterm then vi and refreshing works, however doing so doesn't allow the home and end keys to work. When you launch mrxvt, what is TERM set to?

Quote:
Originally Posted by imitheos View Post
Didn't we discuss the same thing in this thread ?
http://www.linuxquestions.org/questi...stions-777809/

bash uses the readline settings in /etc/inputrc so xterm+bash works fine.
zsh doesn't use readline. You need to bind the keys to specific actions
using "bindkey".
I asked a few different questions in that thread, and had not thought that this had been answered.

Indeed, xterm+bash works fine, but any other and bash I still get a tilde instead, so this doesn't seem to be a shell problem but a terminal problem.


edit: OK, I just did some tests. Each of the terminals output different codes for home and end.

for home:

xterm: ^[[H
urxvt: ^[[7^
mrxvt: ^[[7^
aterm: ^[[7^

for end:

xterm: ^[[F
urxvt: ^[[8^
mrxvt: ^[[8^
aterm: ^[[8^

So interesting, They all act the same(incorrectly) except for xterm. This is more than likely related to them not using the terminfo databases, and there being no proper entry for them in termcap. I would like to get them to use the terminfo info rather than hack in entries to termcap.

catkin, what key codes do you get in mrxvt if home and end work for you, and what is TERM set to?

Last edited by Josh000; 04-24-2010 at 12:11 PM.
 
Old 04-24-2010, 03:44 PM   #12
Josh000
Member
 
Registered: Aug 2009
Distribution: Slackware 13 64bit
Posts: 534

Original Poster
Rep: Reputation: 35
OK, I got urxvt somewhat working after adding a termcap entry, however using bash only home works, not the end key.

I have the urxvt termcap entry and things mostly work fine, I have bash and INPUTRC is set to /etc/inputrc, so what could be the issue?

This is actually quite strange because even with the termcap entry urxvt still uses ^[[7^ for the home key and ^[[8^ for the end key, however only the home key registers....

edit: OK, the reason is that urxvt still uses ^[[7^ and ^[[8^ for home and end, and inputrc does not have this defined. I am unsure why home works and end doesnt and wonder if anyone would have a suggestion for why this is?

In any event, I added
Code:
"\e[8": end-of-line
to the end of /etc/inputrc and now the endkey works in that it goes to the end of the line, but it also outputs a tilde. Is there any way to remove the tilde output?

edit2: OK, I have it working I just had to change \e[8 to \e[8~

Last edited by Josh000; 04-24-2010 at 05:37 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
OpenBSD 3.8 Home/End Keys Misbehaving taylor_venable *BSD 15 08-31-2006 11:30 AM
Home / End keys in aterm Vgui Linux - General 4 08-11-2005 12:59 PM
Home/End keys don't work Abdul Linux - Software 2 07-25-2005 08:48 PM
home, delete, end keys problem in vi bujecas Slackware 10 01-12-2005 02:32 PM
Home and End keys in RXVT kevmccor Slackware 3 12-16-2004 04:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 08:56 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