<commit_before>#!/bin/bash

# Install Brew, taps, packages, and casks

# Install Brew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

# Ask for the administrator password upfront.
sudo -v

# Keep-alive: update existing `sudo` time stamp until the script has finished.
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &

brew update
brew upgrade --all

# get current directory
BREW_DIR=$(dirname $BASH_SOURCE)

for tap in $(cat $BREW_DIR/taps.txt); do
  brew tap $tap
done

for package in $(cat $BREW_DIR/packages.txt); do
  brew install $package
  brew upgrade $package
done

for cask in $(cat $BREW_DIR/casks.txt); do
  # There's currently no way to cleanly upgrade a cask yet
  # so in order to prevent multiple versions of a cask
  # polluting the Caskroom (and hence turning up in Alfred searches),
  # you need to go into the Caskroom and manually remove older versions
  brew cask install $cask
done

brew cask cleanup
brew cleanup

# Bring over the saved search for Homebrew apps that will go in the Finder
mkdir -p ~/Library/Saved\ Searches && cp $BREW_DIR/Homebrew\ Apps.savedSearch "$_"<commit_msg>Play keep-alive with sudo during brew installation<commit_after>#!/bin/bash

# Install Brew, taps, packages, and casks

# Install Brew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

# Ask for the administrator password upfront.
sudo -v

brew update
brew upgrade --all

# get current directory
BREW_DIR=$(dirname $BASH_SOURCE)

for tap in $(cat $BREW_DIR/taps.txt); do
  brew tap $tap
done

for package in $(cat $BREW_DIR/packages.txt); do
  # Keep sudo alive during package installation as sudo will be needed
  # to install some of the brew casks
  sudo -n true
  brew install $package
  brew upgrade $package
done

for cask in $(cat $BREW_DIR/casks.txt); do
  # There's currently no way to cleanly upgrade a cask yet
  # so in order to prevent multiple versions of a cask
  # polluting the Caskroom (and hence turning up in Alfred searches),
  # you need to go into the Caskroom and manually remove older versions.
  #
  # Sudo is being used to install every cask because, at the very least, casks
  # that have a pkg file require it, and there's no way to distinguish at the
  # outset whether it will be needed or not and we don't want the script to halt
  # midway prompting for a password.
  sudo brew cask install $cask
done

brew cask cleanup
brew cleanup

# Bring over the saved search for Homebrew apps that will go in the Finder
mkdir -p ~/Library/Saved\ Searches && cp $BREW_DIR/Homebrew\ Apps.savedSearch "$_"
{'fraction_non_alphanumeric': 0.0801209372637944, 'fraction_numerical': 0.0015117157974300832, 'mean_word_length': 3.910946196660482, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4691899', 'n_tokens_mistral': 861, 'n_tokens_neox': 799, 'n_words': 370}