Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bind-key -n equivalent #19

Open
BartSte opened this issue Aug 5, 2023 · 1 comment
Open

bind-key -n equivalent #19

BartSte opened this issue Aug 5, 2023 · 1 comment

Comments

@BartSte
Copy link

BartSte commented Aug 5, 2023

Is it possible to omit the prefix key of tmux-easy-motion? Similarly to omitting Tmux its prefix using the bind-key -n command.

My use case: when I am in copy-mode, I have unassigned keys left that I want to bind to tmux-easy-motion command directly. For example: when I press "k" I want to run the "@easy-motion-binding-w" directly (without having to press the prefix "Space").

My attempts to achieving this were:

  • Setting the tmux-easy-motion prefix to ""
    set -g @easy-motion-copy-mode-prefix ""
    which did not work.
  • Binding "k" to a sequence of keys:
    bind-key -T copy-mode-vi k send-keys " " w 
    which did send a "Space" and a "w" but it triggered the default "w" and not the "@easy-motion-binding-w".

Thanks for the good plugin!

@BartSte BartSte changed the title Disable the pre-fix key in copy-mode bind-key -n equivalent Aug 5, 2023
@BartSte
Copy link
Author

BartSte commented Aug 8, 2023

I solved this as follows:

cmd="no-prefix-easymotion '#{session_id}' '#{window_id}' '#{pane_id}'"
bind -T copy-mode-vi k run-shell -b "$cmd w"

here k is directly bound to the easymotion 'w' command, where
no-prefix-easymotion is the following execuable:

#!/usr/bin/env bash

tmuxpid() {
    [[ "${TMUX}" =~ .*,(.*),.* ]] && echo "${BASH_REMATCH[1]}"
}

server_pid=$(tmuxpid)
bash -c "~/.tmux/plugins/tmux-easy-motion/scripts/easy_motion.sh '${server_pid}' '${1}' '${2}' '${3}' ${4}"

I am no a 100% sure why I need the bash -c though. But it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant