Skip to content

How to implement toggling behaviour for preview (use same keybind to toggle preview command) #3041

Answered by lime-desu
tg0h asked this question in Q&A
Discussion options

You must be logged in to vote

Hello I've tried to do that, but It is not perfect, the way that you wanted it, though it does the job to change the preview.
The problem is:

  • when pressing ctrl-g will change the preview into bat first, now pressing ctrl-g if the preview is on bat it will not change the preview So pressing ctrl-g sometimes doesn't work and that behavior will be kinda annoying. ( I don't know why but, I guess the logic or order is wrong I'm too lazy to figure that out xD) here's the code snippet btw:
fd . | fzf \
  --bind "ctrl-g:execute-silent(touch /tmp/testing; echo "bat" > /tmp/testing)+change-preview(
    if grep -q bat /tmp/testing; then 
      bat --color=always {} && echo "cat" > /tmp/testing;

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tg0h
Comment options

Answer selected by tg0h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants