You are not logged in.
For Example, I usually change environment settings in ~/.bashrc file for nnn file manager here and there. Then, do
$ source ~/.bash_profileIt effects if I run "nnn" in interactive shell. But if I run "nnn" via keybinding or script using
st -e nnnfor instance, it does not effect.
I googled and read a lot post online. As far as I understand, non-interactive shell does not source ~/.bashrc.
So, one solution I found is forcing it to source ~/.bashrc every time, like this, for instance,
st -e $SHELL -ic nnnBut what I am looking for is any way to update or source ~/.bashrc for non-interactive only one time without reboot the machine.
I found a post here, but I do
$ exec $SHELLand it does not work.
So, is there any way to do for non-interactive shell as doing
$ source ~/.bash_profilefor interactive shell.
Last edited by duyinthee (2020-10-04 05:56:54)
Offline
Set BASH_ENV to point to your .bashrc.
That’s it.
export BASH_ENV=“$HOME/.bashrc”Or any other that you want.
You can also export the environment variables for nnn that you change, but if you change them too frequently then use bashrc.
When you find something stable that you like then port the nnn environment variables to your .bash_profile
Edit: not efficient, see @seth suggestion and use env instead.
Last edited by GaKu999 (2020-10-04 07:31:27)
Offline
Set BASH_ENV to point to your .bashrc.
That’s it.export BASH_ENV=“$HOME/.bashrc”Or any other that you want.
You can also export the environment variables for nnn that you change, but if you change them too frequently then use bashrc.
When you find something stable that you like then port the nnn environment variables to your .bash_profile
I have tried,
export BASH_ENV="$HOME/.bashrc"does not work.
Porting my environment settings to ~/.bash_profile does not work too.
Offline
Have you logged in and out?
It must be set on login by .bash_profile, otherwise the subshells won’t inherit it...
I see a source of problems, because if you are using a DM, IIRC it skips that...
If that’s the case you might have to use .pam_environment, but beware, it haves a different syntax.
And of course, only logout and login is needed, idk who told you that you had to reboot to update environment variables...
Edit: not efficient for what you are doing, follow @seth suggestion and use env instead
Wiki page:
https://wiki.archlinux.org/index.php/En … _variables
Last edited by GaKu999 (2020-10-04 07:34:03)
Offline
Forget the entire approach and check "man env".
Offline
Forget the entire approach and check "man env".
That is indeed a lot more efficient for what OP needs.
Last edited by GaKu999 (2020-10-04 07:34:49)
Offline
Yeah, env is helpful.
I found the way to what I want, but it is not an answer to my question regarding with bash.
I create a script called .nnn-launcher lets say, as follow;
#!/usr/bin/env sh
env \
NNN_TRASH=1 \
NNN_BMS='d:~/Documents/mshDic;h:~;j:~/Downloads;u:~/Documents' \
NNN_PLUG='m:ow-mplayer;i:pv-sxiv;c:m-convert;a:mp3-edit' \
"$@"for instance.
then I open nnn in st from keybinding or script like this;
st -e ~/.nnn-launcher nnnActually that's exactly what I want. I can edit plugins and bookmarks in the ~/.nnn-launcher at any time without head ache to re-source bash and logout-login again.
But I still want to know
So, is there any way to do for non-interactive shell as doing
$ source ~/.bash_profile
for interactive shell.
Offline
For non interactive bash init load, use BASH_ENV as said.
Let’s test just in case...
In $HOME/foo
echo barThen run:
BASH_ENV=“$HOME/foo” bash -c “echo baz”It should have bar and baz as output.
Do note that when called as sh it will not load BASH_ENV, for sh IIRC you need to use ENV instead as for bash with —posix.
That includes any script with a sh shebang
By default sh is a symlink to bash, but bash behaves differently when called as sh.
Last edited by GaKu999 (2020-10-04 10:46:28)
Offline
You can also "/bin/bash -i" to explicitly run it as interactive shell and in general set a variable in your bashrc (or any include) that you can test to condition the source.
Offline