xterm not getting PS1 from .bash_profile - Help

This is a discussion on xterm not getting PS1 from .bash_profile - Help ; Running Fedora Core 1, my .bash_profile consists solely of the following
line:
PS1='\u@\h:\w$ '
When I log into the console it's fine, and I get
jzilla@localhost:~$
but when I start an xterm, it's a default
bash-2.05b$
Why the disparity? I've ...

Re: xterm not getting PS1 from .bash_profile

On 22:57 31 Jan 2004, jzilla wrote:
| Running Fedora Core 1, my .bash_profile consists solely of the following
| line:
|
| PS1='\u@\h:\w$ '
|
| When I log into the console it's fine, and I get
|
| jzilla@localhost:~$
|
| but when I start an xterm, it's a default
|
| bash-2.05b$
|
| Why the disparity? I've had the problem due to permissioning in the past
| (/home is mounted via NFS), so I recreated .bash_profile, but that
| didn't help.

New terminals aren't login shells. You want your .bashrc instead.
However, presuming this is under a GUI login, if you just source your
..bash_profile during the X11 startup and make sure you export $PS1 it
_ought_ to work as on the console, avoiding the need to have a .bashrc
(for this purpose, anyway).

Ah, that makes sense.
> You want your .bashrc instead.
> However, presuming this is under a GUI login, if you just source your
> .bash_profile during the X11 startup and make sure you export $PS1 it
> _ought_ to work as on the console, avoiding the need to have a .bashrc
> (for this purpose, anyway).

Putting PS1 in .bashrc sorted out xterm, thanks. Could you expand on
'source your .bash_profile'?
On the off chance, I added '~/.bash_profile' to .xinitrc, but it says
'/home/jzilla/.xinitrc: line 2: /home/jzilla/.bash_profile: Permission
denied'. It's permission 644 and I'm the owner.

Re: xterm not getting PS1 from .bash_profile

On 15:47 01 Feb 2004, jzilla wrote:
| >New terminals aren't login shells.
| Ah, that makes sense.
|
| >You want your .bashrc instead.
| >However, presuming this is under a GUI login, if you just source your
| >.bash_profile during the X11 startup and make sure you export $PS1 it
| >_ought_ to work as on the console, avoiding the need to have a .bashrc
| >(for this purpose, anyway).
|
| Putting PS1 in .bashrc sorted out xterm, thanks. Could you expand on
| 'source your .bash_profile'?

Exactly what you then tried ...

| On the off chance, I added '~/.bash_profile' to .xinitrc, but it says
| '/home/jzilla/.xinitrc: line 2: /home/jzilla/.bash_profile: Permission
| denied'. It's permission 644 and I'm the owner.

Two things:

- you need to _source_ it, not invoke it like a program i.e.

. $HOME/.bash_profile

which runs it in the current shell, instead of

$HOME/.bash_profile

which runs it as a separate command.

The latter will set up all the env vars in the subprocess, and
then neatly discards them when the process finishes. The former
does the setup for the current shell, thus leaving them around
for inheritance by all the programs your X session spawns.

- you may need execute permission:

chmod 755 ~/.bash_profile

The source command (".") might not need execute.

And be sure your .bash_profile doesn't do interactive stuff.
Needless to say, that won't work well during the GUI login:-)

You get Permission denied because you're attempting to execute a program
that doesn't have the executable bit(s) set.

BTW, if you're logging in via a GUI login manager, you should use
~/.xsession, and that must be executable. .xinitrc if for startx. I
source .xsession from .xinitrc, that way I can start ssh-agent in
..xinitrc (Debian starts it for me in GUI logins).
> Two things:
>
> - you need to _source_ it, not invoke it like a program i.e.
>
> . $HOME/.bash_profile
>
> which runs it in the current shell, instead of
>
> $HOME/.bash_profile

The "." command (which is exactly the same as the "source" command) is
exactly like an #include directive you would use in other programming
languages.
> - you may need execute permission:
>
> chmod 755 ~/.bash_profile
>
> The source command (".") might not need execute.

Re: xterm not getting PS1 from .bash_profile

Cameron Kerr wrote:
>
> Cameron Simpson wrote:
>
>>On 15:47 01 Feb 2004, jzilla wrote:
>
>>| On the off chance, I added '~/.bash_profile' to .xinitrc, but it says
>>| '/home/jzilla/.xinitrc: line 2: /home/jzilla/.bash_profile: Permission
>>| denied'. It's permission 644 and I'm the owner.
>
> You get Permission denied because you're attempting to execute a program
> that doesn't have the executable bit(s) set.
>
> BTW, if you're logging in via a GUI login manager, you should use
> ~/.xsession, and that must be executable. .xinitrc if for startx. I
> source .xsession from .xinitrc, that way I can start ssh-agent in
> .xinitrc (Debian starts it for me in GUI logins).

What login manager do you use?

I'd probably use a login manager like gdm or xdm if I knew a simple way
to have them run my window manager (sawfish). I looked into it a while
back, but they both looked pretty hairy and typing 'xinit' isn't so hard.
>>Two things:
>>
>> - you need to _source_ it, not invoke it like a program i.e.
>>
>> . $HOME/.bash_profile
>>
>> which runs it in the current shell, instead of
>>
>> $HOME/.bash_profile
>
>
> The "." command (which is exactly the same as the "source" command) is
> exactly like an #include directive you would use in other programming
> languages.

That's a really cool feature! Thanks for pointing it out, guys.

Re: xterm not getting PS1 from .bash_profile

jzilla wrote:
> What login manager do you use?

Personally, I use wdm (Wings Display Manager), which is more featureful
than xdm, but doesn't have anything to do with KDE or GNOME.
> I'd probably use a login manager like gdm or xdm if I knew a simple way
> to have them run my window manager (sawfish). I looked into it a while
> back, but they both looked pretty hairy and typing 'xinit' isn't so hard.

That should be fairly automatic. Most distros should have an entry for
each session type on their login widget.