junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
62.31k stars 2.35k forks source link

Background color for prompt only? #3775

Closed tmpm697 closed 2 months ago

tmpm697 commented 2 months ago

Checklist

Output of fzf --version

0.51.0

OS

Shell

Problem / Steps to reproduce

from this: https://minsw.github.io/fzf-color-picker/

bg changes background color of all, but i want specific color of an element instead of globally wide

is there a way to do that?

smth like this: Screenshot 2024-05-07 at 1 03 08 AM

LangLangBart commented 2 months ago

You could try using the reverse ANSI attribute.

man fzf | less --pattern "ANSI ATTRIBUTES"

fzf --prompt " LOCATION " --color "prompt:magenta:reverse"

The problem is that the trailing space is not colored in magenta.


Instead of a normal space, try it with a non-breaking space.

On macOS, the key combination seems to be Option + Space [^1].

Character Unicode
Space U+0020
Non-Breaking Space U+00A0

[^1]: Non-breaking space: how to insert one? - Apple Community

tmpm697 commented 2 months ago

Screenshot 2024-05-07 at 4 39 01 PM but then how can i remove that pink < in prompt --> it seems padded to STR in --prompt=STR

another issue is that how can i change the color of text LOCATION from black to white?

ty

LangLangBart commented 2 months ago

but then how can i remove that pink < in prompt --> it seems padded to STR in --prompt=STR

--info=hidden or --info=inline: might suffice

man fzf | less --pattern "--info=STYLE"

another issue is that how can i change the color of text LOCATION from black to white?

🧐 I don't know.


If the color options provided by fzf for the prompt are inadequate, you could try workarounds:

ANSI-C Quoting $'[^1][^2][^3]

fzf --prompt $'\e[1;37;45m LOCATION \e[0m '

ZSH Command

The builtin print command coupled with the -P flag allows to use PROMPT SEQUENCES, see the zshmisc man page for more.

man zshmisc | less --pattern "PROMPT SEQUENCES"
fzf --prompt "$(print -P -- "%K{164}%B LOCATION %~ %b%k ")"
term description
%K{numeric\|string} Start using a background color
%B Start bold
%~ Current working directory
%b End bold
%k End using background color

[^1]: Bash Reference Manual - ANSI-C Quoting [^2]: bash quotes (wizardzines.com) [^3]: bash:tip_colors_and_formatting - FLOZz' MISC

tmpm697 commented 2 months ago

u always amazed me with such a detailed thoughtful reply :)