When I start XTerm, my .bashrc doesn't get sourced
up vote
1
down vote
favorite
My ~/.bashrc
: https://pastebin.com/VA7RLA2E
My ~/.Xresources
: https://pastebin.com/qSF1z0w4
How do I make XTerm automatically source .bashrc
when it starts?
Currently, whenever I open a new XTerm window, it doesn't source ~/.bashrc
.
My OS is Ubuntu 18.04.
bash xterm
New contributor
add a comment |
up vote
1
down vote
favorite
My ~/.bashrc
: https://pastebin.com/VA7RLA2E
My ~/.Xresources
: https://pastebin.com/qSF1z0w4
How do I make XTerm automatically source .bashrc
when it starts?
Currently, whenever I open a new XTerm window, it doesn't source ~/.bashrc
.
My OS is Ubuntu 18.04.
bash xterm
New contributor
1
a quick google search found this ..... i do not know if it applies to your system .... stackoverflow.com/questions/35931378/…
– jsotola
Nov 24 at 6:37
Is bash your default shell ? bash source .bashrc not Xterm.
– ctac_
2 days ago
@ctac_ Yes. I also checked it withecho $SHELL
and it says/bin/bash
.
– 盧芹達
2 days ago
@jsotola Oh, that worked. I've put the code in my.bash_profile
and it worked.
– 盧芹達
2 days ago
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
My ~/.bashrc
: https://pastebin.com/VA7RLA2E
My ~/.Xresources
: https://pastebin.com/qSF1z0w4
How do I make XTerm automatically source .bashrc
when it starts?
Currently, whenever I open a new XTerm window, it doesn't source ~/.bashrc
.
My OS is Ubuntu 18.04.
bash xterm
New contributor
My ~/.bashrc
: https://pastebin.com/VA7RLA2E
My ~/.Xresources
: https://pastebin.com/qSF1z0w4
How do I make XTerm automatically source .bashrc
when it starts?
Currently, whenever I open a new XTerm window, it doesn't source ~/.bashrc
.
My OS is Ubuntu 18.04.
bash xterm
bash xterm
New contributor
New contributor
edited 2 days ago
Kusalananda
117k16220358
117k16220358
New contributor
asked Nov 24 at 6:10
盧芹達
105
105
New contributor
New contributor
1
a quick google search found this ..... i do not know if it applies to your system .... stackoverflow.com/questions/35931378/…
– jsotola
Nov 24 at 6:37
Is bash your default shell ? bash source .bashrc not Xterm.
– ctac_
2 days ago
@ctac_ Yes. I also checked it withecho $SHELL
and it says/bin/bash
.
– 盧芹達
2 days ago
@jsotola Oh, that worked. I've put the code in my.bash_profile
and it worked.
– 盧芹達
2 days ago
add a comment |
1
a quick google search found this ..... i do not know if it applies to your system .... stackoverflow.com/questions/35931378/…
– jsotola
Nov 24 at 6:37
Is bash your default shell ? bash source .bashrc not Xterm.
– ctac_
2 days ago
@ctac_ Yes. I also checked it withecho $SHELL
and it says/bin/bash
.
– 盧芹達
2 days ago
@jsotola Oh, that worked. I've put the code in my.bash_profile
and it worked.
– 盧芹達
2 days ago
1
1
a quick google search found this ..... i do not know if it applies to your system .... stackoverflow.com/questions/35931378/…
– jsotola
Nov 24 at 6:37
a quick google search found this ..... i do not know if it applies to your system .... stackoverflow.com/questions/35931378/…
– jsotola
Nov 24 at 6:37
Is bash your default shell ? bash source .bashrc not Xterm.
– ctac_
2 days ago
Is bash your default shell ? bash source .bashrc not Xterm.
– ctac_
2 days ago
@ctac_ Yes. I also checked it with
echo $SHELL
and it says /bin/bash
.– 盧芹達
2 days ago
@ctac_ Yes. I also checked it with
echo $SHELL
and it says /bin/bash
.– 盧芹達
2 days ago
@jsotola Oh, that worked. I've put the code in my
.bash_profile
and it worked.– 盧芹達
2 days ago
@jsotola Oh, that worked. I've put the code in my
.bash_profile
and it worked.– 盧芹達
2 days ago
add a comment |
2 Answers
2
active
oldest
votes
up vote
4
down vote
accepted
In your ~/.Xresources
file, you have the line
xterm*loginShell: true
This would make XTerm start the shell session as a login shell. When bash
runs as a login shell, it reads your ~/.bash_profile
file, but it does not read ~/.bashrc
(this file is read by non-login interactive sessions) unless ~/.bash_profile
reads it with source
explicitly.
You have two options:
- Remove the line from
~/.Xresources
that specifies that the shell should be a login shell. You will likely have to exit your graphical login session for this file to be re-read and for the changes to take effect.
Make your
~/.bash_profile
filesource
your~/.bashrc
file, while making sure that your~/.bashrc
file is not sourcing the~/.bash_profile
file at the same time (which would create an infinite loop).
An example of how you may do this (this would be added to the
~/.bash_profile
file):
if [ -o interactive ] && [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
You may need to do something similar for
/etc/profile
vs/etc/bash.bashrc
, or wherever the system'sbashrc
is on your system if not already done by your system. However, as/etc/profile
is read by all Bourne-like shells, not justbash
, it needs to be adapted a little:
if [ -n "$BASH" ] &&
[ "$BASH" != /bin/sh ] &&
[ -o interactive ] &&
[ ! -o posix ] &&
[ -f /etc/bash.bashrc ]
then
source /etc/bash.bashrc
fi
Ok, I did that. I used the second solution. It worked. About the first one, I don't know which line specifies that the shell should be a login shell, so I didn't do that.
– 盧芹達
2 days ago
@盧芹達 I mentioned the line at the start of the answer. It saysxterm*loginShell: true
. For the record, I would probably solve it by the second alternative too, if it was my issue.
– Kusalananda
2 days ago
@Kusalanada So, I tried doing that. I removed the things from my ~/.bash_profile that I just added and tried removing the linexterm*loginShell: true
, but it didn't work. So I ended up still using the second solution.
– 盧芹達
2 days ago
1
@盧芹達,~/.Xresources
is typically a file that you load at X11 login time into your X server withxrdb
, that's not a file read by xterm, xterm retrieves those resources from the X server. That's a way to configure xterm on your display regardless of where the xterm connects from. You'd need to restart your X session for those settings to take effect or runxrdb
again. For a file that xterm reads upon startup, look at~/.Xdefaults
– Stéphane Chazelas
2 days ago
1
@盧芹達 Runxrdb -query
to see the list of resources currently loaded into your X server, andappres xterm
andappres XTerm
for the resources for xterm instances or the XTerm class.
– Stéphane Chazelas
2 days ago
|
show 10 more comments
up vote
0
down vote
I would do the following:
- Make sure .bashrc is in your home folder
Make sure that it is owned by you
xterm -e bash --rcfile /home/someuser/.bashrc
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
In your ~/.Xresources
file, you have the line
xterm*loginShell: true
This would make XTerm start the shell session as a login shell. When bash
runs as a login shell, it reads your ~/.bash_profile
file, but it does not read ~/.bashrc
(this file is read by non-login interactive sessions) unless ~/.bash_profile
reads it with source
explicitly.
You have two options:
- Remove the line from
~/.Xresources
that specifies that the shell should be a login shell. You will likely have to exit your graphical login session for this file to be re-read and for the changes to take effect.
Make your
~/.bash_profile
filesource
your~/.bashrc
file, while making sure that your~/.bashrc
file is not sourcing the~/.bash_profile
file at the same time (which would create an infinite loop).
An example of how you may do this (this would be added to the
~/.bash_profile
file):
if [ -o interactive ] && [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
You may need to do something similar for
/etc/profile
vs/etc/bash.bashrc
, or wherever the system'sbashrc
is on your system if not already done by your system. However, as/etc/profile
is read by all Bourne-like shells, not justbash
, it needs to be adapted a little:
if [ -n "$BASH" ] &&
[ "$BASH" != /bin/sh ] &&
[ -o interactive ] &&
[ ! -o posix ] &&
[ -f /etc/bash.bashrc ]
then
source /etc/bash.bashrc
fi
Ok, I did that. I used the second solution. It worked. About the first one, I don't know which line specifies that the shell should be a login shell, so I didn't do that.
– 盧芹達
2 days ago
@盧芹達 I mentioned the line at the start of the answer. It saysxterm*loginShell: true
. For the record, I would probably solve it by the second alternative too, if it was my issue.
– Kusalananda
2 days ago
@Kusalanada So, I tried doing that. I removed the things from my ~/.bash_profile that I just added and tried removing the linexterm*loginShell: true
, but it didn't work. So I ended up still using the second solution.
– 盧芹達
2 days ago
1
@盧芹達,~/.Xresources
is typically a file that you load at X11 login time into your X server withxrdb
, that's not a file read by xterm, xterm retrieves those resources from the X server. That's a way to configure xterm on your display regardless of where the xterm connects from. You'd need to restart your X session for those settings to take effect or runxrdb
again. For a file that xterm reads upon startup, look at~/.Xdefaults
– Stéphane Chazelas
2 days ago
1
@盧芹達 Runxrdb -query
to see the list of resources currently loaded into your X server, andappres xterm
andappres XTerm
for the resources for xterm instances or the XTerm class.
– Stéphane Chazelas
2 days ago
|
show 10 more comments
up vote
4
down vote
accepted
In your ~/.Xresources
file, you have the line
xterm*loginShell: true
This would make XTerm start the shell session as a login shell. When bash
runs as a login shell, it reads your ~/.bash_profile
file, but it does not read ~/.bashrc
(this file is read by non-login interactive sessions) unless ~/.bash_profile
reads it with source
explicitly.
You have two options:
- Remove the line from
~/.Xresources
that specifies that the shell should be a login shell. You will likely have to exit your graphical login session for this file to be re-read and for the changes to take effect.
Make your
~/.bash_profile
filesource
your~/.bashrc
file, while making sure that your~/.bashrc
file is not sourcing the~/.bash_profile
file at the same time (which would create an infinite loop).
An example of how you may do this (this would be added to the
~/.bash_profile
file):
if [ -o interactive ] && [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
You may need to do something similar for
/etc/profile
vs/etc/bash.bashrc
, or wherever the system'sbashrc
is on your system if not already done by your system. However, as/etc/profile
is read by all Bourne-like shells, not justbash
, it needs to be adapted a little:
if [ -n "$BASH" ] &&
[ "$BASH" != /bin/sh ] &&
[ -o interactive ] &&
[ ! -o posix ] &&
[ -f /etc/bash.bashrc ]
then
source /etc/bash.bashrc
fi
Ok, I did that. I used the second solution. It worked. About the first one, I don't know which line specifies that the shell should be a login shell, so I didn't do that.
– 盧芹達
2 days ago
@盧芹達 I mentioned the line at the start of the answer. It saysxterm*loginShell: true
. For the record, I would probably solve it by the second alternative too, if it was my issue.
– Kusalananda
2 days ago
@Kusalanada So, I tried doing that. I removed the things from my ~/.bash_profile that I just added and tried removing the linexterm*loginShell: true
, but it didn't work. So I ended up still using the second solution.
– 盧芹達
2 days ago
1
@盧芹達,~/.Xresources
is typically a file that you load at X11 login time into your X server withxrdb
, that's not a file read by xterm, xterm retrieves those resources from the X server. That's a way to configure xterm on your display regardless of where the xterm connects from. You'd need to restart your X session for those settings to take effect or runxrdb
again. For a file that xterm reads upon startup, look at~/.Xdefaults
– Stéphane Chazelas
2 days ago
1
@盧芹達 Runxrdb -query
to see the list of resources currently loaded into your X server, andappres xterm
andappres XTerm
for the resources for xterm instances or the XTerm class.
– Stéphane Chazelas
2 days ago
|
show 10 more comments
up vote
4
down vote
accepted
up vote
4
down vote
accepted
In your ~/.Xresources
file, you have the line
xterm*loginShell: true
This would make XTerm start the shell session as a login shell. When bash
runs as a login shell, it reads your ~/.bash_profile
file, but it does not read ~/.bashrc
(this file is read by non-login interactive sessions) unless ~/.bash_profile
reads it with source
explicitly.
You have two options:
- Remove the line from
~/.Xresources
that specifies that the shell should be a login shell. You will likely have to exit your graphical login session for this file to be re-read and for the changes to take effect.
Make your
~/.bash_profile
filesource
your~/.bashrc
file, while making sure that your~/.bashrc
file is not sourcing the~/.bash_profile
file at the same time (which would create an infinite loop).
An example of how you may do this (this would be added to the
~/.bash_profile
file):
if [ -o interactive ] && [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
You may need to do something similar for
/etc/profile
vs/etc/bash.bashrc
, or wherever the system'sbashrc
is on your system if not already done by your system. However, as/etc/profile
is read by all Bourne-like shells, not justbash
, it needs to be adapted a little:
if [ -n "$BASH" ] &&
[ "$BASH" != /bin/sh ] &&
[ -o interactive ] &&
[ ! -o posix ] &&
[ -f /etc/bash.bashrc ]
then
source /etc/bash.bashrc
fi
In your ~/.Xresources
file, you have the line
xterm*loginShell: true
This would make XTerm start the shell session as a login shell. When bash
runs as a login shell, it reads your ~/.bash_profile
file, but it does not read ~/.bashrc
(this file is read by non-login interactive sessions) unless ~/.bash_profile
reads it with source
explicitly.
You have two options:
- Remove the line from
~/.Xresources
that specifies that the shell should be a login shell. You will likely have to exit your graphical login session for this file to be re-read and for the changes to take effect.
Make your
~/.bash_profile
filesource
your~/.bashrc
file, while making sure that your~/.bashrc
file is not sourcing the~/.bash_profile
file at the same time (which would create an infinite loop).
An example of how you may do this (this would be added to the
~/.bash_profile
file):
if [ -o interactive ] && [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
You may need to do something similar for
/etc/profile
vs/etc/bash.bashrc
, or wherever the system'sbashrc
is on your system if not already done by your system. However, as/etc/profile
is read by all Bourne-like shells, not justbash
, it needs to be adapted a little:
if [ -n "$BASH" ] &&
[ "$BASH" != /bin/sh ] &&
[ -o interactive ] &&
[ ! -o posix ] &&
[ -f /etc/bash.bashrc ]
then
source /etc/bash.bashrc
fi
edited 2 days ago
answered 2 days ago
Kusalananda
117k16220358
117k16220358
Ok, I did that. I used the second solution. It worked. About the first one, I don't know which line specifies that the shell should be a login shell, so I didn't do that.
– 盧芹達
2 days ago
@盧芹達 I mentioned the line at the start of the answer. It saysxterm*loginShell: true
. For the record, I would probably solve it by the second alternative too, if it was my issue.
– Kusalananda
2 days ago
@Kusalanada So, I tried doing that. I removed the things from my ~/.bash_profile that I just added and tried removing the linexterm*loginShell: true
, but it didn't work. So I ended up still using the second solution.
– 盧芹達
2 days ago
1
@盧芹達,~/.Xresources
is typically a file that you load at X11 login time into your X server withxrdb
, that's not a file read by xterm, xterm retrieves those resources from the X server. That's a way to configure xterm on your display regardless of where the xterm connects from. You'd need to restart your X session for those settings to take effect or runxrdb
again. For a file that xterm reads upon startup, look at~/.Xdefaults
– Stéphane Chazelas
2 days ago
1
@盧芹達 Runxrdb -query
to see the list of resources currently loaded into your X server, andappres xterm
andappres XTerm
for the resources for xterm instances or the XTerm class.
– Stéphane Chazelas
2 days ago
|
show 10 more comments
Ok, I did that. I used the second solution. It worked. About the first one, I don't know which line specifies that the shell should be a login shell, so I didn't do that.
– 盧芹達
2 days ago
@盧芹達 I mentioned the line at the start of the answer. It saysxterm*loginShell: true
. For the record, I would probably solve it by the second alternative too, if it was my issue.
– Kusalananda
2 days ago
@Kusalanada So, I tried doing that. I removed the things from my ~/.bash_profile that I just added and tried removing the linexterm*loginShell: true
, but it didn't work. So I ended up still using the second solution.
– 盧芹達
2 days ago
1
@盧芹達,~/.Xresources
is typically a file that you load at X11 login time into your X server withxrdb
, that's not a file read by xterm, xterm retrieves those resources from the X server. That's a way to configure xterm on your display regardless of where the xterm connects from. You'd need to restart your X session for those settings to take effect or runxrdb
again. For a file that xterm reads upon startup, look at~/.Xdefaults
– Stéphane Chazelas
2 days ago
1
@盧芹達 Runxrdb -query
to see the list of resources currently loaded into your X server, andappres xterm
andappres XTerm
for the resources for xterm instances or the XTerm class.
– Stéphane Chazelas
2 days ago
Ok, I did that. I used the second solution. It worked. About the first one, I don't know which line specifies that the shell should be a login shell, so I didn't do that.
– 盧芹達
2 days ago
Ok, I did that. I used the second solution. It worked. About the first one, I don't know which line specifies that the shell should be a login shell, so I didn't do that.
– 盧芹達
2 days ago
@盧芹達 I mentioned the line at the start of the answer. It says
xterm*loginShell: true
. For the record, I would probably solve it by the second alternative too, if it was my issue.– Kusalananda
2 days ago
@盧芹達 I mentioned the line at the start of the answer. It says
xterm*loginShell: true
. For the record, I would probably solve it by the second alternative too, if it was my issue.– Kusalananda
2 days ago
@Kusalanada So, I tried doing that. I removed the things from my ~/.bash_profile that I just added and tried removing the line
xterm*loginShell: true
, but it didn't work. So I ended up still using the second solution.– 盧芹達
2 days ago
@Kusalanada So, I tried doing that. I removed the things from my ~/.bash_profile that I just added and tried removing the line
xterm*loginShell: true
, but it didn't work. So I ended up still using the second solution.– 盧芹達
2 days ago
1
1
@盧芹達,
~/.Xresources
is typically a file that you load at X11 login time into your X server with xrdb
, that's not a file read by xterm, xterm retrieves those resources from the X server. That's a way to configure xterm on your display regardless of where the xterm connects from. You'd need to restart your X session for those settings to take effect or run xrdb
again. For a file that xterm reads upon startup, look at ~/.Xdefaults
– Stéphane Chazelas
2 days ago
@盧芹達,
~/.Xresources
is typically a file that you load at X11 login time into your X server with xrdb
, that's not a file read by xterm, xterm retrieves those resources from the X server. That's a way to configure xterm on your display regardless of where the xterm connects from. You'd need to restart your X session for those settings to take effect or run xrdb
again. For a file that xterm reads upon startup, look at ~/.Xdefaults
– Stéphane Chazelas
2 days ago
1
1
@盧芹達 Run
xrdb -query
to see the list of resources currently loaded into your X server, and appres xterm
and appres XTerm
for the resources for xterm instances or the XTerm class.– Stéphane Chazelas
2 days ago
@盧芹達 Run
xrdb -query
to see the list of resources currently loaded into your X server, and appres xterm
and appres XTerm
for the resources for xterm instances or the XTerm class.– Stéphane Chazelas
2 days ago
|
show 10 more comments
up vote
0
down vote
I would do the following:
- Make sure .bashrc is in your home folder
Make sure that it is owned by you
xterm -e bash --rcfile /home/someuser/.bashrc
add a comment |
up vote
0
down vote
I would do the following:
- Make sure .bashrc is in your home folder
Make sure that it is owned by you
xterm -e bash --rcfile /home/someuser/.bashrc
add a comment |
up vote
0
down vote
up vote
0
down vote
I would do the following:
- Make sure .bashrc is in your home folder
Make sure that it is owned by you
xterm -e bash --rcfile /home/someuser/.bashrc
I would do the following:
- Make sure .bashrc is in your home folder
Make sure that it is owned by you
xterm -e bash --rcfile /home/someuser/.bashrc
answered 2 days ago
Michael Prokopec
52415
52415
add a comment |
add a comment |
盧芹達 is a new contributor. Be nice, and check out our Code of Conduct.
盧芹達 is a new contributor. Be nice, and check out our Code of Conduct.
盧芹達 is a new contributor. Be nice, and check out our Code of Conduct.
盧芹達 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f483826%2fwhen-i-start-xterm-my-bashrc-doesnt-get-sourced%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
a quick google search found this ..... i do not know if it applies to your system .... stackoverflow.com/questions/35931378/…
– jsotola
Nov 24 at 6:37
Is bash your default shell ? bash source .bashrc not Xterm.
– ctac_
2 days ago
@ctac_ Yes. I also checked it with
echo $SHELL
and it says/bin/bash
.– 盧芹達
2 days ago
@jsotola Oh, that worked. I've put the code in my
.bash_profile
and it worked.– 盧芹達
2 days ago