You are not logged in.

#1 2012-08-07 02:29:07

C. M. Harlequin
Member
From: Australia
Registered: 2011-12-23
Posts: 35

[SOLVED] Colours not displaying in bash prompt

Hi Everyone

I'm trying to configure URxvt to use the Solarized scheme by Ethan Schoonover, but I can't get colours to display in the bash prompt.  URxvt is clearly diplaying colours because vim is showing syntax highlighting nicely.

I'm missing something really fundamental here, but I don't know what it is.  Do I need to configure something in bash?

Here are my files (Yeah, pretty basic right now):

.Xresources

!! URxvt Settings ..............................................................

!! Use colours
URxvt.useColor:         true

!! Hide scroll bar
URxvt.scrollBar:        false

!! Colour Settings .............................................................

!! drop in Solarized colorscheme for Xresources/Xdefaults

!!SOLARIZED HEX     16/8 TERMCOL  XTERM/HEX   L*A*B      RGB         HSB
!!--------- ------- ---- -------  ----------- ---------- ----------- -----------
!!base03    #002b36  8/4 brblack  234 #1c1c1c 15 -12 -12   0  43  54 193 100  21
!!base02    #073642  0/4 black    235 #262626 20 -12 -12   7  54  66 192  90  26
!!base01    #586e75 10/7 brgreen  240 #585858 45 -07 -07  88 110 117 194  25  46
!!base00    #657b83 11/7 bryellow 241 #626262 50 -07 -07 101 123 131 195  23  51
!!base0     #839496 12/6 brblue   244 #808080 60 -06 -03 131 148 150 186  13  59
!!base1     #93a1a1 14/4 brcyan   245 #8a8a8a 65 -05 -02 147 161 161 180   9  63
!!base2     #eee8d5  7/7 white    254 #e4e4e4 92 -00  10 238 232 213  44  11  93
!!base3     #fdf6e3 15/7 brwhite  230 #ffffd7 97  00  10 253 246 227  44  10  99
!!yellow    #b58900  3/3 yellow   136 #af8700 60  10  65 181 137   0  45 100  71
!!orange    #cb4b16  9/3 brred    166 #d75f00 50  50  55 203  75  22  18  89  80
!!red       #dc322f  1/1 red      160 #d70000 50  65  45 220  50  47   1  79  86
!!magenta   #d33682  5/5 magenta  125 #af005f 50  65 -05 211  54 130 331  74  83
!!violet    #6c71c4 13/5 brmagenta 61 #5f5faf 50  15 -45 108 113 196 237  45  77
!!blue      #268bd2  4/4 blue      33 #0087ff 55 -10 -45  38 139 210 205  82  82
!!cyan      #2aa198  6/6 cyan      37 #00afaf 60 -35 -05  42 161 152 175  74  63
!!green     #859900  2/2 green     64 #5f8700 60 -20  65 133 153   0  68 100  60

#define S_base03        #222222
#define S_base02        #073642
#define S_base01        #586e75
#define S_base00        #657b83
#define S_base0         #839496
#define S_base1         #93a1a1
#define S_base2         #eee8d5
#define S_base3         #fdf6e3
#define S_yellow        #b58900
#define S_orange        #cb4b16
#define S_red           #dc322f
#define S_magenta       #d33682
#define S_violet        #6c71c4
#define S_blue          #268bd2
#define S_cyan          #2aa198
#define S_green         #859900
*background:            S_base03
*foreground:            S_base00
*fading:                40
*fadeColor:             S_base03
*cursorColor:           S_base1
*pointerColorBackground:S_base01
*pointerColorForeground:S_base1

!! black dark/light
*color0:                S_base02
*color8:                S_base03

!! red dark/light
*color1:                S_red
*color9:                S_orange

!! green dark/light
*color2:                S_green
*color10:               S_base01

!! yellow dark/light
*color3:                S_yellow
*color11:               S_base00

!! blue dark/light
*color4:                S_blue
*color12:               S_base0

!! magenta dark/light
*color5:                S_magenta
*color13:               S_violet

!! cyan dark/light
*color6:                S_cyan
*color14:               S_base1

