From 3bb8ad24eeec00713151854d242092d5b53bbf69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gregor=20B=C3=BCckendorf?= Date: Thu, 6 Dec 2018 20:58:50 +0100 Subject: [PATCH] bash_profile: Restructured the file to load the bashrc only when required and after the environment is sourced --- .bash_profile | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.bash_profile b/.bash_profile index 68026e2..8a8cf4b 100644 --- a/.bash_profile +++ b/.bash_profile @@ -1,10 +1,5 @@ # .bash_profile -# Get the aliases and functions -if [ -f ~/.bashrc ]; then - . ~/.bashrc -fi - # User specific environment and startup programs PATH=$PATH:$HOME/.local/bin:$HOME/bin export PATH @@ -15,6 +10,15 @@ export PATH # security or privacy reasons. set -a for file in ~/.environment.d/*.env; do - . "$FILE" + . "$file" done set +a + +# Source the .bashrc if the Filedescriptor for stdin is opened. This is a very +# simple test to determine if the .bash_profile was sourced from VT or SSH-login +# where the .bashrc has to be sourced to provide a similar environment to a +# terminal emulator. Found here: +# https://eklitzke.org/effectively-using-bash-profile +if [[ -t 0 && -f ~/.bashrc ]]; then + . ~/.bashrc +fi