Skip to content

Instantly share code, notes, and snippets.

@vraravam
Last active April 12, 2024 12:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save vraravam/698925e88a601d18a79f9c79edc33611 to your computer and use it in GitHub Desktop.
Save vraravam/698925e88a601d18a79f9c79edc33611 to your computer and use it in GitHub Desktop.
#!/usr/bin/env zsh
# Note: This script is specific to my setup and not useful for others.
# You can run this script using this command:
# curl -L https://gist.githubusercontent.com/vraravam/698925e88a601d18a79f9c79edc33611/raw -o fresh-install-vijay.sh; chmod +x ./fresh-install-vijay.sh; ./fresh-install-vijay.sh
# These env vars are duplicated intentionally since this script would bootstrap the installation
USERNAME=${USERNAME:-$(whoami)}
PERSONAL_PROFILES_DIR=${PERSONAL_PROFILES_DIR:-"${HOME}/personal/${USERNAME}/profiles"}
PERSONAL_BIN_DIR=${PERSONAL_BIN_DIR:-"${HOME}/.bin"}
rm -rf "${HOME}/.gitconfig-template.inc"
# utility functions
source "${HOME}/.aliases"
override_prompt() {
echo "$(blue 'Downloading') '${2}' : "
if [ ! -f "${2}" ]; then
echo " $(yellow ' since its not present already')"
curl -fsSL "${1}" -o "${2}"
else
read "yn?$(red ' already present'). Should I override [yn]? "
case $yn in
[Yy]*) curl -fsSL "${1}" -o "${2}" && echo " $(green "downloaded '${2}'")";;
[Nn]*) warn " skipping download of '${2}' since its already present";;
esac
fi
}
override_prompt https://gist.githubusercontent.com/vraravam/eb2161236d78fc0bda77/raw "${HOME}/.gemrc"
#######################
# Clone the home repo #
#######################
if [ ! -d "${HOME}/.git" ]; then
rm -rf "${HOME}/tmp"
mkdir -p "${HOME}/tmp"
git clone --depth=1 keybase://private/avijayr/vijay "${HOME}/tmp"
mv "${HOME}/tmp/.git" "${HOME}/"
rm -rf "${HOME}/tmp"
############################################################################################################################
# Checkout some of the common dotfiles (these should not have any modifications/conflicts with what is in the remote repo) #
############################################################################################################################
git -C "${HOME}" checkout ".[a-zA-Z]*" Brewfile personal
git -C "${HOME}" restore-mtime -c
else
warn 'skipping cloning of home repo since its already present'
fi
source "${HOME}/.aliases.${USERNAME}"
###########################
# Clone the profiles repo #
###########################
if [ ! -d "${PERSONAL_PROFILES_DIR}/.git" ]; then
rm -rf "${PERSONAL_PROFILES_DIR}"
git clone --depth=1 keybase://private/avijayr/profiles "${PERSONAL_PROFILES_DIR}"
else
warn 'skipping cloning of profiles repo since its already present'
fi
#########################################
# Fix /etc/hosts file to block facebook #
#########################################
sudo cp "${PERSONAL_BIN_DIR}/macos/etc.hosts" /etc/hosts
##################################################
# Resurrect repositories that I am interested in #
##################################################
sudo chmod -R 600 "${HOME}"/.ssh/*
resurrect-repositories.rb -r "${PERSONAL_CONFIGS_DIR}/repositories-oss.yml"
all restore-mtime -c
allow_all_direnv_configs
install_mise_versions
##################
# Install devbox #
##################
# curl -fsSL https://get.jetpack.io/devbox | bash
# mkdir -p ${HOME}/.config/devbox/lib/ && devbox completion zsh > ${HOME}/.config/devbox/lib/use_devbox.sh
source "${HOME}/.zprofile"
# exec zsh
##############################################
# Load the direnv config for the home folder #
##############################################
cd ..
cd -
# To install the latest versions of the hex, rebar and phoenix packages
# mix local.hex --force && mix local.rebar --force
# mix archive.install hex phx_new 1.4.1
# To install the native-image tool after graalvm is installed
# gu install native-image
# Enabling history for iex shell (might need to be done for each erl that is installed via mise)
# rm -rf tmp
# mkdir -p tmp
# cd tmp || exit
# git clone --depth=1 https://github.com/ferd/erlang-history.git
# cd erlang-history || exit
# sudo make install
# cd ../.. || exit
# rm -rf tmp
# vagrant plugin install vagrant-vbguest
# if installing jhipster for dot-net-core
# TODO: Use the next line since the released version is only for .net 2.2:
# npm i -g generator-jhipster-dotnetcore
# Note: '-g' didnt work. Had to do 'npm init' and then use '--save-dev' to install and link as a local dependency
# npm i -g jhipster/jhipster-dotnetcore
# npm link generator-jhipster-dotnetcore
# jhipster -d --blueprints dotnetcore
###################################################################
# Restore the preferences from the older machine into the new one #
###################################################################
osx-defaults.sh -y
capture-defaults.sh i
# Default tooling for dotnet projects
# dotnet tool install -g dotnet-sonarscanner
# dotnet tool install -g dotnet-format
echo "\n"
echo $(green "********** Finished auto installation process: Please perform these manual steps **********")
echo $(red "1. Go to VSCodium > Command Palette (Cmd+Shift+P) > Sync Settings: Download (repository -> user)")
echo $(red "2. Manually setup the Finder preferences for sidebar")
echo $(red "3. Login into iCloud and setup Desktop sync")
echo $(red "4. Login for Software Update to different ID (after iCloud login) for beta updates")
echo $(red "5. Turn off battery in top nav bar")
echo $(red "6. Setup cron jobs")
@vraravam
Copy link
Author

vraravam commented Mar 4, 2024

Fixed issue with oh-my-zsh complaining about being loaded from bash. Turned out, I was running this script via bash. Fixed the read command now to work with zsh, and that allowed me to switch to using zsh for this script.

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