stty erase ^? doesn't work

Discussion in 'General' started by krnlpk, Sep 12, 2010.

  1. krnlpk

    krnlpk Member

    Messages:
    31
    Thanks Received:
    0
    I'm trying to use
    Code:
    stty erase "^?"
    to change the behavior of the delete key.
    Both Backspace and Del are working as backspace, and I find this quite annoying.
    But, after executing stty as written above, I just get a backspace command that prints "^H" instead that "^h", and a del key that acts as backspace. If I use csh instead of bash, simply nothing happens. What can I do?
     
  2. wblock@

    wblock@ Administrator Staff Member Administrator Moderator Developer

    Messages:
    13,856
    Thanks Received:
    3,553
    What shell are you using?
     
  3. krnlpk

    krnlpk Member

    Messages:
    31
    Thanks Received:
    0
    Bash, at the moment, but either on csh stty seems to not work.
     
  4. wblock@

    wblock@ Administrator Staff Member Administrator Moderator Developer

    Messages:
    13,856
    Thanks Received:
    3,553
    It may also depend on your terminal. For instance, xfce's Terminal has Edit/Preferences/Advanced "Backspace generates" options.

    Otherwise, Consistent BackSpace and Delete Configuration is useful.
     
  5. krnlpk

    krnlpk Member

    Messages:
    31
    Thanks Received:
    0
    stty doesn't work. Either bind. If I try to set something, the only thing I succeed in is corrupting backspace.
     
  6. Beastie

    Beastie Daemon

    Messages:
    2,079
    Thanks Received:
    416
    For csh, add bindkey ^[[3~ delete-char to .cshrc.
     
  7. krnlpk

    krnlpk Member

    Messages:
    31
    Thanks Received:
    0
    It doesn't work. My shell (bash, csh, whatever) refuses to bind anything else than ^H to delete key.
     
  8. wblock@

    wblock@ Administrator Staff Member Administrator Moderator Developer

    Messages:
    13,856
    Thanks Received:
    3,553
    Oops--I meant to say "Delete key generates" above, about Terminal. What terminal are you using?
     
  9. krnlpk

    krnlpk Member

    Messages:
    31
    Thanks Received:
    0
    None. I'm using real ttys, I've not installed X.
     
  10. AndyUKG

    AndyUKG Well-Known Member

    Messages:
    456
    Thanks Received:
    22
    Firstly, if you currently have multiple keys working as backspace, what makes you think setting another (or resetting one of the existing keys) will stop one or other from being backspace? Maybe it will, I dont have mutiple keys working as backspace to test against but not convinced.
    Secondly, are you using the carrot key "^" when you enter the stty erase command? This needs to be entered not using the carrot key as you find it on they keyboard, but simply by pressing the backspace or whichever key you want. You may have to first type Ctrl+v then type the key you are after, Ctrl+v escapes special keys.
    IE on one of my systems backspace is "^?", which is written in a terminal window if I first type Ctrl+v then backspace...

    thanks Andy.
     
  11. krnlpk

    krnlpk Member

    Messages:
    31
    Thanks Received:
    0
    Even if I try to use ctrl-v, every tentative to set an alternative behavior to del key fails.
     
  12. SirDice

    SirDice Administrator Staff Member Administrator Moderator

    Messages:
    25,254
    Thanks Received:
    5,283
    Remove the quotes.

    # stty erase ^?

    Instead of typing shift-6 (on a US keyboard) and ? press the backspace key.

    Works as it should. But you should not need to change it. It's set correctly by default. Same for home and end keys.
     
  13. krnlpk

    krnlpk Member

    Messages:
    31
    Thanks Received:
    0
    I've already done it, it just do nothing!
    When I press backspace I expect that the character on the left of the cursor will be deleted, and the right one when I press Del. In both cases, the left char is the one to be deleted, even if I try to set other values for erase or erase2, the only results I managed to get are a corrupted backspace key and a delete key that works as before.
    I don't know why, nobody of you have ever get this behavior before?
     
  14. SirDice

    SirDice Administrator Staff Member Administrator Moderator

    Messages:
    25,254
    Thanks Received:
    5,283
    The delete key doesn't do what you expect it to do. In traditional unix the delete key acted as backspace (backspace didn't exist).

    Learn to use ctrl-d.
     
  15. krnlpk

    krnlpk Member

    Messages:
    31
    Thanks Received:
    0
    So, there's no way to change its behavior?
     
  16. SirDice

    SirDice Administrator Staff Member Administrator Moderator

    Messages:
    25,254
    Thanks Received:
    5,283
    Beastie's solution seems to work. At least for tcsh.
     
  17. krnlpk

    krnlpk Member

    Messages:
    31
    Thanks Received:
    0
    I've already tried it but it haven't worked for me. Thanks a lot to everybody for the patience :)