LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 03-29-2004, 01:29 PM   #1
Shade
Senior Member
 
Registered: Mar 2003
Location: Burke, VA
Distribution: RHEL, Slackware, Ubuntu, Fedora
Posts: 1,418
Blog Entries: 1

Rep: Reputation: 46
Bash preferences within X


Hey all,

I'm not exactly a noob, and I've searched this, but am looking for something in particular.

To get my xterms, aterms, and the like to display the right prompt, ls colors, etc, I've added

source /etc/profile

to .bashrc

This works fine as long as I stay in X. However, logging in to normal text console will display the fortune twice, as it's being read first from /etc/profile, then read again from .bashrc ...

Is there a simple way to have .bashrc source /etc/profile if I'm on a non-login shell, but not if I'm logging in from console?

--Shade

PS -- It's just the idea of redundancy that I'm trying to get around. I realize I could simply put PS1, my aliases and ls -color and so forth, but I'm trying to find a way to read the system-wide /etc/profile file only once, in all cases.
 
Old 03-29-2004, 03:01 PM   #2
ringwraith
Senior Member
 
Registered: Sep 2003
Location: Indiana
Distribution: Slackware-current
Posts: 1,244

Rep: Reputation: 47
man bash
 
Old 03-29-2004, 03:14 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,978
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
man bash
/.bashrc

The thing is that bash gets invoked differently
depending on whether a shell is a login-shell
or not... by default in X the shell's aren't login-
shells, thus evaluate .bashrc but not /etc/profile.

The bash on a console, on the other hand, is
a login-shell and will evaluate /etc/profile
and ~/bash_profile, ~/.bash_login and ~/.profile
(in this order, and stop at the first one found).

It shouldn't be using your ~/.bashrc, though,
which makes having fortune twice a bit strange.


Cheers,
Tink
 
Old 03-29-2004, 03:16 PM   #4
Shade
Senior Member
 
Registered: Mar 2003
Location: Burke, VA
Distribution: RHEL, Slackware, Ubuntu, Fedora
Posts: 1,418
Blog Entries: 1

Original Poster
Rep: Reputation: 46
Right, I thought it was strange...

I'm grokking the bash man page, again...

--Shade
 
Old 03-29-2004, 03:27 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,978
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Do you happen to have one of the other
three I mentioned as well, and sourcing
that from .bashrc ?


Cheers,
Tink
 
Old 03-29-2004, 03:31 PM   #6
Shade
Senior Member
 
Registered: Mar 2003
Location: Burke, VA
Distribution: RHEL, Slackware, Ubuntu, Fedora
Posts: 1,418
Blog Entries: 1

Original Poster
Rep: Reputation: 46
I'm a retard.

I had 'source /etc/profile' in .bash_profile, not .bashrc
.bash_profile is read only by a login shell...

From the O'Reilly Learning the Bash Shell book:
Quote:
If you start up a new shell by typing bash on the command line, it will attempt to read commands from the file .bashrc. This scheme allows you the flexibility to separate startup commands needed at login time from those you might need when you run a subshell. If you need to have the same commands run regardless of whether it is a login shell or subshell, you can just use the source fommand from within .bash_profile to execute .bashrc.
I understand the scheme now. .bashrc is read for subshells, .bash_profile for login shells. Login shells begin by reading /etc/profile, and continue on to read .bash_profile... That's where my problem was. All I need is the .bashrc to source /etc/profile, and subshells will behave the same.

--Shade


Last edited by Shade; 03-29-2004 at 03:39 PM.
 
Old 03-29-2004, 03:41 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,978
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Or invoke the xterm (rxvt, konsole, whatever ...) with
a flag that makes it a login-shell as well ;)


Cheers,
Tink
 
Old 03-29-2004, 03:43 PM   #8
Shade
Senior Member
 
Registered: Mar 2003
Location: Burke, VA
Distribution: RHEL, Slackware, Ubuntu, Fedora
Posts: 1,418
Blog Entries: 1

Original Poster
Rep: Reputation: 46
I would have done that to begin with, but my instinct was to figure out the workings of it, and why it wasn't doing what I thought it should.

I learned a bit, and that was my goal. Plus it works how I like now. For some reason, I just didn't want login shells for every xterm I'd be opening

--Shade
 
  


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
Preferences Moose3565 Linux - Distributions 16 09-06-2005 02:35 PM
C++ preferences rahul_kulkarni Programming 7 05-10-2005 04:51 AM
Remove Preferences jpapa Linux - Software 0 10-22-2004 08:08 AM
Theme Preferences astroperico Linux - Newbie 2 12-25-2003 05:40 PM
xterm preferences marlaina1 Linux - Newbie 3 02-27-2002 12:37 AM


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