Closed timtyrrell closed 3 years ago
Ok, so for this, I will need to have a different echo command to trim off what I want. My only thought is if you let me use my normal FZF_DEFAULT_OPTS
it should copy what I normally expect. I am not sure if my "echo" command is non-standard, maybe it is?
Seems you hit an unexpected usecase here, I do a lot of background stuff with the line, so coping it from fzf like you do would need some tweaking. I can look into making a default action of copy on enter if that's possible, and that's something you'd like?
I am trying to think about this more at a high level. Would you say it is true that you need to append in your own FZF_DEFAULT_OPTS, which you currently do in the plugin, because otherwise your awk and other logic wouldn't function?
yes, that is correct. I need to get the line number and which direction your moving from the actual line it self. These fields are separated by colons. It goes something like this:
direction : line number : the rest of the line
1: 7: > npm install blah
There can be arbitrary spaces between fields.
It's worth noting that I currently do not override any default options, but certain fzf options must be enabled for fuzzback to function:
--delimiter=":" # separates fields
--ansi # interpret colors
--with-nth="3.." # this tells fzf to only show the line, ignore the line number and direction
--print-query # This is for optional column movement, fuzzback tries to move the cursor to the correct word if possible
# The rest here are non-essential, but it makes no sense to enable them in fuzzback
--no-multi
--no-sort
--no-preview
Alright, so here is my thought. You know how currently there are specific ENVs for certain key presses so you can set more specific settings? Like theseFZF_CTRL_T_COMMAND, FZF_ALT_C_COMMAND, FZF_CTRL_R_OPTS
: https://github.com/junegunn/fzf/wiki/Configuring-shell-key-bindings
If you add an ENV like that or another tmux setting it would allow the flexibility I need to tweak my copy command for this plugin specifically. Also, I am guessing the flexibility would be useful for other reasons down the road to others.
Do I understand you correctly that you'd like a fzf --bind that is customizable and that only affects fzf when used from fuzzback? This is so that you can use a custom copy command to grab whatever line fzf matched you on?
I am, yes. That is literally the use case of why those patterns exist, so you can do things like enable/disable previews, pass in different header text, etc based on the key combination.
I'll try to set that up. When I tried yesterday I ran into some issues using a variable as a bind string, no idea why. I'm pretty busy today so I'll not get a chance to look at this further until tomorrow.
@roosta Do what you think makes sense! I appreciate the changes so far. Great plugin 😎
Thanks for your feedback :) I added a new option for this that should do the trick I think
set -g @fuzzback-fzf-bind 'ctrl-y:execute-silent(echo -n {2..} | xsel -ib)+abort'
Working good, btw, thanks a lot!
set -g @fuzzback-fzf-bind 'ctrl-y:execute-silent(echo -n {3..} | pbcopy)+abort'
When I hit my copy command,
ctrl-y
using my normal shell interface, I get the line, as is:Copied to clipboard:
npm run test:cypress:open
Using this plugin, it is copying some "invisible" line number with it. I would blame my config but it works fine except with this plugin.
Copied to clipboard:
5:❯ fzf-tmux -p
Maybe this should be overrideable? https://github.com/roosta/tmux-fuzzback/blob/main/scripts/fuzzback.sh#L17-L25
I notice my copy command is this
--bind 'ctrl-y:execute-silent(echo -n {2..} | pbcopy)+abort'
which maybe doesn't match what the FZF_DEFAULT_OPTS this plugin outputs 🤔