Skip to content

(HELP) How would I customise keybinds? #9

@nerd190

Description

@nerd190

First, thank you! the shell is missing a leader key!

I see no development in some time, but was wondering if you could help me please?

I use vi-mode in zsh, leader will be active for insert mode also, but for vim it is not, using leader for insert mode means you are unable to:

$ multiline \
   shell \
   command

Or escape characters like space (\<space>), or itself, a backslash (\\)

vi-mode users can use vicmd mappings so that leader is mapped to the correct mode e.g bindkey -M vicmd '\\' leader_widget

I ran leader_init > leader.sh and took a look, the resulting file is:

#!/bin/zsh

leader_widget() {
    local leader_exit leader_next
    leader_next=$(SHELL=/bin/zsh BUFFER=$BUFFER CURSOR=$CURSOR leader print)
    leader_exit=$?
    zle reset-prompt
    if [ $leader_exit -eq 3 ]; then
        BUFFER="${BUFFER}${KEYS}"
        CURSOR=$((CURSOR + $#KEYS))
        return "$leader_exit"
    fi
    eval "$leader_next"
  }
  zle -N leader_widget
  bindkey "\\" leader_widget
}

Is it possible for me to change the above bind and eval this script instead somehow? I gave it a go but was unsucessful, Im think its my fault (not skilled!) as Im sure it should be possible. Please help!

Again, thank you for this, once its mapped to vicmd mode it is PERFECT! 👍

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions