From 6190be3bdd98b90f21e3f89aa504d12f484e8429 Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Sat, 10 Dec 2022 22:23:57 +0200 Subject: [PATCH] settler.sh, fixes, updates --- Brewfile | 1 + install.sh | 38 +++++++++++++------------- local/bin/dotfiles | 1 + scripts/set-defaults.sh | 3 ++- scripts/settler.sh | 59 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 83 insertions(+), 19 deletions(-) create mode 100755 scripts/settler.sh diff --git a/Brewfile b/Brewfile index 84592ae..7bbed8d 100644 --- a/Brewfile +++ b/Brewfile @@ -229,6 +229,7 @@ cask "vlc" # Rust-based terminal cask "warp" mas "1Password for Safari", id: 1569813296 +mas "Flow", id: 1423210932 mas "GarageBand", id: 682658836 mas "iMovie", id: 408981434 mas "Keynote", id: 409183694 diff --git a/install.sh b/install.sh index ffc43f5..87bf178 100755 --- a/install.sh +++ b/install.sh @@ -66,21 +66,23 @@ handle_file_ln() $MKDIR -p "$($DIRNAME "$2")" $LN -sf "$1" "$2" } -handle_file_ln "/Users/ivuorinen/.dotfiles/bash_profile" "/Users/ivuorinen/.bash_profile" -handle_file_ln "/Users/ivuorinen/.dotfiles/bashrc" "/Users/ivuorinen/.bashrc" -handle_file_ln "/Users/ivuorinen/.dotfiles/config/alias" "/Users/ivuorinen/.config/alias" -handle_file_ln "/Users/ivuorinen/.dotfiles/config/antigen.zsh" "/Users/ivuorinen/.config/antigen.zsh" -handle_file_ln "/Users/ivuorinen/.dotfiles/config/gh/config.yml" "/Users/ivuorinen/.config/gh/config.yml" -handle_file_ln "/Users/ivuorinen/.dotfiles/config/git/config" "/Users/ivuorinen/.config/git/config" -handle_file_ln "/Users/ivuorinen/.dotfiles/config/git/gitignore" "/Users/ivuorinen/.config/git/gitignore" -handle_file_ln "/Users/ivuorinen/.dotfiles/config/wtf/config.yml" "/Users/ivuorinen/.config/wtf/config.yml" -handle_file_ln "/Users/ivuorinen/.dotfiles/git_profiles" "/Users/ivuorinen/.git_profiles" -handle_file_ln "/Users/ivuorinen/.dotfiles/huskyrc" "/Users/ivuorinen/.huskyrc" -handle_file_ln "/Users/ivuorinen/.dotfiles/local/bin/dotfiles" "/Users/ivuorinen/.local/bin/dotfiles" -handle_file_ln "/Users/ivuorinen/.dotfiles/local/bin/x-check-git-attributes" "/Users/ivuorinen/.local/bin/x-check-git-attributes" -handle_file_ln "/Users/ivuorinen/.dotfiles/local/bin/x-open-ports" "/Users/ivuorinen/.local/bin/x-open-ports" -handle_file_ln "/Users/ivuorinen/.dotfiles/rcrc" "/Users/ivuorinen/.rcrc" -handle_file_ln "/Users/ivuorinen/.dotfiles/ssh/allowed_signers" "/Users/ivuorinen/.ssh/allowed_signers" -handle_file_ln "/Users/ivuorinen/.dotfiles/ssh/config" "/Users/ivuorinen/.ssh/config" -handle_file_ln "/Users/ivuorinen/.dotfiles/vuerc" "/Users/ivuorinen/.vuerc" -handle_file_ln "/Users/ivuorinen/.dotfiles/zshrc" "/Users/ivuorinen/.zshrc" +handle_file_ln "~/.dotfiles/bash_profile" "~/.bash_profile" +handle_file_ln "~/.dotfiles/bashrc" "~/.bashrc" +handle_file_ln "~/.dotfiles/config/alias" "~/.config/alias" +handle_file_ln "~/.dotfiles/config/antigen.zsh" "~/.config/antigen.zsh" +handle_file_ln "~/.dotfiles/config/exports" "~/.config/exports" +handle_file_ln "~/.dotfiles/config/functions" "~/.config/functions" +handle_file_ln "~/.dotfiles/config/gh/config.yml" "~/.config/gh/config.yml" +handle_file_ln "~/.dotfiles/config/git/config" "~/.config/git/config" +handle_file_ln "~/.dotfiles/config/git/gitignore" "~/.config/git/gitignore" +handle_file_ln "~/.dotfiles/config/wtf/config.yml" "~/.config/wtf/config.yml" +handle_file_ln "~/.dotfiles/git_profiles" "~/.git_profiles" +handle_file_ln "~/.dotfiles/huskyrc" "~/.huskyrc" +handle_file_ln "~/.dotfiles/local/bin/dotfiles" "~/.local/bin/dotfiles" +handle_file_ln "~/.dotfiles/local/bin/x-check-git-attributes" "~/.local/bin/x-check-git-attributes" +handle_file_ln "~/.dotfiles/local/bin/x-open-ports" "~/.local/bin/x-open-ports" +handle_file_ln "~/.dotfiles/rcrc" "~/.rcrc" +handle_file_ln "~/.dotfiles/ssh/allowed_signers" "~/.ssh/allowed_signers" +handle_file_ln "~/.dotfiles/ssh/config" "~/.ssh/config" +handle_file_ln "~/.dotfiles/vuerc" "~/.vuerc" +handle_file_ln "~/.dotfiles/zshrc" "~/.zshrc" diff --git a/local/bin/dotfiles b/local/bin/dotfiles index ef5112f..9de5590 100755 --- a/local/bin/dotfiles +++ b/local/bin/dotfiles @@ -90,6 +90,7 @@ function section_dotfiles rcup -B 0 -g \ | tee "$INSTALL_SCRIPT" 1> /dev/null \ && shfmt -w -l "$INSTALL_SCRIPT" \ + && sed -i '' "s|$HOME|\~|g" "$INSTALL_SCRIPT" \ && echo "🎉 Done!" ;; shfmt) diff --git a/scripts/set-defaults.sh b/scripts/set-defaults.sh index 65d3265..774717c 100755 --- a/scripts/set-defaults.sh +++ b/scripts/set-defaults.sh @@ -4,7 +4,8 @@ echo 'start osx/set-defaults.sh' # Ask for the administrator password upfront sudo -v -# Keep-alive: update existing `sudo` time stamp until `.osx` has finished +# Keep-alive: update existing `sudo` time stamp +# until this script has finished while true; do sudo -n true sleep 60 diff --git a/scripts/settler.sh b/scripts/settler.sh new file mode 100755 index 0000000..66bce86 --- /dev/null +++ b/scripts/settler.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +# +# Settler - my macOS setup automator + +# Ask for the administrator password upfront +sudo -v + +# Keep-alive: update existing `sudo` time stamp until `settler` has finished +while true; do + sudo -n true + sleep 60 + kill -0 "$$" || exit +done 2> /dev/null & + +# https://unix.stackexchange.com/a/408305 +# check if user has git installed and propose to install if not installed +if [ "$(which git)" ]; then + echo "You already have git. Continuing..." +else + XCODE_MESSAGE="$( + osascript -e \ + 'tell app "System Events" to display dialog "Please click install when Command Line Developer Tools appears"' + )" + + if [ "$XCODE_MESSAGE" = "button returned:OK" ]; then + xcode-select --install + else + echo "You have cancelled the installation, please rerun the installer." + exit + fi +fi + +until [ "$(which git)" ]; do + echo -n "." + sleep 1 +done + +# Install brew +if [ "$(which brew)" ]; then + echo 'Brew already installed' +else + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +fi + +bash ../local/bin/dotfiles brew install && "Installed Brewfile contents" +bash ../local/bin/dotfiles dotfiles link && "Linked all dotfiles" + +read -r -p "Do you want to set macOS defaults? (y/N) " yn + +case $yn in + [yY]) + bash "set-defaults.sh" + ;; + *) + echo "Skipping..." + ;; +esac + +echo "Done. Note that some of these changes require a logout/restart to take effect."