Skip to content

Instantly share code, notes, and snippets.

@stevebrownlee
Last active July 9, 2024 15:50
Show Gist options
  • Save stevebrownlee/b146bf49071c46c41eddf5778b147a71 to your computer and use it in GitHub Desktop.
Save stevebrownlee/b146bf49071c46c41eddf5778b147a71 to your computer and use it in GitHub Desktop.
Installations for Mac
#!/bin/bash
current_shell=$(echo $SHELL)
if [ $current_shell == "/bin/bash" ]; then
echo -e "\n\n\n"
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
echo "@@ @@"
echo "@@ Change Needed: Switch to zsh @@"
echo "@@ This change might require your computer password. @@"
echo "@@ @@"
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
ZSH_PATH=$(which zsh >>/dev/null)
if [ $? != 0 ]; then
echo "ERROR: zsh not found. Skipping chsh"
else
SWITCHED=$(chsh -s $ZSH_PATH >>/dev/null)
if [ $? != 0 ]; then
echo "ERROR: Could not chsh to zsh"
else
new_shell=$(echo $SHELL)
if [ $new_shell != "$ZSH_PATH" ]; then
# The rest of the installs will not work if zsh is not the default shell
echo "ERROR: Shell did not change to zsh."
exit 1
fi
fi
fi
else
echo "Already using zsh as default shell"
fi
ZSH_FOLDER=$HOME/.oh-my-zsh
if [ ! -d "$FOLDER" ]; then
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
fi
if [ ! -d "${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions" ]; then
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
fi
if [ ! -d "${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting" ]; then
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
fi
if grep -q "(zsh-autosuggestions zsh-syntax-highlighting" ~/.zshrc; then
echo "Text already exists"
else
sed -i'.original' 's#^plugins=(#plugins=(zsh-autosuggestions zsh-syntax-highlighting #' $HOME/.zshrc
fi
echo "Installing VS Code Extensions"
code --install-extension streetsidesoftware.code-spell-checker --force
code --install-extension ms-python.black-formatter --force
code --install-extension formulahendry.auto-close-tag --force
code --install-extension fosshaas.fontsize-shortcuts --force
code --install-extension ecmel.vscode-html-css --force
code --install-extension ms-vsliveshare.vsliveshare --force
code --install-extension cardinal90.multi-cursor-case-preserve --force
code --install-extension ms-vscode-remote.vscode-remote-extensionpack --force
code --install-extension laurenttreguier.vscode-simple-icons --force
code --install-extension bocovo.dbml-erd-visualizer --force
code --install-extension matt-meyers.vscode-dbml --force
#!/bin/bash
clear
echo "Enter your full name exactly as you entered it on Github settings:"
read -p "> " STUDENT_NAME
echo -e "\nEnter email address you used for Github:"
read -p "> " EMAIL_ADDRESS
echo -e "\nEnter your Github account name:"
read -p "> " GH_USERNAME
PUBLIC_KEY=$HOME/.ssh/id_nss.pub
if [ ! -f "$PUBLIC_KEY" ]; then
echo -e "\n\nGenerating an SSH key so you can backup your code to Github..."
echo "yes" | ssh-keygen -t ed25519 -f ~/.ssh/id_nss -N "" -b 4096 -C $EMAIL_ADDRESS
eval $(ssh-agent)
ssh-add ~/.ssh/id_nss
echo -e "Host *\n\tAddKeysToAgent yes\n\tIdentityFile ~/.ssh/id_nss" >>~/.ssh/config
fi
echo -e "\n\nAdding your SSH key to your Github account..."
PUBLIC_KEY_CONTENT=$(cat $HOME/.ssh/id_nss.pub)
STATUS_CODE=$(curl \
-s \
--write-out %{http_code} \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $PERSONAL_ACCESS_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/user/keys \
-d "{\"key\":\"$PUBLIC_KEY_CONTENT\",\"title\":\"NSS Automated Key\"}" >>/dev/null)
if [ ! $STATUS_CODE == 200 ]; then
echo -e "POST for SSH key returned status code $STATUS_CODE"
fi
git config --global user.name "$STUDENT_NAME"
git config --global user.email "$EMAIL_ADDRESS"
#!/bin/bash
if ! type brew &>/dev/null; then
echo -e "\n\n\n\n Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval $(/opt/homebrew/bin/brew shellenv)' >>$HOME/.zprofile
eval $(/opt/homebrew/bin/brew shellenv)
fi
echo -e "\n\nInstalling git and terminal customization tools..."
brew install -q git tig zsh zsh-completions
#!/bin/bash
if ! type nvm &>/dev/null; then
echo -e "Installing Node Version Manager..."
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash >>/dev/null
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
fi
nvm install --lts
nvm use --lts
echo -e "\nInstalling a web server and a simple API server..."
npm config set prefix $HOME/.npm-packages
echo 'export PATH="$PATH:$HOME/.npm-packages/bin"' >>~/.zshrc
source ~/.zshrc &>zsh-reload.log
npm i -g serve json-server json
#!/bin/bash
echo -e "\n\n\n\n"
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
echo "@@ @@"
echo "@@ VERIFYING INSTALLS @@"
echo "@@ @@"
echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
echo ""
if ! type brew &>/dev/null; then
echo "ERROR: Brew not installed"
else
echo "Brew installed"
fi
if ! type node &>/dev/null; then
echo "ERROR: Node not installed"
else
echo "Node installed"
fi
if ! type serve &>/dev/null; then
echo "ERROR: serve not installed"
else
echo "serve installed"
fi
if ! type json-server &>/dev/null; then
echo "ERROR: json-server not installed"
else
echo "json-server installed"
fi
if xcode-select -p &>/dev/null; then
echo "Xcode is installed."
else
echo "ERROR: Xcode is not installed. Please install Xcode."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment