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

Notices


Reply
  Search this Thread
Old 04-15-2011, 07:55 AM   #1
alexbrui
Member
 
Registered: Nov 2009
Location: Ukraine
Distribution: Slackware 13.37
Posts: 38

Rep: Reputation: 0
No colors in ls output


Using Slackware 13.1 and rxvt-unicode as terminal emulator. There is no colors in ls output under user but running ls as root gives color output.

I check that /etc/profile.d/coreutils-dircolors.sh has executable bit, and LS_OPTIONS environment variable is correct
Code:
bash-4.1$ echo $LS_OPTIONS                     
-F -b -T 0 --color=auto
Running ls with --color option gives me color output. As I can see /etc/profile.d/coreutils-dircolors.sh should set up aliases for ls, dir and vdir commands but why this aliases don't work under user?
 
Old 04-15-2011, 08:02 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
Run the alias command to see what options are set in ls. If there is no ls alias add this to your startup (~/.bashrc is good)

alias ls='ls -F --color=auto'

The system version is this:
alias ls='ls -F --color=auto' 2>/dev/null

which won't give an error about colors in case you are logging in on a teletype.
 
Old 04-15-2011, 08:02 AM   #3
dh2k
Member
 
Registered: Jan 2006
Distribution: Slackware 13.0 (KDE 3.5.10 from 12.2; Xfce 4.6; Fluxbox); Slackware 13.1 (KDE 4.5)
Posts: 211

Rep: Reputation: 52
see my post:

http://www.linuxquestions.org/questi...prompt-798622/


You can add to your '~/.bashrc':

Code:
. /etc/profile

Last edited by dh2k; 04-15-2011 at 09:08 AM.
 
1 members found this post helpful.
Old 04-15-2011, 01:53 PM   #4
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,367

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
Subsequent bash shells inherit environment variables from the initial login shell (so running `. /etc/profile` isn't the best solution, since things like $XDG_CONFIG_DIRS end up having duplicated paths), but they do not inherit aliases. Therefore, you should place the aliases from /etc/profile.d/*.sh (or *.csh if you use a c shell) in your ~/.bashrc (or other non-login shell init file).
Code:
$ grep -vh "^[[:space:]]*#" /etc/profile.d/*.sh | grep alias
  alias ls='/bin/ls ${=LS_OPTIONS}'
  alias dir='/bin/ls ${=LS_OPTIONS} --format=vertical'
  alias vdir='/bin/ls ${=LS_OPTIONS} --format=long'
  alias ls='/bin/ls $LS_OPTIONS'
  alias dir='/bin/ls $LS_OPTIONS --format=vertical'
  alias vdir='/bin/ls $LS_OPTIONS --format=long'
alias d=dir
alias v=vdir
alias mc='. /usr/share/mc/bin/mc-wrapper.sh'
That output grabs all of the aliases in Slackware 13.1.
Code:
$ find /etc/profile.d/ -executable -name "*.sh" -exec grep -h alias {} \; | grep -v "^[[:space:]]*#"
should grab aliases only from executable .sh files in /etc/profile.d.

Last edited by T3slider; 04-15-2011 at 02:15 PM.
 
1 members found this post helpful.
Old 04-15-2011, 03:40 PM   #5
rfernandez
Member
 
Registered: Mar 2010
Location: Brazil
Distribution: Slackware64
Posts: 264

Rep: Reputation: 41
I always solve this problem by initiating the console as a login shell. In Konsole, I always use
Code:
/bin/bash -l
 
Old 04-16-2011, 01:21 AM   #6
alexbrui
Member
 
Registered: Nov 2009
Location: Ukraine
Distribution: Slackware 13.37
Posts: 38

Original Poster
Rep: Reputation: 0
Thanks guys. I create aliases in my ~/.bashrc file
 
Old 04-16-2011, 03:36 AM   #7
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019
Quote:
Originally Posted by T3slider View Post
Code:
$ grep -vh "^[[:space:]]*#" /etc/profile.d/*.sh | grep alias
  alias ls='/bin/ls ${=LS_OPTIONS}'
  alias dir='/bin/ls ${=LS_OPTIONS} --format=vertical'
  alias vdir='/bin/ls ${=LS_OPTIONS} --format=long'
  alias ls='/bin/ls $LS_OPTIONS'
  alias dir='/bin/ls $LS_OPTIONS --format=vertical'
  alias vdir='/bin/ls $LS_OPTIONS --format=long'
alias d=dir
alias v=vdir
alias mc='. /usr/share/mc/bin/mc-wrapper.sh'
That output grabs all of the aliases in Slackware 13.1.
Including some you wouldn't want in a .bashrc. Those first 3 ls aliases are variants for zsh that use a zsh specific syntax (it does word splitting differently)
.
Might be better just to do this as a one off and then edit the resulting .bashrc to taste
Code:
bash -l -c alias >> ~/.bashrc
or, if you don't want to tailor it and just want the aliases to be inherited as is from /etc/profile + /etc/profile.d/*.sh just add the following line to the top of your .bashrc
Code:
source <( bash -l -c alias )
I agree with your other points though. .bashrc is the appropriate place for them, and for the bash specific PS1= string which really shouldn't be exported from /etc/profile
(To see why exporting the PS1 string is a bad idea; run a 'bash -l' and then from within that shell start either ash or ksh.)



To tie things together nicely I use a ~/.bash_profile as follows:
Code:
case $- in
*i* )  # Interactive shell
       if [ -f ~/.bashrc ]; then
          source ~/.bashrc
       fi
       ;;
esac
and then my aliases/PS1 defined in ~/.bashrc

Last edited by GazL; 04-16-2011 at 03:38 AM.
 
2 members found this post helpful.
Old 04-16-2011, 01:56 PM   #8
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,367

Rep: Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843Reputation: 843
Woops, sorry for the oversight and thank you for correcting it. As for PS1, I guess Pat assumes that most people will stick to whatever shell is defined as their login shell, but I see your point.
 
  


Reply



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] Getting xdebug 2.0.5 switch text output to html output lhorace Linux - Server 1 11-01-2009 05:23 PM
How to configure Xterm colors if my xterm can support 256 colors n179911 Linux - Software 4 07-06-2009 02:28 AM
ps -eH | grep java output in a active passive clustered output johnkalikavunkal Linux - Server 2 01-30-2009 11:21 PM
How to change shell to have nice colors and look cool? Penguin likes cool colors! newtovanilla Linux - Newbie 3 11-28-2008 12:55 PM
the sound gives output when using mic but no output when run a music file medo Debian 0 04-19-2004 07:17 PM

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

All times are GMT -5. The time now is 06:45 PM.

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