!! white dark/light
*color7:                S_base2
*color15:               S_base3

.xinirc

#!/bin/bash

xrdb -merge ~/.Xresources

xmodmap -e "keycode 115 = Super_L" -e "add mod4 = Super_L"
exec awesome

.bashrc

#
# ~/.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

alias ls='ls -h --color=auto'
PS1='[\u@\h \W]\$ '

Last edited by C. M. Harlequin (2012-08-07 04:09:28)


διπλοῦν ὁρῶσιν οἱ μαθόντες γράμματα.

Offline

#2 2012-08-07 02:31:05

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

Re: [SOLVED] Colours not displaying in bash prompt

Well ... you need to put colors in the prompt.

There are no color codes in your PS1.

edit: in retrospect I see this may look a bit abrupt.  I could instead give examples of how to put color codes into PS1, but there are so many examples out there I hope it is sufficient to point you in the right direction: the PS1= string needs to set which colors you want it to use, there are no defaults.  A quick googling will give plenty of examples.  Color codes will look like either \033[Xm or \e[Xm with X replaced by a suitable number (31-37 to get you started).  It's also good to enclose these in \[ \] pairs, any site with examples will probable explain why.

Last edited by Trilby (2012-08-07 02:36:37)


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

Offline

#3 2012-08-07 03:06:12

2ManyDogs
Forum Moderator
Registered: 2012-01-15
Posts: 4,645

Re: [SOLVED] Colours not displaying in bash prompt

You can also get a bunch of ideas for fancy colored prompts in this thread: https://bbs.archlinux.org/viewtopic.php?id=50885

I like to define the colors before I use them so I don't have to use the messy escape sequences in the actual prompt:

RS="\[\033[0m\]"    # reset
HC="\[\033[1m\]"    # hicolor
FBLE="\[\033[34m\]" # foreground blue
FRED="\[\033[31m\]" # foreground red

PS1="$HC$FBLE\w$RS $ "
#PS1="$HC$FRED[\u:$FBLE\w]$RS# "

The first prompt is my normal user prompt, and the next one (commented out) I use in root's .bashrc.

Last edited by 2ManyDogs (2012-08-07 03:11:42)


How to post. A sincere effort to use modest and proper language and grammar is a sign of respect toward the community.

Offline

#4 2012-08-07 03:58:44

C. M. Harlequin
Member
From: Australia
Registered: 2011-12-23
Posts: 35

Re: [SOLVED] Colours not displaying in bash prompt

Thanks for your replies, guys.

I realise I wasn't asking the right question.  I know how to modify my PS1, what I wanted to know was how (if it's possible) I can get coloured output in URxvt for commands like ls.  i.e. highlighting directories, files, executables, symlinks etc.

In retrospect, I don't know why I hadn't phrased my question like that.

Edit: @2ManyDogs, predefining colours is a nice tip!

2ManyDogs wrote:

I like to define the colors before I use them so I don't have to use the messy escape sequences in the actual prompt:

RS="\[\033[0m\]"    # reset
HC="\[\033[1m\]"    # hicolor
FBLE="\[\033[34m\]" # foreground blue
FRED="\[\033[31m\]" # foreground red

PS1="$HC$FBLE\w$RS $ "
#PS1="$HC$FRED[\u:$FBLE\w]$RS# "

Last edited by C. M. Harlequin (2012-08-07 04:08:19)


διπλοῦν ὁρῶσιν οἱ μαθόντες γράμματα.

Offline

#5 2012-08-07 04:02:46

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] Colours not displaying in bash prompt

man dir_colors

Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#6 2012-08-07 04:06:39

C. M. Harlequin
Member
From: Australia
Registered: 2011-12-23
Posts: 35

Re: [SOLVED] Colours not displaying in bash prompt

jasonwryan wrote:
man dir_colors

That's exactly what I was looking for!

Thanks!


διπλοῦν ὁρῶσιν οἱ μαθόντες γράμματα.

Offline

#7 2012-08-07 04:09:25

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOLVED] Colours not displaying in bash prompt

See trapd00rs colours for an incredibly detailed example...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB