junegunn/fzf

Background color for prompt only?

tmpm697 opened this issue · 4 comments

Checklist

  • I have read through the manual page (man fzf)
  • I have searched through the existing issues
  • For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.51.0

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

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

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

Footnotes

  1. Non-breaking space: how to insert one? - Apple Community

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

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 $'123

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

Footnotes

  1. Bash Reference Manual - ANSI-C Quoting

  2. bash quotes (wizardzines.com)

  3. bash:tip_colors_and_formatting - FLOZz' MISC

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