Last active
June 28, 2022 21:16
-
-
Save kienstra/af4f8ad4c0606343eeb09e7de117ed93 to your computer and use it in GitHub Desktop.
Installs CLI packages, like Node and Composer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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." |
Oh, good idea to add a .zshrc
, I didn't know new machines don't always come with them.
Do you remember the error messages from the failed nvm
or node
installations, by chance?
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?
Also, I did just need to run nvm use 14
separately to actually use v14.19.3.
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
The script did not crash for me, but I did already have homebrew installed. I also added .zshrc in my root directory prior to make sure the nvm stuff worked as expected.
Interestingly enough, I did just try running this script on another machine and found that a few things did not install successfully (namely, neither nvm or node 14 seemed to install).