From bdda278408a81d00b111e4bbfdc772fe65e555cf Mon Sep 17 00:00:00 2001 From: Peter Wood Date: Fri, 30 May 2025 17:17:27 -0400 Subject: [PATCH] refactor: Improve .profile for shell compatibility and PATH management --- dotfiles/.profile | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/dotfiles/.profile b/dotfiles/.profile index 51df3d7..b71bf4d 100644 --- a/dotfiles/.profile +++ b/dotfiles/.profile @@ -9,10 +9,18 @@ #umask 022 # if running bash -if [ -n "$BASH_VERSION" ]; then - # include .bashrc if it exists +if [ "$SHELL" = "/bin/bash" ]; then + # include .bashrc if it exists and we are not in a subshell + # Check if .bashrc exists 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 @@ -26,4 +34,23 @@ if [ -d "$HOME/.local/bin" ] ; then PATH="$HOME/.local/bin:$PATH" 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