Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bash startup file updating #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions tidal-bootstrap.command
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ normal='\033[0m'
osName=$(uname -s)
myArch=$(uname -m) #intel: x86_64 silicon: arm64

_STARTUP_FILES=(
"${HOME}/.bashrc"
"${HOME}/.bash_profile"
"${HOME}/.bash_login"
"${HOME}/.profile"
"${HOME}/.zshrc"
)

## test for macOS - exit script if not Darwin
if test "${osName}" = "Darwin"; then
printf "Installing Tidalcycles stack for:\n os: ${osName}\n arch: ${myArch}\n\n"
Expand Down Expand Up @@ -83,11 +91,21 @@ else
curl https://get-ghcup.haskell.org -sSf | BOOTSTRAP_HASKELL_GHC_VERSION=latest BOOTSTRAP_HASKELL_CABAL_VERSION=latest BOOTSTRAP_HASKELL_NONINTERACTIVE=1 sh 2>&1 > /tmp/ghcup-install.log
## test to see if cabal exists - then add the env var to shell profiles
if [ -e "${HOME}/.ghcup/bin/cabal" ]; then
printf "${COLOR_PURPLE}[2.1]$normal Adding ghcup initialisation to ~/.bashrc and ~/.zshrc...\n"
echo 'source ${HOME}/.ghcup/env' >> "${HOME}/.bashrc"
echo 'source ${HOME}/.ghcup/env' >> "${HOME}/.zshrc"
_startupFileFound=false
for startupFile in "${_STARTUP_FILES[@]}"; do
if [ -f "$startupFile" ]; then
printf "${COLOR_PURPLE}[2.1]$normal Adding ghcup initialisation to ${startupFile}...\n"
if ! grep -q "source ${HOME}/.ghcup/env" "$startupFile"; then
echo 'source ${HOME}/.ghcup/env' >> "$startupFile"
fi
_startupFileFound=true
fi
done
if [ "$_startupFileFound" = false ]; then
printf "Error: $startup_file not found. Haskell may not be installed correctly.\n"
fi
else
printf "Error: Haskell pkg mgr cabal not found in ${HOME}/.ghcup/bin. "
printf "Error: Haskell pkg mgr cabal not found in ${HOME}/.ghcup/bin.\n"
fi
fi

Expand Down