I have noticed that the paths I add to $PATH
in my .bashrc
appear duplicates when I open session in tmux
(terminal multiplexer):
export PATH=$HOME/miniconda3/bin:$PATH
export PATH=$PATH:$HOME/Devel/bin
If I print $PATH
in a session of tmux
it appears as follows:
/home/alejandro/miniconda3/bin:/home/alejandro/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/alejandro/Devel/bin:/home/alejandro/Devel/bin
Out of tmux
it appears normal:
/home/alejandro/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/alejandro/Devel/bin
I suspect it has to do with the first line of my .bash_profile
:
if [[ -f ~/.bashrc ]]; then . ~/.bashrc; fi
If I comment on this line (which I do not quite understand what its function is), $PATH
appears correct inside and outside the tmux
session, except that I lose script% custom bash-git-prompt
inside of the tmux
session. Apparently tmux
accesses the bash-git-prompt
script by .bash_profile
.
So far the solution I found was:
- comment the first line of
bash_profile
; - Copy the lines from
.bashrc
tobash-git-prompt
script within.bash_profile
(now those lines are in both files).
As a result, $PATH
appears correctly inside and outside the session of tmux
and the same thing with the prompt.
My question is whether it's right or is there a better way to do it.
Edited: