LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   ~/.bashrc ; Editing. (https://www.linuxquestions.org/questions/linux-newbie-8/%7E-bashrc-%3B-editing-514777/)

User Name. 12-29-2006 11:27 PM

~/.bashrc ; Editing.
 
How do I change of color current directory, input text, and such in ~/.bashrc ? Thanks.

PatrickNew 12-29-2006 11:44 PM

this link should just about cover it.
http://news.softpedia.com/news/How-t...pt-40033.shtml

User Name. 12-30-2006 11:13 AM

How do I change the colors of output text? So directorys are blue, executables are green, and such?

This is my current .bashrc file:
Code:

# Defines colors
Black="$(tput setaf 0)"
BlackBG="$(tput setab 0)"
DarkGrey="$(tput bold ; tput setaf 0)"
LightGrey="$(tput setaf 7)"
LightGreyBG="$(tput setab 7)"
White="$(tput bold ; tput setaf 7)"
Red="$(tput setaf 1)"
RedBG="$(tput setab 1)"
LightRed="$(tput bold ; tput setaf 1)"
Green="$(tput setaf 2)"
GreenBG="$(tput setab 2)"
LightGreen="$(tput bold ; tput setaf 2)"
Brown="$(tput setaf 3)"
BrownBG="$(tput setab 3)"
Yellow="$(tput bold ; tput setaf 3)"
Blue="$(tput setaf 4)"
BlueBG="$(tput setab 4)"
LightBlue="$(tput bold ; tput setaf 4)"
Purple="$(tput setaf 5)"
PurpleBG="$(tput setab 5)"
Pink="$(tput bold ; tput setaf 5)"
Cyan="$(tput setaf 6)"
CyanBG="$(tput setab 6)"
LightCyan="$(tput bold ; tput setaf 6)"
NC="$(tput sgr0)" # No Color

# Displays [time][host>dir]$
PS1='\[$White\][\[$Red\]\T\[$White\]][\[$Purple\]\h\[$White\]>\w]\$\[$Green\] '

I think it's a bit overdone, but it looks nice.

edit:
And I want to create a command that will display distro, kernel and such. An alias would work.
Alot like this:
http://news.softpedia.com/images/rev...img2-large.png

Nylex 12-30-2006 11:46 AM

Quote:

Originally Posted by User Name.
How do I change the colors of output text? So directorys are blue, executables are green, and such?

Set the LS_COLORS environment variable, see man dircolors for info.

User Name. 12-30-2006 01:12 PM

Quote:

Originally Posted by Nylex
Set the LS_COLORS environment variable, see man dircolors for info.

I don't exactly under stand what you mean. I checked the man, it didn't give much information. The --help file gave the same as man. Can you explain this better?

PatrickNew 12-30-2006 01:33 PM

to handle the LS_COLORS, it is easier to add to the end of your bashrc the line
alias ls="ls --color=auto"

User Name. 12-30-2006 01:58 PM

Thanks, but is there anyway that I could make it so a special file is a cetain color though? Like pictures? Or text files?

PatrickNew 12-30-2006 02:31 PM

Ah, now I understand the question. Unfortunately I don't know the answer. Sorry.

bartonski 01-01-2007 12:52 AM

The command 'ls' uses the environment variable $LS_COLORS to determine display of colors.

on my system, it looks like this:

Quote:

Code:

>echo $LS_COLORS
no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:


LS_COLORS is set by the program dircolors.

The default colors used by dircolors are compiled in, and can be viewed by using the command

dircolors --print-database

The output from this command can be re-directed to a file, the output can be modified and used as the control file for dircolors.

Here's the step by step:

Quote:

Code:

dircolors --print-database > $HOME/.dircolors

vim $HOME/.dircolors

# edit $HOME/.dircolors, change colors however you want.


Then edit $HOME/.bashrc, put the following commands in:

Quote:

Code:

LS_COLORS = 'dircolors -b $HOME/.dircolors'
alias ls='ls -hF --color=tty'


now... I haven't actually done any of this, you may have to jigger a command or two, but I believe that I'm at least 95% of the way there.

By the way, the documentation for dircolors can be found by using 'info dircolors'.


All times are GMT -5. The time now is 09:23 AM.