You are not logged in.

#1 2018-04-05 15:28:13

E5ten
Member
Registered: 2018-01-08
Posts: 16

zsh bright colours without bold

Is it possible to make parts of my prompt use the bright colours without making them bold?

Offline

#2 2018-04-05 15:33:53

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: zsh bright colours without bold

printf '\033[38;5;10mBright Green\033[0m\n'

Note this will *not* work in the console (without some framebuffer terminal) but it will work with any 256 color terminal and some non-256 gui terminals.

Last edited by Trilby (2018-04-05 15:46:23)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2018-04-05 16:14:29

E5ten
Member
Registered: 2018-01-08
Posts: 16

Re: zsh bright colours without bold

Is that not the formating used by bash?

Offline

#4 2018-04-05 17:26:44

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,786
Website

Re: zsh bright colours without bold


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#5 2018-04-05 17:36:11

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: zsh bright colours without bold

The terminology used by terminal emulators regarding ANSI colour codes is ambiguous.

ANSI only describes one modifier, which it calls bold. It's up to the terminal emulator how it visualises this which most do by using the same (non-bold) font but in a brighter colour. There is no way of distinguishing between bold and bright in your shell prompt or anything else that makes use of escape codes, it's up to the terminal emulator alone how it displays bold text.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#6 2018-04-05 18:21:09

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: zsh bright colours without bold

Slithery wrote:

There is no way of distinguishing between bold and bright in your shell prompt.

Sure there is.  Some terminals - e.g., the tty console, do not respond differently to bold and bright, but this doesn't mean there is no way to request either bold or bright.

There is a escape sequence for bold.  Full stop.

Strictly speaking there is no actual signal for "bright", but by convention (and the default) colors 8-15 are "brighter" versions of 0-7.  You can ask the terminal for any combination of bold/bright:

printf '\033[32mGreen\033[0m\n'
printf '\033[38;5;10mBright Green\033[0m\n'
printf '\033[32;1mBold Green\033[0m\n'
printf '\033[38;5;10;1mBold Bright Green\033[0m\n'

In the TTY there is no bold font.  So if you ask for bold, it just gives you bright.  If you ask for bright, it also gives you bright.  If you ask for bold bright, it still just gives you bright.  So in fact, bright versus non bright is the one distinction you can get in any color terminal.

Most (if not all color) gui terminals can differentiate - with one notable exception.  If the OP had asked for bold without bright, that is a little trickier as in a gui terminal, you have regular font, and if you ask for bright, you get just bright regular font; but if you ask for bold, you get bright bold.  It's not easy to get bold and not bright.  But this was not the OP's question, it is simple to get bright without bold in any terminal.

Last edited by Trilby (2018-04-05 18:22:19)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2018-04-06 03:26:30

E5ten
Member
Registered: 2018-01-08
Posts: 16

Re: zsh bright colours without bold

So I'm probably just being incompetent, but I can't figure out how to apply those ANSI codes to my PS1, which is currently this PS1="%B%F{green}%n@%m%f%b:%B%F{blue}%~%f%b\$ ". If it isn't too much trouble could you show me how I'd use those?

Offline

#8 2018-04-06 12:28:02

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: zsh bright colours without bold

I don't use zsh, but from looking at the docs, I think it'd be

%{\033[38;5;10m}

for bright green.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#9 2018-04-06 15:52:55

E5ten
Member
Registered: 2018-01-08
Posts: 16

Re: zsh bright colours without bold

Thanks, that was super close, I'll post my new prompt here (looks like old one but just bright colours minus bold) in case anyone else wants to compare to understand how it works.
PS1=$'%{\033[38;5;10m%}%n@%m%{\e[0m%}:%{\u001b[34;1m%}%~%{\e[0m%}\$ '
the $ at the beginning tells zsh to interpret ansi codes, the instances of "%{\e[0m%}" make it revert to the standard terminal colour, so if I had not included it at the end, the $ and the whole terminal would be bright blue.

Offline

#10 2018-04-06 17:54:07

E5ten
Member
Registered: 2018-01-08
Posts: 16

Re: zsh bright colours without bold

Actually, I can't seem to get it to work for blue (because I don't truly understand what all the numbers you posted mean) so when I try to adapt your green example to blue I either get dark blue, or bold bright blue.
EDIT: I understand now, I thought the first number was what I had to change to change the colour, it was the last one.

Last edited by E5ten (2018-04-06 18:08:05)

Offline

Board footer

Powered by FluxBB