bullet-train.zsh icon indicating copy to clipboard operation
bullet-train.zsh copied to clipboard

How to change color of '$'

Open bharadwaj-raju opened this issue 9 years ago • 21 comments

How do I change the color of the $ prompt?

I've tried using color escape codes in the BULLETTRAIN_PROMPT_CHAR variable but then the $ becomes invisible.

echoing the same text gives the $ in the proper color.

bharadwaj-raju avatar May 08 '16 09:05 bharadwaj-raju

:+1: it's not only the color, we can't set anything to BULLETTRAIN_PROMPT_CHAR, i tried to set custom text or another segment, nothing works. It is just just empty when set anything different than $.

tunnckoCore avatar May 22 '16 14:05 tunnckoCore

@tunnckoCore Strange, custom text works for me:

if [ -n "${BULLETTRAIN_PROMPT_CHAR+1}" ]; then
    BULLETTRAIN_PROMPT_CHAR="λ"
fi

Just near the start.

bharadwaj-raju avatar May 22 '16 14:05 bharadwaj-raju

Hm. Maybe. I tried with direct assign BULLETTRAIN_PROMPT_CHAR=" foo "

tunnckoCore avatar May 22 '16 18:05 tunnckoCore

@tunnckoCore Are you setting it in your .zshrc? I suppose you have to set it in ~/.oh-my-zsh/themes/bullet-train.zsh-theme

bharadwaj-raju avatar May 23 '16 05:05 bharadwaj-raju

@bharadwaj-raju the whole idea for that variables are to control themes out of theme files.

tunnckoCore avatar May 23 '16 18:05 tunnckoCore

@tunnckoCore Hmm. This seems to do it outside the theme source:

source ~/.path/to/bullet-train.zsh-theme  # do not use the 'plugins' or 'ZSH_THEME' of oh-my-zsh

if [ -n "${BULLETTRAIN_PROMPT_CHAR+1}" ]; then
    BULLETTRAIN_PROMPT_CHAR="λ"
fi

bharadwaj-raju avatar Jul 09 '16 08:07 bharadwaj-raju

Don't see sense and value on your example. oh-my-zsh is already loaded the things in anyway.

In anyway, i stopped using ohz and this theme already.

tunnckoCore avatar Jul 09 '16 08:07 tunnckoCore

i stopped using ohz

I've switched to prezto and get a fresh set of issues... time to change theme.

bharadwaj-raju avatar Jul 09 '16 08:07 bharadwaj-raju

I am trying to change the prompt, with this code in .zshrc BULLETTRAIN_PROMPT_CHAR="»" but all I have is an invisible prompt what do I am it wrong?

luiscobot avatar Jul 17 '16 03:07 luiscobot

@unluisco, Maybe the terminal app you're using can't render that character properly?

revolter avatar Oct 03 '16 07:10 revolter

Yes @unluisco, try pasting it into the prompt (or anywhere, say cat) and see if it shows up.

bharadwaj-raju avatar Oct 03 '16 10:10 bharadwaj-raju

now the prompt work fine, thanks

luiscobot avatar Oct 03 '16 14:10 luiscobot

Amazing! Can we close the issue?

caiogondim avatar Oct 04 '16 11:10 caiogondim

I've switched to prezto and get a fresh set of issues... time to change theme.

It looks like it's invalid now, as @bharadwaj-raju, the original reporter moved on. And @unluisco's problem was different from this issue.

revolter avatar Oct 04 '16 11:10 revolter

@unluisco what was your fix? My prompt char is not showing either, not even if I use plain text.....

ChristianVermeulen avatar Oct 19 '16 12:10 ChristianVermeulen

@ChristianVermeulen, Could you post the part of your .zshrc that fiddles with "Bullet Train"?

revolter avatar Oct 19 '16 13:10 revolter

@ChristianVermeulen make sure you put the character inside parenthesis and double quotes like so: (">>").

To answer the original question, though. You set the color code with %{FG[color]%} where color is a 3 digit color code (found by running spectrum_ls in zsh terminal). You can also use fg[color] where color is text like "red". Here is mine: BULLETTRAIN_PROMPT_CHAR=("%{$fg[red]%}>>")

stevensonmt avatar Dec 30 '16 05:12 stevensonmt

Maybe we should introduce new variable, something like BULLETTRAIN_PROMPT_COLOR ?

dawikur avatar Jan 02 '17 17:01 dawikur

My prompt character always renders correctly but I still cannot change the color

Even when I do: BULLETTRAIN_PROMPT_CHAR=("%{$fg[red]%}>>")

The prompt shows as just ">>" but it is still green

jakemayeux avatar Feb 16 '17 06:02 jakemayeux

Show us your .zshrc

revolter avatar Feb 16 '17 17:02 revolter

I have to periodically reload .zshrc for some reason for the color to stick. So in the terminal just do . <pathto/.zshrc>

stevensonmt avatar Feb 20 '17 01:02 stevensonmt