Coder Social home page Coder Social logo

Comments (5)

junegunn avatar junegunn commented on July 16, 2024 1

Ah, you're perfectly right, thanks for raising the issue. I was a bit worried about this too, but I haven't found a solution yet. I particularly don't like the fact that even if you have set -o vi in your .bashrc, if it comes after source ~/.fzf.bash, the key bindings will not be correctly set. Mentioning this quirkiness in the documentation would be helpful of course, and we should probably do so, but it would be better if we could fix the problem. Do you know of a better way to handle this?

from fzf.

junegunn avatar junegunn commented on July 16, 2024

I've just updated the key bindings section of the README page. But I'm still interested in a real solution :)

from fzf.

stephenh avatar stephenh commented on July 16, 2024

Hi Junegunn,

Thanks for updating the readme...good call about the "set -o vi" being before the source also being a gotcha.

I don't have any good ideas for a real solution.

Perhaps fzf could wait until it was invoked to detect vi mode? I vaguely recall seeing some arcane binding setup on Stackoverflow where invoking one binding would, via a bash function, conditionally setup/"bind" the next binding, and then itself automatically invoke that next binding.

I think the con was that it "burned" a binding, in that you had to use two (or three?) bindings to accomplish it. Plus it was fairly complex anyway.

from fzf.

junegunn avatar junegunn commented on July 16, 2024

Thanks for the reply. I googled a bit and I guess you're referring to this, right?
http://stackoverflow.com/questions/8366450/complex-keybinding-in-bash

I roughly tested the approach as follows:

__fzf_rebind() {
  if [ -z "$(set -o | grep '^vi.*on')" ]; then
    bind '"\C-x\C-t": " \C-u \C-a\C-k$(__fsel_tmux)\e\C-e\C-y\C-a\C-d\C-y\ey\C-h"'
  else
    bind '"\C-x\C-t": "\e$a \eddi$(__fsel_tmux)\C-x\C-e\e0P$xa"'
  fi
}
bind -x '"\C-x\C-f": __fzf_rebind'
bind '"\C-t": "\C-x\C-f\C-x\C-t'

So it re-binds C-x + C-t to the right version depending on the current setting. It functionally works but when the rebind function is executed via C-x + C-f as an intermediate step, I see a line feed. I don't know if it's possible to suppress this unwanted line feed, but if it's not, we can't employ this approach.

If you don't mind, I'll keep this issue open until we find a clean solution to the problem.

from fzf.

stephenh avatar stephenh commented on July 16, 2024

Hi Junegunn,

Yes, that was the article...nice find! Sorry for not including the link, I was on my other machine.

That is odd about the new line; I don't have any good ideas. I'll try it out later when I have some time.

Until then I agree leaving the issue open sounds like a good idea.

Thanks for the great support on these issues; I only just came across fzf but I think I will quickly be very addicted to it. It's a great idea.

from fzf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.