1

Conculusion:

  • No WORDCHARS alternative in Bash, where C-w ends can't be configured.
  • mysql depends on editline, which is customizable with ~/.editrc.
  • redis-cli depends on linenoise, it deletes the whole word without considering :, -

In zsh, WORDCHARS controls the behavior of C-w when deleting a word. Is there any alternative in readline?

I've noticed recently the behavior of C-w in mysql/redis-cli differs that in Bash, although both of which depends on readline?

Take string foo:bar as an example, only bar is deleted by C-w in Bash. While in mysql/redis-cli, the whole word foo:bar is deleted.

How do I control this behavior?

Simba
  • 23,537
  • 7
  • 64
  • 76
  • Can't reproduce this in my `bash`. C-w deletes `foo:bar` as expected. Can you post the output of `bind -P | grep -w w`. Do you happen to have a space after `:`, i.e. `foo: bar`? – Inian Jul 31 '20 at 08:39
  • @Inian What's your bash version? – Simba Jul 31 '20 at 08:42
  • GNU bash, version 4.4.0(1), can you also confirm, no spaces exist? – Inian Jul 31 '20 at 08:45

1 Answers1

2

There are two commands to do backward kill word :

backward-kill-word
unix-word-rubout

backward-kill-word deletes bar, unix-word-rubout deletes foo:bar

Run following command to find out what C-w is bound to

bind -P | grep C-w

Seems bash doesn't have WORDCHARS as in zsh

Philippe
  • 20,025
  • 2
  • 23
  • 32
  • vi-unix-word-rubout can be found on "\C-w". I tried to bind \C-w to `backward-kill-word` and `unix-word-rubout`. There's no difference in my test. Both of them only deletes only `bar` from `foo:bar`. – Simba Aug 02 '20 at 03:19
  • Have you checked on your `mysql/redis-cli`, what `C-w` is bound to ? – Philippe Aug 02 '20 at 07:33
  • Thanks for your tips. I forgot to print the keybinding in these client. It proves a problem of redis-cli only. Maybe redis-cli doesn't depend on readline? I'll dig it deeper. – Simba Aug 03 '20 at 02:34