Open NightMachinery opened 4 years ago
hey this should be working fine as i had to create a script to strip ansii from the preview when using cat (for security reasons) so it should be possible, however, I know for a fact that tput works which is more portable anyways
@rayiik commented on Sep 12, 2020, 2:22 PM GMT+4:30:
hey this should be working fine as i had to create a script to strip ansii from the preview when using cat (for security reasons) so it should be possible, however, I know for a fact that tput works which is more portable anyways
What preview command di you use? My guess is that your previewer added color.
Here I use 'echo {}'
:
hey so generally i have this in my bash rc so its use in any script but I usually ad it to scripts i share
col0="$(tput bold ; tput setaf 0)"
col1="$(tput bold ; tput setaf 1)"
col2="$(tput bold ; tput setaf 2)"
col3="$(tput bold ; tput setaf 3)"
col4="$(tput bold ; tput setaf 4)"
col5="$(tput bold ; tput setaf 5)"
col6="$(tput bold ; tput setaf 6)"
col7="$(tput bold ; tput setaf 7)"
col8="$(tput bold ; tput setaf 8)"
col9="$(tput bold ; tput setaf 9)"
col10="$(tput bold; tput setaf 10)"
col11="$(tput bold; tput setaf 11)"
col12="$(tput bold; tput setaf 12)"
col13="$(tput bold; tput setaf 13)"
col14="$(tput bold; tput setaf 14)"
col15="$(tput bold; tput setaf 15)"
colwarn="$(tput smso; tput smul)"
nc="$(tput sgr0)"
then for usage its just
$col1 word/text/string/ $nc
usually with echo but printf should work too
to apply it to the text you just loop through input and fork (if-then statements) to color specific output and i just used the standard --preview= but can be any command its the loop and the tput that adds the color in the picture, its just cat and I think that one is a here-string i can check in the morning
@rayiik commented on Sep 12, 2020, 2:44 PM GMT+4:30:
to apply it to the text you just loop through input and fork (if-then statements) to color specific output
and i just used the standard --preview= but can be any command its the loop and the tput that adds the color
in the picture, its just cat and I think that one is a here-string i can check in the morning
Thank you, but this is not what I meant. I already color the preview myself:
I want to preserve the highlighting of fzf itself, the thing that is dark green in this picture:
I want that darkgreen highlight to be passed to the preview command via a placeholder such as {c}
. Otherwise I'd need to duplicate fzf's highlighter in my previewer which is not easy or prudent.
Ahhh do you have ripgrep?
Searchcmd | fzf —preview=“Previewcmd {} | rg {q} —passthru”
Will highlight based off of your query pass thru will print everything including non matching
Ahhh do you have ripgrep?
Searchcmd | fzf —preview=“Previewcmd {} | rg {q} —passthru”
Will highlight based off of your query pass thru will print everything including non matching
This is the strategy fzf.el
(from Emacs) uses. I don't like it. It doesn't work if you use any complex query, because grep
-like tools use PCRE-ish regexes.
Hey so ripgrep uses the rust regexp library which has enough differences that it might be worth your time Even if not used for this case https://blog.burntsushi.net/ripgrep/#regex-engine functionality very different from the Perl library (pcre or the grep) which both use backtracking and finite automata but I find it works quite well with both simple and complex queries https://blog.burntsushi.net/ripgrep/#regex-engine
im still not sure what part of it doesn't work (as i don't use fzf.el) but if you don't want to use regular expression just use the --fixed-strings flag and it just becomes a highlight tool
popualte-list | fzf --phony --preview='echo {} | rg --fixed-stings {q} --passthru'
should be what you described
@rayiik commented on Sep 20, 2020, 7:37 AM GMT+4:30:
im still not sure what part of it doesn't work (as i don't use fzf.el) but if you don't want to use regular expression just use the --fixed-strings flag and it just becomes a highlight tool
popualte-list | fzf --phony --preview='echo {} | rg --fixed-stings {q} --passthru'
should be what you described
I know all these; These only work your query is either a regex or a fixed string. They can't handle, e.g., 'exactMatch | sth someOtherThing
.
Could you give me an specific example with a reproducible example but I don’t think your going to find a solution that doesn’t involve regex or fixed sting that will work with fzf I can think of at least 4 ways to do it with regex awk Perl rg tput sed and could probably make one of those work your your test case but without more info it’s as far as I can take it good luck
@rayiik commented on Sep 22, 2020, 9:54 AM GMT+3:30:
do you mean the curser line highlight or the word highlight? like this or just highlight the line you're on?
Just the line I'm on.
k well fzf doesn't have a "line that your on" its a general view so the feature request your looking for is a set line/ prompt for the preview window I suppose you might be able to set one with READLINE_POINT if you anchored to the physical area on the screen but either way your looking for a value that doesn't currently exist and passing {c} won't change that if there's not physical/anchor point/cursor line so id recommend changing the posing to feature request preview cursor line/prompt **but im totally in favor of having a reference point within the preview window
man fzf
)Info
Problem / Steps to reproduce
I have created a previewer that shows me searches from files in their context, but I lose the highlighting this way. It'd be great if you could support
{c}
to send the line with its color codes preserved to the previewer.