View previous topic :: View next topic |
Author |
Message |
brettlpb Apprentice
Joined: 27 May 2003 Posts: 197
|
Posted: Tue Jun 17, 2003 8:13 am Post subject: Coloring bash |
|
|
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 |
|
|
cebewee n00b
Joined: 17 Jun 2003 Posts: 22
|
Posted: Tue Jun 17, 2003 8:42 am Post subject: Re: Coloring bash |
|
|
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 |
|
|
far Guru
Joined: 10 Mar 2003 Posts: 394 Location: Stockholm, Sweden
|
Posted: Tue Jun 17, 2003 9:31 am Post subject: Re: Coloring bash |
|
|
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 |
|
|
cebewee n00b
Joined: 17 Jun 2003 Posts: 22
|
Posted: Tue Jun 17, 2003 9:54 am Post subject: Re: Coloring bash |
|
|
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 |
|
|
far Guru
Joined: 10 Mar 2003 Posts: 394 Location: Stockholm, Sweden
|
Posted: Tue Jun 17, 2003 10:07 am Post subject: Re: Coloring bash |
|
|
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 |
|
|
georges n00b
Joined: 04 Apr 2003 Posts: 9
|
Posted: Wed Jun 18, 2003 1:44 am Post subject: |
|
|
I dunno about xterms, but I know Konsole reads /etc/profile.
I just tested it |
|
Back to top |
|
|
Black Apprentice
Joined: 10 Dec 2002 Posts: 158 Location: Québec, Canada
|
Posted: Wed Jul 23, 2003 1:28 am Post subject: |
|
|
What is /etc/profile supposed to be? Around July first, my Konsole's prompt suddently became:
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 |
|
|
Unne l33t
Joined: 21 Jul 2003 Posts: 616
|
Posted: Wed Jul 23, 2003 1:59 am Post subject: |
|
|
Does your ~/.bashrc or ~/.bash_profile have something like Code: | if [ -f /etc/profile ]; then
source /etc/profile
fi |
|
|
Back to top |
|
|
Black Apprentice
Joined: 10 Dec 2002 Posts: 158 Location: Québec, Canada
|
Posted: Wed Jul 23, 2003 2:13 am Post subject: |
|
|
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 |
|
|
ShiVa n00b
Joined: 13 Sep 2002 Posts: 49 Location: Mannheim/Germany
|
Posted: Fri Aug 08, 2003 4:09 pm Post subject: |
|
|
Black wrote: | What is /etc/profile supposed to be? Around July first, my Konsole's prompt suddently became:
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 |
|
|
|