Hi

It would be nice to have a tmux command that conditonally send keys
based on the program running in the focused pane.

See a use case with hacky workaround here:
https://gist.github.com/tarruda/5158535

In the example, vim-tmux-move.zsh will navigate between tmux panes,
but if the current pane is running vim, it will just send some
keys(which vim will handle by navigating between splits, or will
navigate to a tmux pane if the current split sits at an edge)

There are other attempts to achieve the same thing:
https://gist.github.com/mislav/5189704

Those scripts could be generalized into a script that accepts the
following arguments:

1               - a program or pane identifier
2               - a tmux key-map or command
remaining - a list of keys in the same format a send-keys

The script would send the keys if the current pane matches the program
name, else it would run the tmux command or keymap.

The problem with this approach is efficiency: every time a key mapped
to this script is pressed, a new shell has to be spawned, and that
shell will invoke tmux commands. This seems a lot of trouble for
simple things like integrating movement between tmux panes and another
program that also has the concept of panes/splits.

My suggestion is to add a new command that solves this problem by
running other tmux commands based on a condition for example:

bind M-p send-keys-if '#{pane_current_command} == vim' 'paste-buffer'
'Escape' 'p'

This would run bind alt+p to tmux paste-buffer command, but if vim was
focused it would send the keys necessary to invoke vim paste command.

What do you think?

------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to