LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   "Insert" & "Delete" key returns "~" in a terminal. (http://www.linuxquestions.org/questions/linux-general-1/insert-and-delete-key-returns-%7E-in-a-terminal-876401/)

sharky 04-21-2011 03:17 PM

"Insert" & "Delete" key returns "~" in a terminal.
 
This is making me nuts because I do a lot of command line stuff.

In a terminal, any terminal (I've tried konsole and xterm), pressing the "Insert" or "Delete" key returns a tilde "~" character. This only happens in my account. If I log in to a different account, in the same terminal, the delete key actually deletes characters and makes editing of commands much easier. I have no idea why it behaves in other accounts and not mine. The dot files are all identical.

For a while this was happening with the "Home", "End", and "Page Up/Down" keys. I blew away my .kde directory and it fixed all except the "Delete" and "Insert" keys. I don't really care about the "Insert" key but I really need "Delete" to function as a delete.

PhoenixAndThor 04-21-2011 04:14 PM

Need more information
 
I have experienced similar problems like this, but first, please be clear about which desktop (KDE 3.x, KDE 4.x, etc) you are using, what distribution you are running (Debian, Fedora, etc), and what kind of system you are having the problem on (desktop, laptop, other?).

Sometimes it could be the keyboard you are using. Try switching out keyboards (unless you are on a laptop).

Telengard 04-21-2011 04:57 PM

Until you figure out a solution here are some work-arounds you may find useful.

Ctrl+D = delete character under cursor
Alt+D = delete from cursor to end of word
Ctrl+K = kill from cursor to end of line
Ctrl+u = kill from cursor to start of line
Ctrl+_ = undo last deletion
Ctrl+Y = replace last killed text

Many more exist.

impert 04-21-2011 05:27 PM

Quote:

This only happens in my account. If I log in to a different account, in the same terminal, the delete key actually deletes characters and makes editing of commands much easier. I have no idea why it behaves in other accounts and not mine. The dot files are all identical.
Why not make a new user and either work from that account or copy whatever you cherish to that account, delete your own account, re-make your own account, and copy all your files back.

PhoenixAndThor 04-21-2011 07:00 PM

Thnx Telengard, I didn't know about those keybindings. And impert, I think thats exactly what we want to avoid, but it will still wok.

impert 04-22-2011 05:06 AM

Quote:

And impert, I think thats exactly what we want to avoid, but it will still wok.
To me it just seems like the easiest way, but whatever.
Surely if it's not happening in the other accounts, it's got to be to do with a dot file in the account where he has the trouble?

PhoenixAndThor 04-23-2011 12:26 AM

True. Another thing, why is the "dot-hierarchy" in a typical user's home folder so complicated? When problem like this one occurs, I sometimes spend hours trying to find the culprit. It's a good thing I always back up everything.

KDHofAvalon 04-23-2011 12:11 PM

I had a problem like this just recently with my laptop, the Home and End keys were inserting tildes in the terminal. Theres a simple way to fix it though, assuming it's actually the same problem. First, post the contents of your /etc/inputrc and (if it exists) ~/.inputrc for the account having the problem, then run
Code:

cat
in a terminal exactly like I wrote it there, without any parameters. Now press delete, then enter, then insert, then CTRL+D twice and post the output of that as well. If it's the same problem I was having we'll have it fixed in no time.

sharky 04-25-2011 10:29 AM

Quote:

Originally Posted by KDHofAvalon (Post 4333715)
I had a problem like this just recently with my laptop, the Home and End keys were inserting tildes in the terminal. Theres a simple way to fix it though, assuming it's actually the same problem. First, post the contents of your /etc/inputrc and (if it exists) ~/.inputrc for the account having the problem, then run
Code:

cat
in a terminal exactly like I wrote it there, without any parameters. Now press delete, then enter, then insert, then CTRL+D twice and post the output of that as well. If it's the same problem I was having we'll have it fixed in no time.

That's it. I removed ~/.inputrc and it fixed the problem! thx,

TobiSGD 04-25-2011 02:45 PM

@KDHofAvalon: I have exactly the same problem on Slackware -current with zsh. But I don't have ~/.inputrc. Would you be so kind to share your solution, so that I can try if that helps?

KDHofAvalon 04-26-2011 12:57 AM

@Sharky: You're quite welcome.

@TobiSGD: Certainly. Slackware's where I had the problem as well.

You should have an '/etc/inputrc' file, even without one in ~, since Slackware installs it by default. DO NOT delete this file as it's referenced at least two times in other default Slackware scripts, once in '/etc/profile' and again... I forget the other one at the moment, sorry.

Anyway the file lists the wrong symbols for the keys that are misbehaving, so you're going to have to edit it. Use my instructions for 'cat' in my last post and press the misbehaving keys one at a time. The result will look something like this:
Code:

^[[8~
And a sample from my '/etc/inputrc':
Code:

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

Simply replace the number of the proper function with the one you got with 'cat' and you're done.

Hope that helps.

PhoenixAndThor 04-26-2011 01:47 AM

Wow, I'm bookmarking this. Even though I've never had a problem like this, I am thinking about trying Slackware soon and this is exactly the kind of info I need.

TobiSGD 04-26-2011 06:07 AM

Thanks for your explanation, but sadly, that didn't help me.
This is the content of my /etc/inputrc:
Code:

# /etc/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 xterm
"\eOH": beginning-of-line
"\eOF": end-of-line



# for freebsd console
"\e[H": beginning-of-line
"\e[F": end-of-line

These keys (with the code the cat command gives) are not working for me in the console, regardless of it is a xterm or a virtual console.
Code:

Delete:      ^[[3~
Insert:      ^[[2~
Page up:      ^[[5~
Page down:    ^[[6~
Home:        ^[OH    on virtual console this is ^[[1~
End:          ^[OF    on virtual console this is ^[[4~

I am somewhat lost here, because the keys I press are the same that are mentioned in the inputrc, but it is not working.

KDHofAvalon 04-26-2011 07:30 AM

Okay I just realized the problem. I use bash while you use zsh, which apparently doesn't read '/etc/inputrc'. Alright, then we'll have to convert the key definitions for bindkey and put them in your ~/.zshrc, easy enough just put bindkey at the start and get rid of the colon. Or if you prefer here's a sed one-liner to get them into the right format:
Code:

sed -n 's/^/bindkey /; s/: / /p' /etc/inputrc
Sorry about that, I've never used zsh extensively.

TobiSGD 04-26-2011 07:37 AM

That works, thanks for your help.


All times are GMT -5. The time now is 05:23 AM.