laktak / extrakto

extrakto for tmux - quickly select, copy/insert/complete text without a mouse
MIT License
878 stars 45 forks source link

multi pane fuzzy completion #27

Closed oblitum closed 5 years ago

oblitum commented 6 years ago

Sometimes I'm with a split of vim and a console. If editing in the vim pane, extrakto doesn't fuzzy find text/paths in the console pane. It would be great if it could do so. Meanwhile I have to select the target console pane, fuzzyfind there and copy, then get to the vim pane and paste.

oblitum commented 6 years ago

I've hardcoded the multipane feature with this, please tell what you think, if it should be behind a flag or not, I can make it into a pull:

diff --git a/scripts/tmux-extrakto.sh b/scripts/tmux-extrakto.sh
index 1a161ae..caa6588 100755
--- a/scripts/tmux-extrakto.sh
+++ b/scripts/tmux-extrakto.sh
@@ -59,7 +59,13 @@ function capture() {
   # for troubleshooting add
   # tee /tmp/stageN | \
   # between the commands
-  sel=$(tmux capture-pane -pJS ${capture_pane_start} -t ! | \
+  for pane in $(tmux list-panes -F "#{pane_active}:#{pane_id}"); do
+    if [[ $pane =~ '0:'  ]]; then
+      captured+=$(tmux capture-pane -pJS ${capture_pane_start} -t ${pane:2})
+      captured+=$'\n'
+    fi
+  done
+  sel=$(echo "$captured" | \
     $extrakto -r$extrakto_flags | \
     (read line && (echo $line; cat) || echo NO MATCH - use a different filter) | \
     $fzf_tool \
oblitum commented 6 years ago

It could possibly be made more general too, to go across windows/sessions optionally.

laktak commented 6 years ago

Sounds like a good idea!

I have a few suggestions:

Not sure if going across windows would be useful even if the performance was ok.

oblitum commented 6 years ago

Good points. Sadly, I can't figure out how to get the pane_id of the last active pane (-t !). I think I need it to exclude it from the loop and put its capture as the last output concatenation, otherwise I'll have to add it twice.

laktak commented 6 years ago

@oblitum see $ACTIVE_PANE in 454f39f

oblitum commented 6 years ago

@laktak cool thanks for that. You may delete the branch now if you want. I'll make that part of the pull (no ETA though).

floscr commented 6 years ago

Would it be possible to search in all panes in the current window?

oblitum commented 6 years ago

@laktak I've converted the issue into a pull request.

laktak commented 5 years ago

Sorry, I somehow missed the notification for your commit. Thanks for implementing this feature!