You are not logged in.

#1 2009-01-22 07:46:36

Thoht
Member
From: Sweden
Registered: 2008-02-02
Posts: 75

Custom colours in BASH prompt? [SOLVED]

Hey there!

I'd like to colourize my BASH prompt, specifically have the working directory output in purple. This is my .Xdefaults:

! use xft for drawing fonts
urxvt.font: xft:Bitstream Vera Sans Mono-8.5
urxvt.background: black
urxvt.foreground: white
! make a scrollbar that's nearly black
urxvt*scrollBar:     false
urxvt*scrollBar_floating:    true
urxvt*scrollBar_right:   false
urxvt*scrollColor:       #202020
urxvt*termName:     xterm
urxvt*urllauncher:           firefox
! matcher.button # 3 is a right-click
urxvt*matcher.button:        3
urxvt*saveLines:              8192
urxvt.perl-ext-common:         default,matcher,tabbed
! black 
urxvt*color0:      #222222
urxvt*color8:      #666666
! red
urxvt*color1:      #9e1828
urxvt*color9:      #cf6171
! green
urxvt*color2:      #aece92
urxvt*color10:     #c5f779
! yellow
urxvt*color3:      #968a38
urxvt*color11:     #fff796
! blue
urxvt*color4:      #71C5F4
urxvt*color12:     #67CDE9
! magenta
urxvt*color5:      #963c59
urxvt*color13:     #cf9ebe
! cyan
urxvt*color6:      #418179
urxvt*color14:     #71bebe
! white
urxvt*color7:      #bebebe
urxvt*color15:      #FFFFFF

urxvt*cursorColor:       #d8d8d8

...and this is my .bashrc:

alias ls='ls --color=auto'
# PS1='\u@\h: \W> '
function prompt
{
local WHITE="\[\033[1;37m\]"
local GREEN="\[\033[0;32m\]"
local CYAN="\[\033[0;36m\]"
local GRAY="\[\033[0;37m\]"
local BLUE="\[\033[0;34m\]"
export PS1="
${GREEN}\u${WHITE}@${BLUE}\h${WHITE}: ${GRAY}\w
${WHITE}> ${GRAY}"
}
prompt

See the ls alias puts some stuf in a very nice purple/magenta colour that I'd like to use in my prompt, but I don't understand how to translate those .Xdefaults colours into the .bashrc. Would someone please help me out and explain how it works? Thanks in advance.

Last edited by Thoht (2009-01-22 16:33:32)


Credit to KiwiesRuleXD @ DeviantArt for the avatar.

Offline

#2 2009-01-22 09:02:24

skualito
Member
Registered: 2008-11-19
Posts: 203

Re: Custom colours in BASH prompt? [SOLVED]

The codes for bash colors :


Black       0;30     Dark Gray     1;30
Blue        0;34     Light Blue    1;34
Green       0;32     Light Green   1;32
Cyan        0;36     Light Cyan    1;36
Red         0;31     Light Red     1;31
Purple      0;35     Light Purple  1;35
Brown       0;33     Yellow        1;33
Light Gray  0;37     White         1;37

so you would add in your function prompt

local PURPLE="\[\033[1;35m\]"

have a look at http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html

Last edited by skualito (2009-01-22 09:04:05)

Offline

#3 2009-01-22 09:06:29

msh
Member
From: Latvia
Registered: 2009-01-16
Posts: 17

Re: Custom colours in BASH prompt? [SOLVED]

NVM. I must learn to read. hmm

Last edited by msh (2009-01-22 09:07:25)

Offline

#4 2009-01-22 12:49:26

Thoht
Member
From: Sweden
Registered: 2008-02-02
Posts: 75

Re: Custom colours in BASH prompt? [SOLVED]

Thanks, I understand the relation between the list on the link and my .Xdefaults now.

However, according to that page 1;30 displays the text in Dark Grey, but also Bold. How can I make the text non-bold with that specific colour? Other than setting Black to Dark Grey in my .Xdefaults?


Credit to KiwiesRuleXD @ DeviantArt for the avatar.

Offline

#5 2009-01-22 15:38:03

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: Custom colours in BASH prompt? [SOLVED]

1; = bold/bright  0; = normal
You can set the bold font to a none-bold one, but then you won't get bold fonts at all.


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#6 2009-01-22 16:33:06

Thoht
Member
From: Sweden
Registered: 2008-02-02
Posts: 75

Re: Custom colours in BASH prompt? [SOLVED]

Oh, alrighty then. Thanks.


Credit to KiwiesRuleXD @ DeviantArt for the avatar.

Offline

Board footer

Powered by FluxBB