LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Arch
User Name
Password
Arch This Forum is for the discussion of Arch Linux.

Notices


Reply
  Search this Thread
Old 08-19-2010, 07:27 PM   #1
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Rep: Reputation: 77
Colorized Bash Prompts


I get really frustrated that in Arch my directories are not blue / purple and my tarball files are not red. How can I colorized my ls output to be more convenient?
 
Old 08-19-2010, 08:06 PM   #2
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
You just need to edit /etc/DIR_COLORS.

For information about ANSI codes, go here: http://en.wikipedia.org/wiki/ANSI_escape_code

I recommend that you backup the file first before edit.
 
Old 08-20-2010, 10:51 PM   #3
mixtr
Member
 
Registered: Jul 2004
Location: Ottawa
Distribution: Arch, OpenBSD
Posts: 123

Rep: Reputation: 17
or put this in your .bashrc
alias ls='ls --color=auto"
 
Old 08-20-2010, 10:52 PM   #4
mixtr
Member
 
Registered: Jul 2004
Location: Ottawa
Distribution: Arch, OpenBSD
Posts: 123

Rep: Reputation: 17
or put this in your .bashrc
alias ls='ls --color=auto"
 
Old 08-21-2010, 11:42 AM   #5
papul1993
Member
 
Registered: Aug 2010
Location: India
Distribution: Archlinux
Posts: 56

Rep: Reputation: 1
# Check for an interactive session
[ -z "$PS1" ] && return

alias ls='ls --color=auto'
#PS1='[\u@\h \W]\$ '

#PS1='\[\e[1;32m\][\u@\h \W]\$\[\e[0m\] '

PS1='\[\e[1;31m\][\u@\h \W]\$\[\e[0m\] '

^^^^^
this in your ~/.bashrc might help
 
Old 09-09-2010, 07:23 PM   #6
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Rep: Reputation: 67
I'm not sure how useful this is, but I've always had
Code:
 eval $(dircolors -b)
in by bashrc (in addition to the ls --color alias)
 
Old 10-04-2010, 11:18 AM   #7
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Original Poster
Rep: Reputation: 77
My users all have .bashrc file however my root user doesn't. This is why I can't see colored 'ls' output. If my root use is missing his .bashrc, how can I have my root account be able to see colored 'ls' output?
 
Old 10-04-2010, 11:31 AM   #8
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Just make a .bashrc in your /root directory.
 
0 members found this post helpful.
Old 10-04-2010, 11:33 AM   #9
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Original Poster
Rep: Reputation: 77
What needs to be in that file so that root has a colorized 'ls' output?
 
Old 10-04-2010, 01:35 PM   #10
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: Slackware®
Posts: 13,923
Blog Entries: 44

Rep: Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158
Hi,

You could setup a .bashrc & .bash_profile for your user(s) & root;

Code:
sample .bash_profile;
 
 ~$ cat .bash_profile
 #-------
 # .bash_profile
 #08-30-06 12:21
 #
 # Source .bashrc
 if [ -f ~/.bashrc ]; then
         . ~/.bashrc
 fi
 #---------
Code:
 sample .bashrc;
 :~$ cat .bashrc
 
 #----------
 #.bashrc
 #08-30-06 12:20 
 
 # Add bin to path
 
 export PATH="$PATH:/sbin:/usr/sbin:$HOME/bin"
 
 #export PATH="$PATH:$HOME/bin"
 
 # Dynamic resizing
 shopt -s checkwinsize
 
 # Custom prompt
 #PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
 
 #08-29-06 11:40
 
 if [ `id -un` = root ]; then
    PS1='\[\033[1;31m\]\h:\w\$\[\033[0m\] '
  else
    PS1='\[\033[1;32m\]\h:\w\$\[\033[0m\] '
 fi
 
 #
 # Add color
 eval `dircolors -b`
 
 # User defined aliases
 alias cls='clear'
 alias clls='clear; ls'
 alias ll='ls -l'
 alias lsa='ls -A'
 alias lsg='ls | grep'
 alias lsp='ls -1 /var/log/packages/ > package-list'
 alias na='nano'
 alias web='links -g -download-dir ~/ www.google.com'
 
 #08-29-06 11:50
 
 #To clean up and cover your tracks once you log off
 #Depending on your version of BASH, you might have to use
 # the other form of this command
    trap "rm -f ~$LOGNAME/.bash_history" 0
 
 #The older KSH-style form
 #   trap 0 rm -f ~$LOGNAME/.bash_history
 #--------
The .bashrc is very useful!
 
1 members found this post helpful.
Old 10-04-2010, 02:24 PM   #11
carlosinfl
Senior Member
 
Registered: May 2004
Location: Orlando, FL
Distribution: Arch
Posts: 2,905

Original Poster
Rep: Reputation: 77
Thanks. I just did:

Code:
cp -a /etc/skel/.bash* /root/
 
Old 10-04-2010, 02:53 PM   #12
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
Quote:
Originally Posted by carlosinfl View Post
Thanks. I just did:

Code:
cp -a /etc/skel/.bash* /root/
Make sure your /etc/skel items you copied don't contain items like "PATH=$PATH:~/bin" running as root items like that are fairly dangerous, so be sure you read the files you copied in well and ensure they're doing what they should be done exactly.
 
Old 10-04-2010, 03:30 PM   #13
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: Slackware®
Posts: 13,923
Blog Entries: 44

Rep: Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158
Hi,

Quote:
Originally Posted by carlosinfl View Post
Thanks. I just did:

Code:
cp -a /etc/skel/.bash* /root/
You should use a method to differentiate root & user so the PATH is correctly set.

Look at the way the root is tested in the sample to set for color and the way the PATH is set early at the top of the script. You can modify to suit.
In '~' I setup for each user and modify to suit. If you have a lot of users then setup the defaults for system wide. This way you can setup a user to have specific needs with a '~/.bashrc' & '~/.bash_profile'.

 
  


Reply


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
[SOLVED] Color prompts screws bash ! MotherDawg Fedora 5 08-08-2010 02:56 PM
LXer: Colors and Prompts in Bash LXer Syndicated Linux News 0 03-11-2007 09:16 AM
BASH: How to answer command prompts using redirects ?? swedish_lunacy Linux - Newbie 1 07-25-2006 02:28 AM
Newbie questions:Bash Prompts newinlinux Linux - Newbie 9 03-10-2004 06:15 PM
Bash Prompts with xterm-style terminals somnium Linux - General 1 09-11-2003 08:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Arch

All times are GMT -5. The time now is 09:47 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