Re: No way to 'bind -x' symbolic character names

2019-11-30 Thread Dennis Williamson
On Fri, Nov 29, 2019, 10:40 AM Nikolaos Kakouros  wrote:

> Using bash version:
>
> GNU bash, version 5.0.11(1)-release (x86_64-pc-linux-gnu)
>
>
> Trying to map Backspace to execute a function, I try to do:
>
> bind -x '"Rubout": my_func'
>
> This, as expected, binds the string 'Rubout' to the function. Omitting the
> double quotes makes bind fail. Escaping, like `\Rubout`, works neither.
>
> This is important in the case of Backspace, as there is no (to my
> knowledge) other way to bind the backspace than using Rubout. Using Konsole
> as my terminal emulator, `C-v Backspace` prints `^?` which I haven't
> managed to use with bind.
>

Backspace is a terminal setting which has precedence. You have to first
undefine it.

stty erase undef
bind -x '"\C-?":my_func'

>


Re: No way to 'bind -x' symbolic character names

2019-11-30 Thread Dennis Williamson
On Sat, Nov 30, 2019, 11:24 AM Chet Ramey  wrote:

>
Readline binds the terminal special characters if the variable
> `bind-tty-special-chars' is set, and it's set by default.
>

Wow, that's been in Bash a long time and I never noticed it! Thanks!

>


Re: No way to 'bind -x' symbolic character names

2019-11-30 Thread Chet Ramey
On 11/30/19 9:57 AM, Dennis Williamson wrote:
> On Fri, Nov 29, 2019, 10:40 AM Nikolaos Kakouros  wrote:
> 
>> Using bash version:
>>
>> GNU bash, version 5.0.11(1)-release (x86_64-pc-linux-gnu)
>>
>>
>> Trying to map Backspace to execute a function, I try to do:
>>
>> bind -x '"Rubout": my_func'
>>
>> This, as expected, binds the string 'Rubout' to the function. Omitting the
>> double quotes makes bind fail. Escaping, like `\Rubout`, works neither.

The answer below, using the standard "\C-?" notation to denote DEL, is the
right one. The symbolic character names were deprecated a number of years
ago. They only work with old APIs.

>> This is important in the case of Backspace, as there is no (to my
>> knowledge) other way to bind the backspace than using Rubout. Using Konsole
>> as my terminal emulator, `C-v Backspace` prints `^?` which I haven't
>> managed to use with bind.
>>
> 
> Backspace is a terminal setting which has precedence. You have to first
> undefine it.
> 
> stty erase undef
> bind -x '"\C-?":my_func'

The `stty erase under' might be overkill, since it affects all programs
using that terminal.

Readline binds the terminal special characters if the variable
`bind-tty-special-chars' is set, and it's set by default. You could unset
that instead of disabling the stty erase character binding.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/