spaceship-prompt / spaceship-prompt

:rocket::star: Minimalistic, powerful and extremely customizable Zsh prompt
https://spaceship-prompt.sh
MIT License
19.55k stars 962 forks source link

Add option to print prompt in non-bold font #426

Open lumaxis opened 6 years ago

lumaxis commented 6 years ago

Issue

I'd love for Spaceship to have option to not set bold as the default font style for the prompt. What do people think about this? If others are interested in this as well, I'd start prototyping a PR.

Screenshot

iTerm with bold fonts globally disabled:

screenshot 2018-04-23 19 33 47

Hyper with the Spaceship default:

screenshot 2018-04-23 19 33 28

Environment

Spaceship version: 3.3.0 Zsh version: zsh 5.3 (x86_64-apple-darwin17.0) Zsh framework: oh-my-zsh Zsh plugin manager: None Terminal emulator: Hyper/iTerm Operating system: macOS

salmanulfarzy commented 6 years ago

bold disabled for section contents like git information or whole prompt including prefixes and suffixes ?

timofurrer commented 6 years ago

I would love to have such an option!

bold disabled for section contents like git information or whole prompt including prefixes and suffixes ?

IMHO: for all options where you can set the color.

pcdevil commented 5 years ago

Moving the discussion from #519:

I would like to make this feature to be happen because of personal interest, but I want to align with the current route of the project.

My proposed approach would have a new standard parameter (SPACESHIP_PROMPT_DEFAULT_BOLD) which could have been overridden in sections.

But as @salmanulfarzy mentioned this would be overkill. I interpret his concerns as this would bring too much complexity on the project for a feature not widely used (correct me if I am wrong). I tend to agree on the latter part, if it's not widely used than the new "API" would overwhelm the documentation for newcomers. I respect his opinion and I understand the notion behind his thoughts so I would follow with a simpler solution (as he suggested):

A new standard parameter (SPACESHIP_PROMPT_BOLD) would be introduced to globally switch the boldness of the content part of the sections. The keyword here is content - this wouldn't change the behaviour of prefixes and suffixes.

This would be a more subtle change with less risk on the current codebase too.

I looked at the code and this would be easy to implement.

What your thoughts on this? (Mainly addressing the question to @salmanulfarzy)

If we are in a consensus I would follow-up with a WIP pull-request to eliminate the obstacles along the implementation.

ortonomy commented 4 years ago

Any movement on this? This bolding of the prompt is really annoying. Why should I have to disable bold face globally in iTerm? Shouldn't this be a choice for spaceship? (considering how granularly everything else is configurable?)

image

pcdevil commented 4 years ago

Hey @ortonomy, I didn't move on this because wanted to get green light from @salmanulfarzy before implementing any code to avoid later confusion/discrepancies about it.

Any thoughts Salmanul?

romkatv commented 4 years ago

While you are waiting for the new option to be implemented, you can add the following snippet at the end of ~/.zshrc to unbold spaceship prompt.

() {
  local z=$'\0'
  PROMPT='${${${$(spaceship_prompt)//\%\%/'$z'}//\%B}//'$z'/%%}'
}

This performs 3 replace-all operations on PROMPT:

  1. Replace %% with $'\0' (special value that cannot be present in PROMPT).
  2. Replace %B with nothing. This removes all boldness.
  3. Replace $'\0' with %% to restore escaped percents.

Enjoy your spaceship prompt!

ortonomy commented 4 years ago

thanks @romkatv -- A pity I have to disable it globally.

yoniamir commented 4 years ago

Thanks @romkatv nice workaround.

dhasilva commented 3 years ago

@romkatv This does not work for the right prompt here, unfortunately.

romkatv commented 3 years ago

@dhasilva You can add the same line for RPROMPT.

dhasilva commented 3 years ago

@romkatv Thank you, friend. It works! For newbies like me finding this thread:

() {
  local z=$'\0'
  PROMPT='${${${$(spaceship_prompt)//\%\%/'$z'}//\%B}//'$z'/%%}'
  RPROMPT='${${${$(spaceship_rprompt)//\%\%/'$z'}//\%B}//'$z'/%%}'
}
zhimsel commented 1 year ago

FYI, there are two new issues with the above workaround starting in v4+:

  1. The spaceship_[r]prompt functions have been moved to spaceship::[r]prompt.
  2. The workaround no longer works. I'm guessing it has something to do with the asynchronous prompt rendering; I'd wager that changing the $PROMPT variable directly does not take effect since the async process will replace it immediately after. I tested with SPACESHIP_PROMPT_ASYNC=false, but it still doesn't work. 🤷