refactor: Improve .profile for shell compatibility and PATH management

This commit is contained in:
Peter Wood
2025-05-30 17:17:27 -04:00
parent d6c76ac146
commit bdda278408

View File

@@ -9,10 +9,18 @@
#umask 022 #umask 022
# if running bash # if running bash
if [ -n "$BASH_VERSION" ]; then if [ "$SHELL" = "/bin/bash" ]; then
# include .bashrc if it exists # include .bashrc if it exists and we are not in a subshell
# Check if .bashrc exists
if [ -f "$HOME/.bashrc" ]; then if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc" # Check if we are in a login shell (indicated by -l in the shell options)
if ! shopt -oq posix; then # Check if not running in POSIX mode (usually implies a login shell)
. "$HOME/.bashrc"
fi
fi
elif [ "$SHELL" = "/bin/zsh" ]; then
if [ -f "$HOME/.zshrc" ]; then
. "$HOME/.zshrc"
fi fi
fi fi
@@ -26,4 +34,23 @@ if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH" PATH="$HOME/.local/bin:$PATH"
fi fi
nvm use stable # Use stable nvm version if available
if command -v nvm &> /dev/null; then
nvm use stable
fi
# Add Go directories to PATH
if [ -d "/usr/local/go/bin" ] ; then
PATH="/usr/local/go/bin:$PATH"
fi
if [ -d "$HOME/go/bin" ] ; then
PATH="$HOME/go/bin:$PATH"
fi
# Add Go version-specific paths if they exist
for go_path in /usr/lib/go-*/bin /usr/lib/go/bin; do
if [ -d "$go_path" ] ; then
PATH="$go_path:$PATH"
fi
done