From 242089bb2c13b5114eb3e50c4614882e9e172d35 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Sat, 26 Aug 2023 00:28:19 -0400 Subject: [PATCH] Check before installing starship. A bit o refactor --- copy.sh | 84 +++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 32 deletions(-) diff --git a/copy.sh b/copy.sh index 652020c..a3d5e40 100755 --- a/copy.sh +++ b/copy.sh @@ -22,36 +22,56 @@ if [[ "$1" != "--install" ]]; then done touch "$HOME/.zsh_local" -else - # Install required packages - echo -n "Rust is " - if ! command -v cargo; then - echo "not installed. Installing..." - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - else - echo "installed." - fi - . "$HOME/.cargo/env" - if command -v cargo && ! command -v bat; then - cargo install bat - fi - if ! test -d "$HOME/.nvm"; then - curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash - export NVM_DIR="$HOME/.nvm" - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm - [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion - nvm install 14 - nvm install 18 - nvm install node - nvm use node - fi - if ! command -v dotnet; then - wget https://dot.net/v1/dotnet-install.sh -O /tmp/dotnet-install.sh - chmod +x /tmp/dotnet-install.sh - /tmp/dotnet-install.sh --version latest - rm /tmp/dotnet-install.sh - fi - curl -sS https://starship.rs/install.sh | sh - echo "Starship requires an NFont: https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/FiraCode.zip" - echo "You may wish to install fzf" + exit 0 fi + +# Install required packages +echo -n "Rust is " +if ! command -v cargo; then + echo "not installed. Installing..." + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +else + echo "already installed." +fi + +. "$HOME/.cargo/env" +if command -v cargo && ! command -v bat; then + cargo install bat +fi + +echo "nvm is " +if ! test -d "$HOME/.nvm"; then + echo "not installed. Installing..." + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm + [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + nvm install 14 + nvm install 18 + nvm install node + nvm use node +else + echo "already installed." +fi + +echo "dotnet is " +if ! command -v dotnet; then + echo "not installed. Installing..." + wget https://dot.net/v1/dotnet-install.sh -O /tmp/dotnet-install.sh + chmod +x /tmp/dotnet-install.sh + /tmp/dotnet-install.sh --version latest + rm /tmp/dotnet-install.sh +else + echo "already installed." +fi + +echo "starship is " +if ! command -v starship; then + echo "not installed. Installing..." +curl -sS https://starship.rs/install.sh | sh +echo "Starship requires an NFont: https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/FiraCode.zip" +else + echo "already installed." +fi + +echo "You may wish to install fzf for sofi and other search"