You are not logged in.

#1 2009-03-06 01:11:21

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

[Help] colorized bash output,confuzed about `tput setf 1`

How should i understand the number (here "1")?

[

BLUE=`tput setf 1`
GREEN=`tput setf 2`
CYAN=`tput setf 3`
RED=`tput setf 4`
MAGENTA=`tput setf 5`
YELLOW=`tput setf 6`
WHITE=`tput setf 7`
PURPLE=`tput setf 9`
WHEAT=`tput setf 11`
DEFA=`tput setf 49`
DEFB=`tput setf 45`

PS1='\[$DEFA\]\A\[$DEFB\]\w\[$DEFA\]">\[$DEFB\] '

]

Is there any way to translate the number after "setf" to something comprehensible, like, RGB ??

the major purpose i wanna know this is that,
i have a color i wanna use in urxvt as output font color,
i know the color name, CornflowerBlue,
AND i know the RGB value, 100 149 237, or, #6495ED,
BUT,unfortunately, i don't know the "setf" value !

feels like a blind guy....lol
some light to guide?
thx


This silver ladybug at line 28...

Offline

#2 2009-03-06 02:10:35

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: [Help] colorized bash output,confuzed about `tput setf 1`

It is all in

man terminfo

This is one of the hugest man pages I know of (around 2000 lines) and the information there is overwhelming.

Color values, including RGB, are around line 1770.

setf is "set foreground"
setb is "set background"


To know or not to know ...
... the questions remain forever.

Offline

#3 2009-03-06 03:28:43

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Re: [Help] colorized bash output,confuzed about `tput setf 1`

bernarcher wrote:

It is all in

man terminfo

This is one of the hugest man pages I know of (around 2000 lines) and the information there is overwhelming.

Color values, including RGB, are around line 1770.

setf is "set foreground"
setb is "set background"

thanks, bernarcher! it is overwhelming...
i see the 0~7 chart there around 1770,
and i see it in /usr/include/curses.h

/* colors */
#define COLOR_BLACK     0
#define COLOR_RED       1
#define COLOR_GREEN     2
#define COLOR_YELLOW    3
#define COLOR_BLUE      4
#define COLOR_MAGENTA   5
#define COLOR_CYAN      6
#define COLOR_WHITE     7

while, on the other hand, i still dont get the point of it... i  mean,
what about the `tput setf  65` ?
where is it defined, i  still dont get it...
and i've tried those numbers around 70, 80 , 90 , there seems to be a limit to it, which i'm not sure about,
still feeling blind..as newbies normally do , lol..

bernarcher, and also somebody,
explain it to me , plz  smile


This silver ladybug at line 28...

Offline

#4 2009-03-06 07:29:58

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: [Help] colorized bash output,confuzed about `tput setf 1`

Can you not use .Xdefaults? That's where I set urxvt colours.

Offline

#5 2009-03-06 08:03:54

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Re: [Help] colorized bash output,confuzed about `tput setf 1`

@Tomk

i do use .Xdefaults.

now i've renamed .bashrc to .bashrc.xx, then opened up a new urxvt window, it's nice that when i type in urxvt, the "URxvt.foreground" color is set to output font. it's nice since the font color coming out is finally predictable  .... ==!  lol

thx for that tip~ tomk!

while, still... since i've abandoned PS1 setting in .bashrc, SP1 looks now just plain: '$ bash-3.2: '
how can i get the PS1 set to my former style, using several colors, like ::

PS1='\[$colorA\]\A\[$colorB\]\w\[$colorC\]">\[$colorD\] '

.1 how to set PS1 to be like this using only .Xdefaults ?

.2 how to set PS1 to be like this using .Xdefaults to set colorD, and .bashrc to set colorA\B\C ?

.3 i'm still wondering if anyone here will feagure it out what 'setf 1' means, so that it's ok to just set it up in .bashrc  ?

Last edited by lolilolicon (2009-03-06 08:18:13)


This silver ladybug at line 28...

Offline

#6 2009-03-06 09:35:51

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: [Help] colorized bash output,confuzed about `tput setf 1`

You should still use .bashrc for your PS1. For fancy prompts, search the forum and/or google.

Offline

Board footer

Powered by FluxBB