Skip to content

fzf single button data source toggling in bash environment variable but in a variable function execution declatation #3663

Answered by LangLangBart
MikeLemo1 asked this question in Q&A
Discussion options

You must be logged in to vote

echo "$MY_FZF_OPTS" # For debugging

set -x12 is powerful for debugging as it prints commands and their arguments as they are
executed, allowing you to chip away parts of your code until you find the bug yourself.


Basically I'm trying to make this work, got stuck at the source toggling functionality

In your case, you need to escape the $FZF_PROMPT because the surrounding quotes are double quotes.

# example with surrounding double quotes
export MY_FZF_OPTS="
  --preview '[[ \$FZF_PROMPT =~ Files ]] && bat --color=always {} || tree -C {}'
"

# example with surrounding single quotes
export MY_FZF_OPTS='
  --preview "[[ $FZF_PROMPT =~ Files ]] && bat --color=always {} || tree -C {}"
'

Fur…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by MikeLemo1
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