Skip to content

Instantly share code, notes, and snippets.

@kienstra
Last active June 28, 2022 21:16
Show Gist options
  • Save kienstra/af4f8ad4c0606343eeb09e7de117ed93 to your computer and use it in GitHub Desktop.
Save kienstra/af4f8ad4c0606343eeb09e7de117ed93 to your computer and use it in GitHub Desktop.
Installs CLI packages, like Node and Composer
#!/bin/bash
# Usage:
# curl -o- https://gist.githubusercontent.com/kienstra/af4f8ad4c0606343eeb09e7de117ed93/raw/84d11672958d6d5802fd2cd5cd0c35083dbb7cfc/CLI%2520Setup | bash
echo "Checking that git is installed…"
if [ "$(git --version)" ]
then
echo "git is installed, as expected"
else
echo "Please install git"
fi
if [ ! -f ~/.zshrc ]
then
echo "source ~/.nvm/nvm.sh" > ~/.zshrc
fi
echo "Installing homebrew. You might be asked for your password for sudo access."
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install)"
echo "Installing composer and coreutils via homebrew…"
brew install composer
brew install coreutils
echo "Installing nvm…"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
# Ensure this can run nvm without opening a new Terminal tab.
source ~/.zshrc
nvm install node
nvm install 14
nvm use 14
echo "Success! You now have node and composer installed."
@mike-day
Copy link

They actually seemed to fail silently, or I might have just missed the error!

For the sake of experimentation, I tried adding the .zshrc file before running this script again on my second machine — nvm and node 14 both installed as expected. Maybe the script could create .zshrc with a single line source ~/.nvm/nvm.sh (or something to that effect) if the file doesn't exist?

@mike-day
Copy link

Also, I did just need to run nvm use 14 separately to actually use v14.19.3.

@kienstra
Copy link
Author

Ah, great idea. Just added your idea of creating a .zshrc file with that single line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment