Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Coloring bash
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
brettlpb
Apprentice
Apprentice


Joined: 27 May 2003
Posts: 197

PostPosted: Tue Jun 17, 2003 8:13 am    Post subject: Coloring bash Reply with quote

I was wondering how I would go about making it so that when I (for example) do 'ls' the directories listed would be in a different color than plain files, and maybe with a / after them.

I'm assuming this is a change in bash, and probably .bashrc? I've seen it in other distro's and just thought it was a nice feature ;)

Thanks in advance
Back to top
View user's profile Send private message
cebewee
n00b
n00b


Joined: 17 Jun 2003
Posts: 22

PostPosted: Tue Jun 17, 2003 8:42 am    Post subject: Re: Coloring bash Reply with quote

brettlpb wrote:
I was wondering how I would go about making it so that when I (for example) do 'ls' the directories listed would be in a different color than plain files, and maybe with a / after them.


Add
Code:
alias ls='ls --color=auto'

to your .bashrc or .bash_profile, or to /etc/profile for a system-wide default.

BTW: Is there a system wide configuration file for interactive shells, so I can get a colored ls for example after a 'su'?
Back to top
View user's profile Send private message
far
Guru
Guru


Joined: 10 Mar 2003
Posts: 394
Location: Stockholm, Sweden

PostPosted: Tue Jun 17, 2003 9:31 am    Post subject: Re: Coloring bash Reply with quote

cebewee wrote:
BTW: Is there a system wide configuration file for interactive shells, so I can get a colored ls for example after a 'su'?

/etc/profile, at least if you are using bash
_________________
The Porthole Portage Frontend
Back to top
View user's profile Send private message
cebewee
n00b
n00b


Joined: 17 Jun 2003
Posts: 22

PostPosted: Tue Jun 17, 2003 9:54 am    Post subject: Re: Coloring bash Reply with quote

far wrote:
cebewee wrote:
BTW: Is there a system wide configuration file for interactive shells, so I can get a colored ls for example after a 'su'?

/etc/profile, at least if you are using bash


No, /etc/profile is for login shells, but a xterm or su for example don't start the bash as a login shell.
Back to top
View user's profile Send private message
far
Guru
Guru


Joined: 10 Mar 2003
Posts: 394
Location: Stockholm, Sweden

PostPosted: Tue Jun 17, 2003 10:07 am    Post subject: Re: Coloring bash Reply with quote

cebewee wrote:
No, /etc/profile is for login shells, but a xterm or su for example don't start the bash as a login shell.

No, unless you do su -
_________________
The Porthole Portage Frontend
Back to top
View user's profile Send private message
georges
n00b
n00b


Joined: 04 Apr 2003
Posts: 9

PostPosted: Wed Jun 18, 2003 1:44 am    Post subject: Reply with quote

I dunno about xterms, but I know Konsole reads /etc/profile.
I just tested it :)
Back to top
View user's profile Send private message
Black
Apprentice
Apprentice


Joined: 10 Dec 2002
Posts: 158
Location: Québec, Canada

PostPosted: Wed Jul 23, 2003 1:28 am    Post subject: Reply with quote

What is /etc/profile supposed to be? Around July first, my Konsole's prompt suddently became:

Code:
bash-2.05b$


As for /etc/profile:

Code:
# /etc/profile:
# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/profile,v 1.23 2003/04/29 21:23:18 azarah Exp $

if [ -e "/etc/profile.env" ]
then
        . /etc/profile.env
fi

#077 would be more secure, but 022 is generally quite realistic
umask 077

if [ `/usr/bin/whoami` = 'root' ]
then
        # Do not set PS1 for dumb terminals
        if [ "$TERM" != 'dumb'  ] && [ -n "$BASH" ]
        then
                export PS1='\[\033[01;31m\]\h \[\033[01;34m\]\W \$ \[\033[00m\]'
        fi
        export PATH="/bin:/sbin:/usr/bin:/usr/sbin:${ROOTPATH}"
else
        # Do not set PS1 for dumb terminals
        if [ "$TERM" != 'dumb'  ] && [ -n "$BASH" ]
        then
                export PS1='\[\033[01;32m\]\u@\h \[\033[01;34m\]\W \$ \[\033[00m\]'
        fi
        export PATH="/bin:/usr/bin:${PATH}"
fi
unset ROOTPATH

if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]
then
        export INPUTRC="/etc/inputrc"
fi

# Extract the value of EDITOR
[ -z "$EDITOR" ] && EDITOR="`. /etc/rc.conf 2>/dev/null; echo $EDITOR`"
[ -z "$EDITOR" ] && EDITOR="`. /etc/conf.d/basic 2>/dev/null; echo $EDITOR`"
[ -z "$EDITOR" ] && EDITOR="/bin/nano"
export EDITOR


And if I type export PS1='\[\033[01;32m\]\u@\h \[\033[01;34m\]\W \$ \[\033[00m\]' , I get the colors I'm used to. This one has me baffled! :?
Back to top
View user's profile Send private message
Unne
l33t
l33t


Joined: 21 Jul 2003
Posts: 616

PostPosted: Wed Jul 23, 2003 1:59 am    Post subject: Reply with quote

Does your ~/.bashrc or ~/.bash_profile have something like
Code:
if [ -f /etc/profile ]; then
        source /etc/profile
fi
Back to top
View user's profile Send private message
Black
Apprentice
Apprentice


Joined: 10 Dec 2002
Posts: 158
Location: Québec, Canada

PostPosted: Wed Jul 23, 2003 2:13 am    Post subject: Reply with quote

Unne wrote:
Does your ~/.bashrc or ~/.bash_profile have something like
Code:
if [ -f /etc/profile ]; then
        source /etc/profile
fi


It didn't, so I added it, and it works. Thanks.

On the other hand, I checked on a backup from before it stopped working, and neither my .bashrc nor my .bash_profile has changed.
Back to top
View user's profile Send private message
ShiVa
n00b
n00b


Joined: 13 Sep 2002
Posts: 49
Location: Mannheim/Germany

PostPosted: Fri Aug 08, 2003 4:09 pm    Post subject: Reply with quote

Black wrote:
What is /etc/profile supposed to be? Around July first, my Konsole's prompt suddently became:

Code:
bash-2.05b$


As for /etc/profile:

Code:
# /etc/profile:
# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/profile,v 1.23 2003/04/29 21:23:18 azarah Exp $

if [ -e "/etc/profile.env" ]
then
        . /etc/profile.env
fi

#077 would be more secure, but 022 is generally quite realistic
umask 077

if [ `/usr/bin/whoami` = 'root' ]
then
        # Do not set PS1 for dumb terminals
        if [ "$TERM" != 'dumb'  ] && [ -n "$BASH" ]
        then
                export PS1='\[\033[01;31m\]\h \[\033[01;34m\]\W \$ \[\033[00m\]'
        fi
        export PATH="/bin:/sbin:/usr/bin:/usr/sbin:${ROOTPATH}"
else
        # Do not set PS1 for dumb terminals
        if [ "$TERM" != 'dumb'  ] && [ -n "$BASH" ]
        then
                export PS1='\[\033[01;32m\]\u@\h \[\033[01;34m\]\W \$ \[\033[00m\]'
        fi
        export PATH="/bin:/usr/bin:${PATH}"
fi
unset ROOTPATH

if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]
then
        export INPUTRC="/etc/inputrc"
fi

# Extract the value of EDITOR
[ -z "$EDITOR" ] && EDITOR="`. /etc/rc.conf 2>/dev/null; echo $EDITOR`"
[ -z "$EDITOR" ] && EDITOR="`. /etc/conf.d/basic 2>/dev/null; echo $EDITOR`"
[ -z "$EDITOR" ] && EDITOR="/bin/nano"
export EDITOR


And if I type export PS1='\[\033[01;32m\]\u@\h \[\033[01;34m\]\W \$ \[\033[00m\]' , I get the colors I'm used to. This one has me baffled! :?


==> you have to start konsole as a loginshell.
i think the command is konsole -ls .... or something like that (no KDE on this mashine)
_________________
never forget: god remains real until declared integer!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum