Skip to content

Commit

Permalink
Issue #131: Ensure local bindir is first in PATH
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Detwiler <mike@detwiler.io>
  • Loading branch information
detwiler committed Dec 14, 2022
1 parent a17912e commit 24e466b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
12 changes: 9 additions & 3 deletions data/bash/common/.bash_profile.in
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
# source the system wide bashrc if it exists
if [ -f /etc/bash.bashrc ] ; then
source /etc/bash.bashrc
source /etc/bash.bashrc
fi

# source the users bashrc if it exists
if [ -f "$HOME/.bashrc" ] ; then
source "$HOME/.bashrc"
source "$HOME/.bashrc"
fi

_toolbox_name=$(__toolbox_name)

# source customizations
if [ -f "@pkgconfdir@/$_toolbox_name/profile" ]; then
source "@pkgconfdir@/$_toolbox_name/profile"
source "@pkgconfdir@/$_toolbox_name/profile"
fi

# Set PATH so it includes user's private bin dirs if they exist
if type -t pathmung &>/dev/null; then
pathmung @bindir@
pathmung @sbindir@
fi

unset _toolbox_name
30 changes: 12 additions & 18 deletions data/bash/common/.bashrc.in
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Determin toolbox name
function __toolbox_name()
{
if [[ -f @TOOLBOX_ENV_FILE@ ]]; then
if [[ -f @CONTAINER_ENV_FILE@ ]]; then
toolbox_name=$(source @CONTAINER_ENV_FILE@ && printf $name)
if [[ -f @TOOLBOX_ENV_FILE@ ]]; then
if [[ -f @CONTAINER_ENV_FILE@ ]]; then
toolbox_name=$(source @CONTAINER_ENV_FILE@ && printf $name)
else
toolbox_name=$(hostname)
fi
else
toolbox_name=$(hostname)
toolbox_name=$(hostname)
fi
else
toolbox_name=$(hostname)
fi
printf "$toolbox_name"
} # toolbox_name()
export -f __toolbox_name
Expand All @@ -18,32 +18,26 @@ _toolbox_name=$(__toolbox_name)

# Source global definitions
if [ -f "@pkgconfdir@/$_toolbox_name/global-bash" ]; then
source "@pkgconfdir@/$_toolbox_name/global-bash"
source "@pkgconfdir@/$_toolbox_name/global-bash"
fi

# User specific aliases and functions
if [ -f "@pkgconfdir@/$_toolbox_name/functions" ]; then
source "@pkgconfdir@/$_toolbox_name/functions"
fi

# Set PATH so it includes user's private bin dirs if they exist
if type -t pathmung &>/dev/null; then
pathmung @bindir@
pathmung @sbindir@
source "@pkgconfdir@/$_toolbox_name/functions"
fi

# Add Homebrew directories to PATH
if [ -f "@pkgconfdir@/$_toolbox_name/homebrew-pathmung" ]; then
source "@pkgconfdir@/$_toolbox_name/homebrew-pathmung"
source "@pkgconfdir@/$_toolbox_name/homebrew-pathmung"
fi

# Add Windows Python 3 directories to PATH
if [ -f "@pkgconfdir@/$_toolbox_name/win-python-pathmung" ]; then
source "@pkgconfdir@/$_toolbox_name/win-python-pathmung"
source "@pkgconfdir@/$_toolbox_name/win-python-pathmung"
fi

if [ -f "@pkgconfdir@/$_toolbox_name/bashrc" ]; then
source "@pkgconfdir@/$_toolbox_name/bashrc"
source "@pkgconfdir@/$_toolbox_name/bashrc"
fi

unset _toolbox_name

0 comments on commit 24e466b

Please sign in to comment.