LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > *BSD
User Name
Password
*BSD This forum is for the discussion of all BSD variants.
FreeBSD, OpenBSD, NetBSD, etc.

Notices


Reply
  Search this Thread
Old 01-14-2003, 02:10 AM   #1
L0CTiT3
LQ Newbie
 
Registered: Dec 2002
Posts: 6

Rep: Reputation: 0
Bash color shell


I've got the following code, to make colors in my shell...
But I don't know how to make it work...
Ive got FreeBSD 4.6-2....

Plz help me...

# Define some colors first:
red='\e[0;31m'
RED='\e[1;31m'
blue='\e[0;34m'
BLUE='\e[1;34m'
cyan='\e[0;36m'
CYAN='\e[1;36m'
NC='\e[0m' # No Color
# --> Nice. Has the same effect as using "ansi.sys" in DOS.

# Looks best on a black background.....
echo -e "${CYAN}This is BASH ${RED}${BASH_VERSION%.*}${CYAN} - DISPLAY on ${RED}$DISPLAY${NC}\n" date if [ -x /usr/games/fortune ]; then
/usr/games/fortune -s # makes our day a bit more fun.... :-)
fi

function _exit() # function to run upon exit of shell
{
clear
echo -e "${RED}Hasta la vista, baby${NC}"
}
trap _exit 0

#---------------
# Shell prompt
#---------------

function fastprompt()
{
unset PROMPT_COMMAND
{
LOAD=$(uptime|sed -e "s/.*: \([^,]*\).*/\1/" -e "s/ //g")
TIME=$(date +%H:%M)
}
case $TERM in
*term | rxvt )
#PS1="${cyan}[\$TIME \$LOAD]$NC\n$RED\u@\h # $NC" ;;
PS1="${RED}\u@\w> $NC" ;;

linux )
PS1="${cyan}[\$TIME - \$LOAD]$NC\n[\h \#] \w > " ;;
* )
PS1="[\$TIME - \$LOAD]\n[\h \#] \w > " ;;
esac
}

fastprompt

alias ll="gnuls -al --color=always"
alias ls="gnuls --color=always"
alias xs="cd"
alias vf="cd"
alias moer="more"
alias moew="more"
alias kk="ll"
alias ..="cd .."
alias cd..="cd .."
 
Old 01-14-2003, 06:46 AM   #2
Frustin
Member
 
Registered: May 2002
Location: Essex, UK
Distribution: Debian, Redhat, AIX 5L
Posts: 512

Rep: Reputation: 30
before you do all that can i just ask have you tried adding this to your .bashrc:

export LS_OPTIONS='--color=auto'
eval `dircolors`
alias ls='ls $LS_OPTIONS'
 
Old 01-14-2003, 11:21 AM   #3
L0CTiT3
LQ Newbie
 
Registered: Dec 2002
Posts: 6

Original Poster
Rep: Reputation: 0
Hey Frustin...
Where is the .bashrc located ?
I cant find it...
 
Old 01-15-2003, 02:06 AM   #4
Frustin
Member
 
Registered: May 2002
Location: Essex, UK
Distribution: Debian, Redhat, AIX 5L
Posts: 512

Rep: Reputation: 30
its in your (or should be) home directory. this is mine:

# .bashrc

export PS1='\h:\w\$ '
umask 022

# Adding colour discriptions to files and dirs

export LS_OPTIONS='--color=auto'
eval `dircolors`
alias ls='ls $LS_OPTIONS'

# User specific aliases and functions

alias mono='telnet meson.mono.org'

# Makes current directory title of the console

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
 
Old 12-22-2007, 09:42 AM   #5
sadiqdm
Member
 
Registered: Nov 2003
Location: London, UK
Distribution: openSUSE, Ubuntu
Posts: 358

Rep: Reputation: 35
Modifying the BASH prompt

This is the official HowTo - http://www.faqs.org/docs/Linux-HOWTO...mpt-HOWTO.html

And this is a more newbie friendly one - http://www.cyberciti.biz/tips/howto-...up-prompt.html

According to the latter, the location of bashrc is:
Quote:
Open /etc/bashrc (Redhat and friends) / or /etc/bash.bashrc (Debian/Ubuntu) or /etc/bash.bashrc.local (Suse and others)
I found the file /etc/bash.bashrc which reads the directory colours from a file /etc/DIR_COLORS

When I used Slackware I had a selection of "pretty" prompts, but now I generally use one of the other terms with built in colourisation.
 
Old 10-22-2008, 10:59 AM   #6
TextBrowserAddict
LQ Newbie
 
Registered: Aug 2005
Location: NY USA
Distribution: Slackware (12), Ubuntu, Crux?
Posts: 8

Rep: Reputation: 0
Thanks!

Quote:
Originally Posted by Frustin View Post
before you do all that can i just ask have you tried adding this to your .bashrc:

export LS_OPTIONS='--color=auto'
eval `dircolors`
alias ls='ls $LS_OPTIONS'
For me, this worked like a charm. Ofcourse, I had to make my home directory because I forgot to specifiy it with adduser.

Code:
sudo mkdir /home/myuser/
sudo chmod -R 700 /home/myuser/
sudo chown -R myuser /home/myuser/
sudo chgrp -R myusergroup /home/myuser/
sudo usermod -d /home/myuser/ myuser
Probably a better way to do that. Thanks!


Quote:
According to the latter, the location of bashrc is:
Quote:
Open /etc/bashrc (Redhat and friends) / or /etc/bash.bashrc (Debian/Ubuntu) or /etc/bash.bashrc.local (Suse and others)
I found the file /etc/bash.bashrc which reads the directory colours from a file /etc/DIR_COLORS
Editing this file modifies the global bash settings. On a multi-user system this is not reccomended. As with all ".progrc" files, if they do not exist in your home directory, feel free to create it.

Quote:
touch ~/.bashrc

Last edited by TextBrowserAddict; 10-22-2008 at 11:07 AM. Reason: Clarification
 
  


Reply

Tags
bash, colors


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash ls --color alias? tripmix Linux - Newbie 7 01-18-2005 04:49 AM
how do i chage the color of a file or a directory in a bash shell Paxmaster Linux - Software 3 10-17-2004 11:21 PM
how change text (and background) color within the bash shell? Xavius Linux - Newbie 4 03-29-2004 02:21 PM
Shell Color Tags nocturnal Linux - General 2 05-17-2003 04:13 PM
Shell Color Codes justmoon Linux - General 18 03-16-2003 01:22 PM

LinuxQuestions.org > Forums > Other *NIX Forums > *BSD

All times are GMT -5. The time now is 02:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration