You are not logged in.

#1 2015-11-02 06:03:04

Temetka
Member
From: Sol System, Western Spiral Arm
Registered: 2015-10-14
Posts: 549

[SOLVED] Help with .bashrc colors

[  --- Moved from "Tips & etc ----  by MOD (It is a help request, not a Tip wink ) ]

I put this here because isn't the .bashrc file kind of script like?

So anyway. I have 3 .bashrc's I have used over the years. Mainly kind of aped other peoples work and now I am trying to create one with a color pallete to match my conky. I am unable to locate a universal color code page except for this:

https://wiki.archlinux.org/index.php/Co … t_and_Bash

But it seems .bashrc color codes are pretty loose in terms of how they are defined. Whereas in conky I can use hex values to represent colors I can't do that in the .bashrc file. So looking up color codes to exactly match what I have is rather difficult. Unless someone knows of .bashrc color code to hex convertor (or vice versa)

Let me submit 2 examples of what I am referring to:

black='\e[0;30m'
blue='\e[0;34m'
green='\e[0;32m'
cyan='\e[0;36m'
red='\e[0;31m'
export black="\[\033[0;38;5;0m\]"
export red="\[\033[0;38;5;1m\]"
export orange="\[\033[0;38;5;130m\]"
export green="\[\033[0;38;5;2m\]"
export yellow="\[\033[0;38;5;3m\]

Both examples work fine. But how do I convert the a code from the top section to a code in the lower section? I ask because I'm not writing a .bashrc by hand. Although thinking about it, I probably should.

I'd like to control the output of "ls" like this

drwxr-xr-x 2 temetka temetka 4.0K Nov  1 21:06 Downloads
[----Gray----] [-----Slate Gray--------] [----greyish--] [----aqua--]

Files and folder with a standard "ls" or "ls -a" show with different colors. I.E. a script will have a different color than a folder, etc.

If it helps here are the hex values of the colors in my conky I am working with:

color0 B0E0E6 # PowderBlue
color1 6E7F80 # Light Blue Gray
color2 536872 # Blue-ish
color3 007777 # Aqua
color4 536878 # Mist
color5 CCCCCC # Gray80
color6 543F9F # Dark Blue
color7 777777 # Greyish
color8 888888 # Steel Grey
color9 708090 # Hex Slate Gray

In the past I have used this site to look up color codes:

http://www.color-hex.com/

If you copy one of the hex codes I listed and search it there, it gives a table of other codes. I'm not sure if any of those codes will work in a .bashrc file.

Any help would be appreciated. I'm probably in over my head, but this is fun. smile

Last edited by Temetka (2015-11-02 09:51:17)


The meaning of life is to just be alive. It is so plain and so obvious
    and so simple. And yet everybody rushes aroound in a great panic
             as if it were necessary to achieve something beyond themselves.
                                                                                                             - Alan Watts

Offline

#2 2015-11-02 07:05:10

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,652
Website

Re: [SOLVED] Help with .bashrc colors

If you want some more to think about: http://mywiki.wooledge.org/BashFAQ/037


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Offline

#3 2015-11-02 07:32:42

ohnonot
...again
Registered: 2015-09-29
Posts: 5,592

Re: [SOLVED] Help with .bashrc colors

Temetka wrote:

I put this here because isn't the .bashrc file kind of script like?

.bashrc works like any other bash script.

But it seems .bashrc color codes are pretty loose in terms of how they are defined. Whereas in conky I can use hex values to represent colors I can't do that in the .bashrc file.

exactly.
you have 16 colors (8 base colors, 8 "bright" colors), plus sometimes 2 seperate foreground/background colors.
you cannot customise these colors in bash.
full stop.
this happens through your terminal emulator, which takes customised colors from some other file.
so you can tell it e.g.: "bash says "bright red" and i want you to assign hex color #874523 to that"
in the case of urxvt it's ~/.Xresources.

I'd like to control the output of "ls" like this

drwxr-xr-x 2 temetka temetka 4.0K Nov  1 21:06 Downloads
[----Gray----] [-----Slate Gray--------] [----greyish--] [----aqua--]

Files and folder with a standard "ls" or "ls -a" show with different colors. I.E. a script will have a different color than a folder, etc.

if you're not happy with the color choices ls makes, you have to rewrite it.
has been done, by the way: https://github.com/trapd00r/ls--/ (you must understand that this is a seperate application)

Offline

#4 2015-11-02 07:41:34

Temetka
Member
From: Sol System, Western Spiral Arm
Registered: 2015-10-14
Posts: 549

Re: [SOLVED] Help with .bashrc colors

So if I understand that correctly, I can use matching hex codes in the `/.Xresources file for "ls" output?

Let me put it another way. I use whatever terminal emulator BL RC1 shipped with. In there I can define color schemes. Are those schemes written to or read from the `/.Xresources file?

This is all new to me.


The meaning of life is to just be alive. It is so plain and so obvious
    and so simple. And yet everybody rushes aroound in a great panic
             as if it were necessary to achieve something beyond themselves.
                                                                                                             - Alan Watts

Offline

#5 2015-11-02 09:26:20

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 9,093
Website

Re: [SOLVED] Help with .bashrc colors

Temetka wrote:

I use whatever terminal emulator BL RC1 shipped with. In there I can define color schemes. Are those schemes written to or read from the `/.Xresources file?

No, terminator uses it's own configuration files.

BunsenLabs also has rxvt-unicode and this is configured via ~/.Xresources (or ~/.Xdefaults)

Offline

#6 2015-11-02 09:50:49

Temetka
Member
From: Sol System, Western Spiral Arm
Registered: 2015-10-14
Posts: 549

Re: [SOLVED] Help with .bashrc colors

Putting this here for documentation:

Terminator config as found in /home/temetka/.config/terminator/config

[global_config]
  title_transmit_bg_color = "#000000"
  title_inactive_bg_color = "#000000"
[keybindings]
  hide_window = <Shift><Control>a
[profiles]
  [[default]]
    scrollbar_position = hidden
    palette = "#000000:#aa0000:#00aa00:#aa5500:#0000aa:#aa00aa:#00aaaa:#aaaaaa:#555555:#ff5555:#55ff55:#ffff55:#5555ff:#ff55ff:#55ffff:#ffffff"
    background_image = None
    background_darkness = 0.83
    scrollback_lines = 5000
    background_type = transparent
    use_system_font = False
    cursor_color = "#0be620"
    foreground_color = "#017abf"
    scroll_on_output = False
    show_titlebar = False
    color_scheme = custom
    font = Monospace 10
    scrollback_infinite = True
[layouts]
  [[default]]
    [[[child1]]]
      type = Terminal
      parent = window0
    [[[window0]]]
      type = Window
      parent = ""
[plugins]

/home/temetka/.Xresources

! font settings --------------------------------------------------------------

Xft.autohint: true
Xft.antialias: true
Xft.hinting: true
Xft.hintstyle: hintslight
!Xft.dpi: 96
Xft.rgba: rgb
Xft.lcdfilter: lcddefault

! xscreensaver ---------------------------------------------------------------

!font settings
xscreensaver.Dialog.headingFont:        -*-fixed-medium-r-*-*-14-*-*-*-*-*-*-*
xscreensaver.Dialog.bodyFont:           -*-fixed-medium-r-*-*-14-*-*-*-*-*-*-*
xscreensaver.Dialog.labelFont:          -*-fixed-medium-r-*-*-14-*-*-*-*-*-*-*
xscreensaver.Dialog.unameFont:          -*-fixed-medium-r-*-*-14-*-*-*-*-*-*-*
xscreensaver.Dialog.buttonFont:         -*-fixed-medium-r-*-*-14-*-*-*-*-*-*-*
xscreensaver.Dialog.dateFont:           -*-fixed-medium-r-*-*-12-*-*-*-*-*-*-*
xscreensaver.passwd.passwdFont:         -*-fixed-medium-r-*-*-14-*-*-*-*-*-*-*
!general dialog box (affects main hostname, username, password text)
xscreensaver.Dialog.foreground:         #101010
xscreensaver.Dialog.background:         #D8D8D8
xscreensaver.Dialog.topShadowColor:     #D8D8D8
xscreensaver.Dialog.bottomShadowColor:  #D8D8D8
xscreensaver.Dialog.Button.foreground:  #101010
xscreensaver.Dialog.Button.background:  #E5E5E5
!username/password input box and date text colour
xscreensaver.Dialog.text.foreground:    #101010
xscreensaver.Dialog.text.background:    #E5E5E5
xscreensaver.Dialog.internalBorderWidth:24
xscreensaver.Dialog.borderWidth:        0
xscreensaver.Dialog.shadowThickness:    2
!timeout bar (background is actually determined by Dialog.text.background)
xscreensaver.passwd.thermometer.foreground:  #101010
xscreensaver.passwd.thermometer.background:  #2E2E2E
xscreensaver.passwd.thermometer.width:       8

! urxvt -------------------------------------------

URxvt.font: xft:Monospace:pixelsize=12
URxvt.letterSpace: -1

! Window size and position
!urxvt*geometry: 60x22+50+100
! Window size, let the Window Manager position it
urxvt*geometry: 60x22

URxvt*scrollstyle: plain
URxvt*scrollBar: true
URxvt*scrollBar_right: true
URxvt*iconFile: /usr/share/icons/Faenza-Bunsen/apps/48/utilities-terminal.png

! Grey theming
!URxvt*background: #cecece
!URxvt*foreground: #101010
! Terminator Crunchbang colours
URxvt*background: #2e3436
URxvt*foreground: #d8d8d8

! scrollback buffer lines - 65535 is max (64 is default)
URxvt*saveLines:16384

URxvt*color0: #000000
URxvt*color1: #9e1828
URxvt*color2: #aece92
URxvt*color3: #968a38
URxvt*color4: #414171
URxvt*color5: #963c59
URxvt*color6: #418179
URxvt*color7: #bebebe
URxvt*color8: #666666
URxvt*color9: #cf6171
URxvt*color10: #c5f779
URxvt*color11: #fff796
URxvt*color12: #4186be
URxvt*color13: #cf9ebe
URxvt*color14: #71bebe
URxvt*color15: #ffffff

Well, it looks like I might have found the colors I am after. I can edit the hex values in the .Xresources file.

Between that and the colors in .bashrc I should be good.

Archwiki mentions 256 color support in .bashrc from here:

https://wiki.archlinux.org/index.php/Color_Bash_Prompt

Thanks for the help guys.

Last edited by Temetka (2015-11-02 09:53:35)


The meaning of life is to just be alive. It is so plain and so obvious
    and so simple. And yet everybody rushes aroound in a great panic
             as if it were necessary to achieve something beyond themselves.
                                                                                                             - Alan Watts

Offline

#7 2015-11-04 17:56:47

Horizon_Brave
Operating System: Linux-Nettrix
Registered: 2015-10-18
Posts: 1,473

Re: [SOLVED] Help with .bashrc colors

The Arch Linux wiki, provides the list:

txtblk='\e[0;30m' # Black - Regular
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
txtpur='\e[0;35m' # Purple
txtcyn='\e[0;36m' # Cyan
txtwht='\e[0;37m' # White
bldblk='\e[1;30m' # Black - Bold
bldred='\e[1;31m' # Red
bldgrn='\e[1;32m' # Green
bldylw='\e[1;33m' # Yellow
bldblu='\e[1;34m' # Blue
bldpur='\e[1;35m' # Purple
bldcyn='\e[1;36m' # Cyan
bldwht='\e[1;37m' # White
unkblk='\e[4;30m' # Black - Underline
undred='\e[4;31m' # Red
undgrn='\e[4;32m' # Green
undylw='\e[4;33m' # Yellow
undblu='\e[4;34m' # Blue
undpur='\e[4;35m' # Purple
undcyn='\e[4;36m' # Cyan
undwht='\e[4;37m' # White
bakblk='\e[40m'   # Black - Background
bakred='\e[41m'   # Red
bakgrn='\e[42m'   # Green
bakylw='\e[43m'   # Yellow
bakblu='\e[44m'   # Blue
bakpur='\e[45m'   # Purple
bakcyn='\e[46m'   # Cyan
bakwht='\e[47m'   # White
txtrst='\e[0m'    # Text Reset

Couldn't you set each of these to an alias and use the names instead of the color codes?


"I have not failed, I have found 10,000 ways that will not work" -Edison

Offline

#8 2015-11-05 08:22:11

Temetka
Member
From: Sol System, Western Spiral Arm
Registered: 2015-10-14
Posts: 549

Re: [SOLVED] Help with .bashrc colors

Possibly, I never really considered that option. I was just looking for 16 color codes I needed to match my conky. Which that list (and others) provide. Thanks for the list though, that will come in handy later.


The meaning of life is to just be alive. It is so plain and so obvious
    and so simple. And yet everybody rushes aroound in a great panic
             as if it were necessary to achieve something beyond themselves.
                                                                                                             - Alan Watts

Offline

Board footer

Powered by FluxBB