LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Shell Prompts and root ls colouring (https://www.linuxquestions.org/questions/slackware-14/shell-prompts-and-root-ls-colouring-72472/)

iantri 07-13-2003 10:45 PM

Shell Prompts and root ls colouring
 
Hello. I have two questions. First of all, normally when I am
at a console I get the default shell prompt, which is like iantri@waffle:/etc$. However, when I open an xterm I only f
get sh-2.05b. How do I set things so that I get the same style shell prompt under an xterm?

Also, when I log in as root I get the pretty colouring on my
ls listings. But, when I su to root I don't. Why does this happen like this, and how can I change it so I get coloured
ls listings either way?

Thank you.
Ian Trider

f

slakmagik 07-13-2003 11:04 PM

Add -ls to whatever arguments start your xterm, whether in a window manager menu or .xinitrc or whatever. There may be a better way, but that makes it a log-in shell and causes it to source your bash configuration files.

Not sure about the second one except that it's probably a similar thing. You might have a DIR_COLORS entry in your user bash files and not in root's or something.

contrasutra 07-13-2003 11:05 PM

First, searching the forums should give you the answer to both those questions.

The first one: You get that [user]@[host]: When youve just switched users or logged in. So logging in in an xterm will give you that.

Second question, the easiest way to get color is to make an alias to "ls --color"

make a file: ~/.bashrc and add:

alias "ls"="ls --color"


Save, and restart the terminal.

iantri 07-14-2003 09:34 AM

Thank you for your answers although I think I found out what I need this morning while looking through some Linux from Scratch information.

http://beyond.linuxfromscratch.org/v...s/profile.html

I think what this is saying is that .bash_profile (or /etc/profile) is invoked when you login, and that .bashrc (or /etc/bashrc) is invoked when bash is started, but is not a login shell.

This would mean that if I am iantri and I su to root, it invokes bashrc which I'm assuming does not have ls colours set. This also means that if I am iantri and I open an xterm that bash is invoked, but not as a login shell and so bashrc is used.

If I put my PS1 variable and the alias from LS to LS --colour which are in /etc/profile (or my .bash_profile) I should get the same things either way, correct?

Thank you,
Ian Trider.

fancypiper 07-14-2003 09:59 AM

I put it in my user's .bashrc file:
Code:

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

# Change bash prompt. See the article
# http://www-106.ibm.com/developerwork.../l-tip-prompt/
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'


Freaek 07-17-2003 12:16 AM

Whenever I've wanted to su to root and have colours, I've just used su - instead of just plain su.

Works for me! :)

m0rl0ck 07-17-2003 03:10 AM

I like machine specific prompts with the time included, this one has reverse video:

PS1="\033[1;45m\]\h:\[\033[0;44m\]\A\[\033[0;36m\]\[\033[1;41m\]:\W\[\033[0m\]\[
\033[1;31m\]> \[\033[0m\]"

much the same, no reverse video:

PS1="[\033[1;32m\]\h:\[\033[1;34m\]\A\[\033[0;35m\]\[\033[1;35m\]:\W\[\033[0m\]]
\[\033[1;31m\]$ \[\033[0m\]"

stargazerff 07-27-2003 03:39 PM

PS1 Variable on Console and in xterm
 
I found an easier way to change the PS1 Environmental Variable.
I modify the /etc/profile file to what ever prompt I want for the console eg. PS1-'[\u@h:\W]$'
This gives me the following prompt:
[stargazerff@darkstar:stargazerff]$
It shows who is logged in and the present working directory.
As far as the xterm goes, I put the same line except for 1 difference ,in xinitrc.twm right before the line that says
&twm
export PS1='[\u@\h:\W]$'
Now I get the same prompt in the Xwindow as I get on the console.
Hope this helps.
Ralph

Noryungi 07-28-2003 04:06 AM

This is what I use for *every* user:

dircolors > ~/.bashrc

Short, sweet, and to the point... :D

boscorelle 09-11-2003 04:50 PM

Help with Bash (shell script)
 
Does anyone know how to enable the time and the current working directory to be displayed once I login to use bash; someone said something about .bashrc; how do I access and edit this file to get it display what I need. -thanks

zsejk 09-11-2003 08:48 PM

My reasons for using the ls command really do not include being able to see a pretty display of colors.

:D

-zsejk


All times are GMT -5. The time now is 04:11 PM.