leader icon indicating copy to clipboard operation
leader copied to clipboard

(HELP) How would I customise keybinds?

Open nerd190 opened this issue 3 years ago • 2 comments

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! 👍

nerd190 avatar May 13 '21 11:05 nerd190

Hey @5c0tt-b0t :wave:

Thank you for the feedback and sorry for the late reply, I didn't get a notification for this!

I'll need some time to look into your use case, but what you want should be possible in theory.

Will keep you posted here!

dhamidi avatar Jul 22 '21 13:07 dhamidi

No worries at all @dhamidi, thank you so much for taking a look! This leader for the shell is amazing, thank you! If its possible (to use in vicmd), it will be much more usable and it also would also work perfectly from vim's builtin shell! 👍

nerd190 avatar Aug 09 '21 13:08 nerd190