-
-
Save dmfigol/104ac3637c1a29a97c4beb5c953dbe99 to your computer and use it in GitHub Desktop.
A bootstrap script to install my dotfiles and configure a new computer
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
#!/usr/bin/env bash | |
BOOTSTRAP_SCRIPT_PATH="${HOME}/bootstrap.sh" | |
# set colors | |
if tput setaf 1 &> /dev/null; then | |
tput sgr0 | |
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then | |
ORANGE="$(tput setaf 172)" | |
else | |
ORANGE="$(tput setaf 4)" | |
fi | |
RESET="$(tput sgr0)" | |
else | |
ORANGE="\033[1;33m" | |
RESET="\033[m" | |
fi | |
function notice() { | |
echo "${ORANGE}[ notice ] : ${1}${RESET}" | |
} | |
cat >"$BOOTSTRAP_SCRIPT_PATH" <<EOL | |
#\$usr/bin/env bash | |
DOTFILES_REPO="https://github.com/dmfigol/dotfiles.git" | |
# set colors | |
if tput setaf 1 &> /dev/null; then | |
tput sgr0 | |
if [[ \$(tput colors) -ge 256 ]] 2>/dev/null; then | |
ORANGE="\$(tput setaf 172)" | |
else | |
ORANGE="\$(tput setaf 4)" | |
fi | |
RESET="\$(tput sgr0)" | |
else | |
ORANGE="\033[1;33m" | |
RESET="\033[m" | |
fi | |
function notice() { echo "\${ORANGE}[ notice ] : \${1}\${RESET}" ; } | |
function macos_dev_tools() { | |
notice "Confirming we have developer tools..." | |
if ! xcode-select --print-path &> /dev/null; then | |
xcode-select --install &> /dev/null | |
until xcode-select --print-path &> /dev/null; do | |
sleep 5 | |
done | |
notice 'XCode Command Line Tools Installed' | |
else | |
notice "Command Line Tools are already installed" | |
fi | |
} | |
macos_dev_tools | |
function seek_confirmation() { | |
notice "\$@" | |
while true; do | |
read -p " (y/n) " yn | |
case \$yn in | |
[Yy]* ) return 0 ;; | |
[Nn]* ) return 1 ;; | |
* ) input "Please answer yes or no." ;; | |
esac | |
done | |
} | |
function cloneRepo() { | |
notice "Cloning dotfiles repo..." | |
cd "\$HOME" | |
if ! git clone "\$DOTFILES_REPO"; then | |
notice "Uh oh. Seems we had problems..." | |
notice "Try running this script again once resolved" | |
exit 1 | |
else | |
notice "Repo successfully cloned" | |
fi | |
} | |
cloneRepo | |
exit 0 | |
EOL | |
chmod a+x "$BOOTSTRAP_SCRIPT_PATH" | |
notice "SUCCESS! '$BOOTSTRAP_SCRIPT_PATH' created." | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment