In bash, the home/end/delete key is inserting a tilde, or if preceded by escape key: [1~
So I type echo hellp
, move cursor to hel|lp
and type delete, and bam, i got ~tilde
Also, I type echo hellp
, move cursor to hel|lp
and type esc then delete, and bam, I got [3~
$ echo hel~lp
hel~lp
$ echo hell[3~o
hell[3~o
~
My version of bash:
$ bash --version
GNU bash, version 3.1.17(1)-release (i686-pc-msys)
Copyright (C) 2005 Free Software Foundation, Inc.
What I want is behavior like cmd.exe
:
- I want Esc to clear the current line / buffer
- I want Home to move cursor to start of line before first character
- I want End to move cursor to end of line before first character
- I want delete to delete the next character (right of cursor) from current line/buffer
What do I have to edit to fix this?
Is this default on your bash?
update: i'm on a windows machine running a windows program, sh.exe ( as you can see above GNU bash), compiled with mingw for msys:
$ uname -s -m -o
MINGW32_NT-5.1 i686 Msys
Best Answer
You customize bash via an
.inputrc
file in your/home/username
, you can copy the defaulthere is mine (comments start with # )
to find out what you need to type in your inputrc on the left side (the escape code, as it can vary between laptop/desktop...), at the prompt type
echo '
then typeCtrl-V
followed by the key , likeHome
, then type'
examplethen replace each
^[
with\e
add\M-
forAlt
theoretically you'd use\C-
forCtrl
but it currently doesn't work (windows limitation)the available commands (like
backward-kill-line
) are listed in http://www.gnu.org/software/bash/manual/bashref.html#index-backward_002dkill_002dline-_0028C_002dx-Rubout_0029you can view existing keyboard shortcuts/bindings with
bind -p
ordon't mess with TERMCAP