LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices


Reply
  Search this Thread
Old 05-28-2006, 06:04 PM   #1
Daws
Member
 
Registered: May 2006
Location: UK
Distribution: Debian
Posts: 447

Rep: Reputation: 39
Why does Debian host decide to ignore PS1 variable?


Hi, this is not a major issue, so please don't spend an undue amount of time on it. This is just something that has confused me in the past and still now. I am just wondering whether anybody else has noticed this and knows why.

Basically when setting up the build environment for the lfs user PS1 is set to "\u:\w\$ "
One day I suddenly thought wait a minute that should mean the prompt reads "username":"working directory"$ ... But it didnt... It was still the default Debian prompt ie "username"@"hostname":"working directory"$

Typing echo $PS1 showed: ${debian_chroot:+($debian_chroot)}\u@\h:\w\$

I know PS1 isnt amazingly important while building the toolchain, but it did lead me to wonder whether any other Debian related stuff was leaking into my supposedly "clean" environment.

Any thoughts?
 
Old 06-11-2006, 10:12 PM   #2
320mb
Senior Member
 
Registered: Nov 2002
Location: pikes peak
Distribution: Slackware, LFS
Posts: 2,577

Rep: Reputation: 48
well it appears your system is reading the default PS1 from /etc/profile--
so each user can customize their own PS1, there should be a .bash_profile in the users /home directory.......this is my .bash_profile
Code:
# ~/.bash_profile: executed by bash(1) for login shells.
# I keep this file simple and put everything in ~/.bashrc

# Sets the default permissions for files. 755 for directories 
and 644 for files.
umask 022

# include the configurations from ~/.bashrc 
if [ -f ~/.bashrc ]; then
    source ~/.bashrc
fi

export PATH=$PATH:/usr/X11R6/bin  
export PKG_CONFIG_PATH=/usr/X11R6/lib/pkgconfig 
export PATH=$PATH:/opt/kde/bin
my .bashrc contains the following as well as other configuration stuff
Code:
# Color Variables for Prompt
GRAD1='\333\262\261\260'
GRAD2='\260\261\262\333'
YLOBRN='\[\033[01;33;43m\]'
WHTBRN='\[\033[01;37;43m\]'
REDBRN='\[\033[01;31;43m\]'
BLUBRN='\[\033[01;34;43m\]'
GRNBRN='\[\033[00;32;43m\]'
REDBLK='\[\033[00;31;40m\]'
PPLBLK='\[\033[01;35;40m\]'
WHTBLK='\[\033[01;37;40m\]'
NONE='\[\033[00m\]'
HBLK='\[\033[00;30;30m\]'
HBLU='\[\033[01;34;34m\]'

BLU='\[\033[01;34m\]'
YEL='\[\033[01;33m\]'
WHT='\[\033[01;37m\]'
PRPL='\[\033[00;35m\]'
RED='\[\033[01;31m\]'
GRN='\[\033[01;32m\]'          
GRAY='\[\033[01;30m\]'
PINK='\[\033[01;35m\]'
NORM='\[\033[01;00;0m\]'
CYAN='\[\033[01;36m\]'


export GRAD1 GRAD2 YLOBRN WHTBRN REDBRN
BLUBRN GRNBRN REDBLK PPLBLK WHTBLK NONE 
HBLK HBLU BLU YEL WHT PRPL RED GRN GRAY 
PINK NORM CYAN

PS1="$CYAN[\s]$YEL[\t] $GRN\u$YEL@$BLU\h $WHT[\w]\$$NONE $NORM"
this makes for an easy to change colorful prompt.......

Last edited by 320mb; 06-11-2006 at 10:14 PM.
 
Old 06-13-2006, 07:02 PM   #3
Daws
Member
 
Registered: May 2006
Location: UK
Distribution: Debian
Posts: 447

Original Poster
Rep: Reputation: 39
Hi, thank you for replying and I am sorry for not replying sooner I'd actually forgotten I'd posted this, its been a while...

Anyway, back to the matter at hand this is the ~/.bash_profile for the "lfs" user

Code:
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash
and this is the ~./bashrc

Code:
set +h
umask 022
LFS=/mnt/lfs
LC_ALL=POSIX
PATH=/tools/bin:/bin:/usr/bin
export LFS LC_ALL PATH
yet despite the presence of these files I still get the wrong PS1...meh I don't think its very important anyway

PS thanks for showing me how to change the colours of the CLI, the idea had never really crossed my mind before now
 
Old 04-10-2018, 06:55 PM   #4
whereswaldon
LQ Newbie
 
Registered: Apr 2018
Posts: 4

Rep: Reputation: Disabled
I just encountered this, and I think I found a fix

I'll post here for posterity, as I'm sure that nobody is really expecting an answer at this point. Based on the Debian man pages for bash, the reason that PS1 is polluted by Debian is:

Quote:
When an interactive shell that is not a login shell is started, bash reads and exe-
cutes commands from /etc/bash.bashrc and ~/.bashrc, if these files exist. This may
be inhibited by using the --norc option. The --rcfile file option will force bash
to read and execute commands from file instead of /etc/bash.bashrc and ~/.bashrc.
It seems like you should be able to tweak the LFS ~/.bash_profile to use the --rcfile flag to fix this, but I haven't been able to make that work. However, using the --norc flag does prevent the PS1 value from being polluted. You then have to manually
Code:
$ source ~/.bashrc
in order to make sure all of the environment variables are set properly.

If anyone can explain why setting --rcfile /home/lfs/.bashrc still sources /etc/bash.bashrc, I'd be very grateful.
 
  


Reply

Tags
bash, debian, prompt



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
I just have to decide between these: Debian and Slackware JesusFreak84 Linux - Distributions 17 11-04-2005 10:55 AM
virtual host in debian davidhk Debian 3 08-31-2005 03:39 PM
PS1 variable wogga Red Hat 2 05-26-2004 05:39 PM
Setting PS1 variable for KDE Konsole shell (RH9) robertmarkbram Linux - Software 4 10-14-2003 07:38 PM
setting the PS1 enviroment variable in xterm qanopus Linux - General 2 04-29-2003 08:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

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