Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 08-30-2003, 09:32 AM   #1
Registered: Aug 2003
Location: Romania
Distribution: Ubuntu 6.06
Posts: 278

Rep: Reputation: 30
colored shell

I tried to make my promter colored by adding the next code to the .bashrc file
function myprompt{
local GRAD1=`tty|cut -d/ -f3`
local COLOR1="\[\033[1;34m\]"
local COLOR2="\[\033[0;34m\]"
local COLOR3="\[\033[1;36m\]"
local COLOR4="\[\033[0m\]"
local COLOR5="\[\033[1;32m\]"
local COLOR6="\[\033[0;32m\]"
case $TERM in
*term* | rxvt )
PS1="$COLOR1[$COLOR3\$(date +%I:%M) $COLOR3\u \w$COLOR1]$COLOR3\$$COLOR4 \[\033]0;\u \w\007\]" ;;
PS1="$COLOR1[$COLOR3\$(date +%I:%M) $COLOR3\u \w$COLOR1]$COLOR3\$$COLOR4 "
#PS2='[\w]\$ ';;
PS2="[$(date +%I:%M) \u \w]\$ \[\033]0;\u \w\007\]" ;;
and when I try to open the new shell it gives me the next error:
# bash: /home/spank/.bashrc: line 11: syntax error near unexpected token `local'
# bash: /home/spank/.bashrc: line 11: `local GRAD1=`tty|cut -d/ -f3`'
PS: how can I change the directory ls color.. I have RH9 and the blue color doesn't read very well
Old 08-30-2003, 09:57 AM   #2
LQ Guru
Registered: Feb 2003
Location: Sparta, NC USA
Distribution: Ubuntu 10.04
Posts: 5,141

Rep: Reputation: 60
Here is my .bashrc file for a comparison.

# Duron 950 uilleann .bashrc for user fancy
# User specific aliases and functions

# Change bash prompt. See the article
export PS1='\d \@ \[\e[32;1m\]\u\[\e[34;1m\]@\[\e[36;1m\]\H \[\e[34;1m\]\w\[\e[32;1m\] $ \[\e[0m\]'
# For the root account use this
# export PS1='\d \@ \[\e[31;1m\]\u\[\e[34;1m\]@\[\e[36;1m\]\H \[\e[34;1m\]\w\[\e[31;1m\] # \[\e[0m\]'

# Set paths
alias path='echo -e ${PATH//:/\\n}'

# Allow local users to use my X session
# xhost +local:

# Dialup, start fetchmail daemon and startx
alias x='/sbin/ifup ppp0;fetchmail -d 300;startx'

# Alter the ls command
alias ls='ls -ac'
alias lls='ls -lac'

# Become system administrator
alias god='su -'

# Connect/disconnect the internet by modem
alias dial='/sbin/ifup ppp0'
alias hangup='/sbin/ifdown ppp0'

# Launch links with my linux links page
alias links='links /pub/fancy/bookmarks.html'

# Power down/reboot
alias off='shutdown -h now'
alias boot='shutdown -r now'

# For nano editor because I forget which one I use in which distro
alias pico='nano -w'
alias nano='nano -w'

# Script needs to be on the bottom of the file or RH updates will fsck it up
# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
Old 08-30-2003, 06:40 PM   #3
Senior Member
Registered: Dec 2001
Location: 35.7480 N, 95.3690 W
Distribution: Debian, Gentoo, Red Hat, Solaris
Posts: 2,070

Rep: Reputation: 47
You asked this in another forum. This prompt is one I posted on another thread (and I am currently using in my .bashrc and it works fine) except you added a line which bash is telling you is getting the error.

Delete the line
local GRAD1=`tty|cut -d/ -f3`

and do
source .bashrc
Old 08-31-2003, 02:18 AM   #4
Registered: Apr 2003
Distribution: Debian Sarge
Posts: 259

Rep: Reputation: 30
You can change the directory color by editing the LS_COLORS environment variable. Just run
$ env
and you'll see it. The directory color is "di".


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
colored vlinks? synaptical LQ Suggestions & Feedback 2 07-15-2005 07:54 PM
colored ls in screen [GOD]Anck Slackware 2 03-22-2005 03:07 PM
colored shell devit Slackware 1 03-15-2004 09:23 AM
colored prompter/shell spank Linux - Newbie 2 08-30-2003 06:02 PM
Colored console jeucken Linux - Software 1 11-15-2002 05:13 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:33 AM.

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