Skip to content

How to implement magic-enter functionality in ble.sh? #490

Answered by akinomyoga
mattmc3 asked this question in Q&A
Discussion options

You must be logged in to vote

I haven't checked how the mentioned magic-enter precisely behaves, but here are examples:

If you want to replace just Enter,

# blerc

function ble/widget/blerc/magic-enter {
  if [[ ! $_ble_edit_str ]]; then
    ble/widget/execute-command 'git status -sb .'
  else
    ble/widget/accept-single-line-or-newline    # this is the default binding of C-m/RET
  fi
}
ble-bind -f C-m blerc/magic-enter    # for traditional keyboard protocol
ble-bind -f RET blerc/magic-enter    # for advanced keyboard protocol

If you want to hook into more places that executes the user's command,

# blerc

ble/function#advice around ble/widget/default/accept-line '
  if [[ ! $_ble_edit_str ]]; then
    ble/widget/exec…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by mattmc3
Comment options

You must be logged in to vote
1 reply
@akinomyoga
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants