From bb11db42a536ca3e857a71b86e76f55cfc1b8958 Mon Sep 17 00:00:00 2001 From: "Andrew R. M" Date: Thu, 4 Jan 2018 18:35:09 -0500 Subject: [PATCH] Ensure .profile is loaded by shells. Took this code out of /etc/profile and /etc/bashrc from NixOS --- bash/.bashrc | 15 +++++++++++---- sh/.profile | 4 ++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/bash/.bashrc b/bash/.bashrc index c040d48..3ab5658 100644 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -29,22 +29,29 @@ export PROMPT_COMMAND="history -n; history -w; history -c; history -r; $PROMPT_C #{- SOURCING -}# -# Source aliases + +# Source profile, if it hasn't already been loaded +if [ -z "$__PROFILE_DONE" ]; then + . $HOME/.profile +fi + + +# Source aliases, if they exist if [ -f "$HOME/.aliases" ] && [ -r "$HOME/.aliases" ]; then . "$HOME/.aliases" fi -# Source private aliases +# Source private aliases, if they exist if [ -f "$HOME/.private_aliases" ] && [ -r "$HOME/.private_aliases" ]; then . "$HOME/.private_aliases" fi -# Source functions +# Source functions, if they exist if [ -f "$HOME/.functions" ] && [ -r "$HOME/.functions" ]; then . "$HOME/.functions" fi -# Source private functions +# Source private functions, if they exist if [ -f "$HOME/.private_functions" ] && [ -r "$HOME/.private_functions" ]; then . "$HOME/.private_functions" fi diff --git a/sh/.profile b/sh/.profile index 4b6e01f..b34f2be 100644 --- a/sh/.profile +++ b/sh/.profile @@ -1,5 +1,9 @@ #{- ~/.profile -}# +# Only execute this file once per shell +if [ -n "$__PROFILE_SOURCED" ]; then return; fi +export __PROFILE_SOURCED=1 + #{- PATH -}# # Prepend ~/.local/bin to the path and append the current directory to the path