You are not logged in.

#1 2013-02-03 01:43:51

nwenclaff
Member
Registered: 2012-11-19
Posts: 5

Bashrc not being sourced.

I had to delete my account and recreate it - long story.

Anyway when I load up Konsole I get sh-4.2$ for a prompt I no longer get [name@compname ] - the only way I can is by source .bashrc

My .bash_profile is below :

#
# ~/.bash_profile
#

#[[ -f ~/.bashrc ]] && . ~/.bashrc
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

export PS1='\[\e[0;31m\]\u\[\e[0m\]\[\e[1;31m\]@\[\e[0m\]\[\e[0;31m\]\H\[\e[0m\] \w $ '
source ~/.bashrc

my .Bashrc

#
# ~/.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

alias ls='ls -1sh --color=auto'

PS1='[\u@\h \W]\$ '

/etc/profile

# /etc/profile

#Set our umask
umask 022

# Set our default path
PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"
export PATH

# Load profiles from /etc/profile.d
if test -d /etc/profile.d/; then
	for profile in /etc/profile.d/*.sh; do
		test -r "$profile" && . "$profile"
	done
	unset profile
fi

# Source global bash config
if test "$PS1" && test "$BASH" && test -r /etc/bash.bashrc; then
	. /etc/bash.bashrc
fi

# Termcap is outdated, old, and crusty, kill it.
unset TERMCAP

# Man is much better than us at figuring this out
unset MANPATH

Any help at all please I have searched over two hours on web forums and nothing has fixed the issue.

Last edited by jasonwryan (2013-02-03 01:53:48)

Offline

#2 2013-02-03 02:57:00

ConnorBehan
Trusted User (TU)
From: Long Island NY
Registered: 2007-07-05
Posts: 1,356
Website

Re: Bashrc not being sourced.

Do you have any strange environment variables? And does it suddenly get sourced if you run bash from within bash? Try "sudo bash", "sudo -u your_user bash" and "su -c bash" variants too.


6EA3 F3F3 B908 2632 A9CB E931 D53A 0445 B47A 0DAB
Great things come in tar.xz packages.

Offline

#3 2013-02-03 22:56:41

Antoine
Member
From: Picton Ontario
Registered: 2012-10-11
Posts: 90

Re: Bashrc not being sourced.

nwenclaff wrote:

I had to delete my account and recreate it - long story.

Anyway when I load up Konsole I get sh-4.2$ for a prompt I no longer get [name@compname ] - the only way I can is by source .bashrc

My .bash_profile is below :

#
# ~/.bash_profile
#

#[[ -f ~/.bashrc ]] && . ~/.bashrc
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

export PS1='\[\e[0;31m\]\u\[\e[0m\]\[\e[1;31m\]@\[\e[0m\]\[\e[0;31m\]\H\[\e[0m\] \w $ '
source ~/.bashrc

Any help at all please I have searched over two hours on web forums and nothing has fixed the issue.

I set my prompt in ~/.bashrc. ~/bash.profile modifies my  PATH, and then sources .bashrc in the way you do.

Offline

#4 2013-02-04 02:44:53

vv
Member
Registered: 2013-02-03
Posts: 12

Re: Bashrc not being sourced.

nwenclaff, it could be that Konsole is invoking bash via /bin/sh symlink. When invoked as 'sh', bash will not read ~/.bash* files, because it's emulating the POSIX shell. Try configuring Konsole so that it invokes 'bash' instead of 'sh' and I hope that should fix your issue.

Offline

#5 2013-02-04 04:32:25

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,058

Re: Bashrc not being sourced.

.bash_profile is only sourced once so I would try putting your PS1 in .bashrc instead.

Offline

#6 2013-03-20 22:31:36

woah
Member
Registered: 2008-09-16
Posts: 10

Re: Bashrc not being sourced.

I recently had this same issue and based off of vv's advice, this is what fixed it for me:

As root

usermod --shell /bin/bash "${your_user_name}"

The shell was previously /bin/sh

Offline

#7 2013-03-20 23:13:44

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,412

Re: Bashrc not being sourced.

As stated above you can change your default shell.  It does indeed sound as though your default shell is set to /bin/sh.  Check out the file /etc/passwd and see what the shell is on the line with your name.  If it says /bin/sh that explains it, and you need to do what is offered in the post above (#6).

Offline

Board footer

Powered by FluxBB