Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: emulate bash key bindings



On 1/8/20, Andrey Butirsky <butirsky@xxxxxxxxx> wrote:
> On 08.01.2020 05:26, Sebastian Gniazdowski wrote:
>> On Tue, 7 Jan 2020 at 19:40, Andrey Butirsky <butirsky@xxxxxxxxx> wrote:
>>> Hello,
>>>
>>> after 25 years of bash, I'm doing my first steps with Zsh.
>>>
>>> I'm trying to reproduce main bash key bindings in Zsh, so I started
>>> with:
>>>
>>> autoload -U select-word-style
>>> select-word-style bash
>>>
>>> But sill, I need to have different word boundaries for some bindings,
>>> e.g Ctrl+W should kill space-delimeted word.
>>>
>>> What is the best way to achieve that? Can I avoid creating custom
>>> widgets?
>> The widget is backward-kill-word. I'd also suggest utilizing the
>> ability of bindkey to process multiple arguments at once – it'll spare
>> some space:
>>
>> bindkey "^A"      beginning-of-line     "^E"      end-of-line
>> bindkey "^?"      backward-delete-char  "^H"      backward-delete-char
>> bindkey "^W"      backward-kill-word    "\e[1~"   beginning-of-line
>> bindkey "\e[7~"   beginning-of-line     "\e[H"    beginning-of-line
>> bindkey "\e[4~"   end-of-line           "\e[8~"   end-of-line
>> bindkey "\e[F"    end-of-line           "\e[3~"   delete-char
>> bindkey "^J"      self-insert           "^M"      accept-line
>> bindkey "^R"      history-incremental-search-backward
>>
> Thanks, but 'backward-kill-word' widget changes it's behavior after
> issuing "select-word-style bash" command - it starts kill bash-like
> words (alphabet and numeric symbols). So I need bindings for both type
> of words, bash-like and space-delimited.

You can bind those you want to be space-delimited to widgets with a .
in front, it will override the custom widget function
select-word-style sets up.
bindkey "\e[4~"   end-of-line           "\e[8~"   .end-of-line


-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author