LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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 01-03-2014, 10:55 PM   #1
Tachtory
Member
 
Registered: Dec 2011
Distribution: Mint, Slackware
Posts: 42

Rep: Reputation: Disabled
~/.bashrc, /etc/bash.bashrc files not read?


Trying to set permanent changes to the bash prompt in Slackware 14.

On my linux mint the colors are set in /etc/bash.bashrc

Reading the doc /usr/doc/Linux-HOWTOs/Bash-Prompt-HOWTO seems to suggest that prompt settings should be set in ~/.bashrc

I created the following .bashrc file but it does not seem to be read when logging in:

Code:
if [[ ${EUID} == 0 ]] ; then
    PS1="\[\033[01;31m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\]"
else
    PS1="\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\]"
fi
As far as I can tell there aren't any syntax errors with the assignment to PS1; if I set PS1 from the command line to one of the two prompts it works and shows up with color. I also tried without the if/clause and also tried moving the file to /etc/bash.bashrc but still no change in the prompt.
 
Old 01-03-2014, 11:19 PM   #2
astrogeek
Senior Member
 
Registered: Oct 2008
Distribution: Slackware: 12.1, 13.1, 14.1, 64-14.1, -current, FreeBSD-10
Posts: 1,770

Rep: Reputation: 601Reputation: 601Reputation: 601Reputation: 601Reputation: 601Reputation: 601
Your login is not loading the ~/.bashrc...

Slackware does not add (many) things not included in the upstream packages, and that includes the optional config files for bash added by some other distros.

For the order and precedence of bash configs, as always, see man bash (INVOCATION section).

But to get you going here is a quick summary:

Quote:
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login
option, it first reads and executes commands from the file /etc/profile, if that file exists. After
reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads
and executes commands from the first one that exists and is readable. The --noprofile option may be
used when the shell is started to inhibit this behavior.
So ~/.bashrc is not read when it is your login shell. Typically you will want to create a ~./bash_profile with the following lines:

Code:
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
Additionally, if you have system wide bash aliases or vars, put them in /etc/bashrc and add this to your ~/.bashrc:

Code:
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
That will give you a fairly common bash config stack, and load your ~/.bashrc.

Last edited by astrogeek; 01-03-2014 at 11:21 PM.
 
1 members found this post helpful.
Old 01-04-2014, 12:17 AM   #3
Tachtory
Member
 
Registered: Dec 2011
Distribution: Mint, Slackware
Posts: 42

Original Poster
Rep: Reputation: Disabled
Thank you! It was that missing .bash_profile. I see also I must create files in the /root/ directory too if I want a custom root prompt.
 
Old 01-04-2014, 12:25 AM   #4
astrogeek
Senior Member
 
Registered: Oct 2008
Distribution: Slackware: 12.1, 13.1, 14.1, 64-14.1, -current, FreeBSD-10
Posts: 1,770

Rep: Reputation: 601Reputation: 601Reputation: 601Reputation: 601Reputation: 601Reputation: 601
Quote:
Originally Posted by Tachtory View Post
Thank you! It was that missing .bash_profile. I see also I must create files in the /root/ directory too if I want a custom root prompt.
Great! Yes, you have to add the bash configs for all users, including root.

If you have multiple users on the system you might want to create the .bash_profile and .bashrc in /etc/skel/ when you first install, then any users you create will get their own copy.
 
1 members found this post helpful.
  


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
Messed up .bashrc. Please read. jcunit Linux - Newbie 6 04-03-2013 12:28 AM
How to use my /home/kangjoo/.bashrc rather than root/.bashrc kangjoo.lee Linux - Newbie 2 11-05-2012 03:38 PM
.bashrc / .bash_profile /etc/profile /etc/bashrc deadeyes Red Hat 2 02-13-2010 11:22 AM
bashrc not being read ... entirely h/w Linux - General 6 02-02-2008 02:42 PM
Setting path: /etc/profile, /etc/bashrc or ~/.bashrc Swakoo Linux - General 1 08-07-2007 10:59 PM


All times are GMT -5. The time now is 06:42 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration