Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Background color for prompt only? #3775

Closed
5 of 10 tasks
tmpm697 opened this issue May 6, 2024 · 4 comments
Closed
5 of 10 tasks

Background color for prompt only? #3775

tmpm697 opened this issue May 6, 2024 · 4 comments

Comments

@tmpm697
Copy link

tmpm697 commented May 6, 2024

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

@LangLangBart
Copy link
Contributor

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

@tmpm697
Copy link
Author

tmpm697 commented May 7, 2024

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
Copy link
Contributor

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

@tmpm697
Copy link
Author

tmpm697 commented May 7, 2024

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

@tmpm697 tmpm697 closed this as completed May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants