DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 11th December 2008
taylor_venable taylor_venable is offline
Real Name: Taylor Venable
Security Programmer
 
Join Date: Jun 2008
Location: Indiana, USA
Posts: 6
Default xterm + bash: Make <DEL> delete char under cursor

I've been toying with this since I put 4.4 on my laptop. I like to use xterm and bash; with this combination I cannot get <BS> to delete the previous character and <DEL> to delete the current one, the behaviour in most apps nowadays. Here's some information, hopefully somebody can help:
  • Typing <CTRL>-V <BS> and <CTRL>-V <DEL> both yield "^?" so bash sees them as the same key.
  • xev shows they are distinct, namely (keycode 22 / BackSpace) and (keycode 107 / Delete).
  • The readline binding of \C-? is backward-delete-char. In my .inputrc I have these definitions:
    Code:
    "^?" : delete-char
    "\C-h" : delete-char
    "\C-?" : delete-char
    In some vain attempt to get <DEL> to do delete-char but to no avail. After doing bind -f .inputrc (even though it is definitely loaded when bash starts), bind -p | grep delete shows that \C-? is still bound to backward-delete-char.
  • I can do bind '^?=delete-char-forward' in ksh, after which both <DEL> and <BS> delete the current char, but this is still a problem since I want them to be different. Probably related to the first point above.
__________________
How many shells could Shell sort sort if Shell sort could sort shells?
Reply With Quote
  #2   (View Single Post)  
Old 11th December 2008
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
 
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 1,027
Default

In my ~/.Xresources file I have mapped the Delete keys to a string:

Code:
*VT100.Translations: #override \
              !<Key>BackSpace:    string(0x7F) \n\
              !<Key>KP_Begin:     string(0x1b) string("[25~") \n\
              !<Key>Home:         string(0x1b) string("[7~") \n\
              !<Key>KP_Home:      string(0x1b) string("[7~") \n\
              <Key>Insert:        string(0x1b) string("[2~") \n\
              !<Key>KP_Insert:    string(0x1b) string("[2~") \n\
              <Key>Delete:        string(0x1b) string("[3~") \n\
              !<Key>KP_Delete:    string(0x1b) string("[3~") \n\
...(etc.)...
Note the last two lines especially. Then, in my ~/.inputrc I use that string:

Code:
"\e[3~": delete-char        # Delete
I hope that can get you started on what you want to do. (BTW, thanks for the tip about Ctrl-V, didn't know about that.)
Reply With Quote
  #3   (View Single Post)  
Old 11th December 2008
taylor_venable taylor_venable is offline
Real Name: Taylor Venable
Security Programmer
 
Join Date: Jun 2008
Location: Indiana, USA
Posts: 6
Default

Awesome! That was exactly what I was looking for, thanks much!

Yes, the ^V trick is pretty useful; it comes from vi so you can use it there also to insert a character literally; especially nice when typing e.g. sed patterns with tabs and newlines in them.
__________________
How many shells could Shell sort sort if Shell sort could sort shells?
Reply With Quote
  #4   (View Single Post)  
Old 11th December 2008
zzak zzak is offline
Real Name: Ed Perchyshyn
New User
 
Join Date: Dec 2008
Location: Canada
Posts: 2
Default

In my Slackware partition, and in my home directory's .bashrc file,
I have the following entry, among others:

# Make sure the backspace key erases:
stty erase "^H"
Reply With Quote
  #5   (View Single Post)  
Old 11th December 2008
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Default

Take a look at the output of stty all:

Code:
Terry@vectra$ stty all
speed 38400 baud; 24 rows; 80 columns;
lflags: icanon isig iexten echo echoe -echok echoke -echonl echoctl
        -echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo
        -extproc -xcase
iflags: -istrip icrnl -inlcr -igncr -iuclc ixon -ixoff ixany imaxbel
        -ignbrk brkint -inpck -ignpar -parmrk
oflags: opost onlcr -ocrnl -onocr -onlret -olcuc oxtabs -onoeot
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -mdmbuf
discard dsusp   eof     eol     eol2    erase   intr    kill    lnext
^O      ^Y      ^D      <undef> <undef> ^?      ^C      ^U      ^V
min     quit    reprint start   status  stop    susp    time    werase
1       ^\      ^R      ^Q      <undef> ^S      ^Z      0       ^W
Terry@vectra$
^V gives a literal next character, so it should work fairly well around in various shells; you can even remap it. No clue if the classic vi used ^V irregardless or obeyed lnest, since it kind of pre-dates curses lol.
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
  #6   (View Single Post)  
Old 12th December 2008
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
 
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 1,027
Default

Quote:
Originally Posted by zzak View Post
In my Slackware partition, and in my home directory's .bashrc file,
I have the following entry, among others:

# Make sure the backspace key erases:
stty erase "^H"
I have that also, but put it in ~/.bash_profile, on the assumption that it's only needed for interactive shells. Also the double quotes around "^H" aren't needed (nice to keep things clean and simple ).
Reply With Quote
  #7   (View Single Post)  
Old 12th December 2008
zzak zzak is offline
Real Name: Ed Perchyshyn
New User
 
Join Date: Dec 2008
Location: Canada
Posts: 2
Default

I was wondering where I got it from.

Running Linux, 3rd Edition, Welsh, Dalheimer and Kaufman.
page 117

They also mentions .bash_profile

"For the bash shell. Another shell script. The difference between this script and
.bashrc is that .bash_profile runs only when you log in. It was originally designed
so you could separate interactive shells from those run by background processes like
cron. But it is not too useful on modern computers with the X Window System, because
when you open a new xterm window, only .bashrc runs. If you start up a windown with
the command xterm -ls, it will run .bash_profile too."

Sorry about the Linux stuff. For information only.
Reply With Quote
  #8   (View Single Post)  
Old 13th December 2008
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
 
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 1,027
Default

Yea, it definitely depends on how you like to set things up. I use the -ls flag with all xterm's, to make them more like my consoles. Because I do like to use the console as much as possible (most days, this lasts about 10 minutes before throwing in the towel and typing "startx", lol).
Reply With Quote
Reply

Tags
<bs> key, <del> key

Thread Tools
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
xterm color does not behave properly. pieterverberne OpenBSD General 2 19th August 2009 05:17 PM
Changing shell to bash rex FreeBSD General 13 29th August 2008 03:20 AM
xterm End key graudeejs General software and network 1 24th August 2008 04:55 PM
Is bash included in OpenBSD? bsdnewbie999 OpenBSD General 21 2nd August 2008 02:57 AM
How add additional features on xterm ( Xfce ) ? aleunix OpenBSD Packages and Ports 4 5th June 2008 02:18 PM


All times are GMT. The time now is 08:53 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick