#!/bin/bash -
# ------------------------------------------------------------------------------
# deploy-apps-libs.sh
# ===================
#
# Scope macOS
# Copyright (C) 2024 by RaySoft, Zurich, Switzerland
# License GNU General Public License (GPL) 2.0
# https://www.gnu.org/licenses/gpl2.txt
#
# ------------------------------------------------------------------------------
set -o 'noglob' -o 'nounset' -o 'pipefail' # -o 'errexit' -o 'xtrace'
# ------------------------------------------------------------------------------
# URL to the Homebrew installation script
DP_HOMEBREW_INSTALL='https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh'
# List of Homebrew taps to be used
DP_HOMEBREW_TAPS=(
'homebrew/cask-fonts'
# Tap from https://github.com/anchore/grype
'anchore/grype'
# Tap from https://github.com/perkons/homebrew-sshpass
'perkons/sshpass'
)
# List of Homebrew formulae to be installed
DP_HOMEBREW_FORMULAE=(
# Formulae from default tap
# https://github.com/Homebrew/homebrew-core/
'ansible'
'bash'
'bash-completion@2'
'bitwarden-cli'
'brew-cask-completion'
'coreutils'
'curl'
'direnv'
'duti'
'eza'
'findutils'
'flake8' # Used for the Sublime Text package
# 'SublimeLinter-flake8'
'gawk'
'git'
'gnu-sed'
'gnu-tar'
'grep'
'grype'
'hwatch'
'imagemagick'
'jc'
'jq'
'mas'
'neovim'
'open-completion'
'pandoc'
'python@3.12'
'qrencode'
'rclone'
'rsync'
'shellcheck' # Used for the Sublime Text package
# 'SublimeLinter-shellcheck'
'ssh-audit'
'sshpass'
'tag'
'unison'
'yamllint' # Used for the Sublime Text package
# 'SublimeLinter-contrib-yamllint'
'yq'
'yt-dlp'
)
# List of Homebrew casks to be installed
DP_HOMEBREW_CASKS=(
# Casks from the default tap
# https://github.com/Homebrew/homebrew-cask/
'alfred'
'basictex'
'calibre'
'drawio'
'firefox'
'fujitsu-scansnap-home'
'garmin-basecamp'
'garmin-express'
'gnucash'
'integrity'
'iterm2'
'jdownloader'
'keepassxc'
'keka'
'knockknock'
'libreoffice'
'little-snitch'
'malwarebytes'
'microsoft-teams'
'obsidian'
'omnifocus'
'onyx'
'oversight'
'ransomwhere'
'securesafe'
'setapp'
'soundsource'
'sublime-text'
'teamviewer'
'vlc'
'witch'
# Casks from 'homebrew/cask-fonts' tap
# https://github.com/Homebrew/homebrew-cask-fonts/
'font-anka-coder'
'font-anonymous-pro'
'font-fira-code'
'font-hack'
'font-jetbrains-mono'
'font-juliamono'
'font-source-code-pro'
'font-ubuntu-mono'
# Casks from 'macos-fuse-t/cask' tap
# https://github.com/macos-fuse-t/
'macos-fuse-t/homebrew-cask/fuse-t'
'macos-fuse-t/homebrew-cask/fuse-t-sshfs'
)
# List of Apple App Store apps to be installed
DP_APPSTORE_APPS=(
'1365531024' # 1Blocker
'1593408455' # Anybox
'1352778147' # Bitwarden
'1482920575' # DuckDuckGo Privacy Essentials
'1529448980' # Reeder
)
# List of Setapp apps to be installed
# NOTE: Setapp has not command line tool yet! :-(
DP_SETAPP_APPS=(
'AirBuddy'
'Bartender'
'CleanMyMac X'
'iStat Menus'
'Lungo'
'Marked'
'MindNode'
)
# List of Node.js packages to be installed
DP_NODE_PACKAGES=(
'jshint' # Used for the Sublime Text package
# 'SublimeLinter-jshint'
'markdownlint-cli' # Used for the Sublime Text package
# 'SublimeLinter-contrib-markdownlint'
)
# ------------------------------------------------------------------------------
# Define binaries and their parameters
DP_X_BASH=('/bin/bash' '-c')
DP_X_BREW=('/usr/local/bin/brew')
DP_X_CURL=('/usr/bin/curl' '--fail' '--location' '--show-error' '--silent')
DP_X_LN=('/bin/ln' '-f' '-s')
DP_X_MAS=('/usr/local/bin/mas')
DP_X_NPM=('/usr/local/bin/npm' '--global')
DP_X_PIP=('/usr/local/bin/pip3')
DP_X_XCODE_SELECT=('/usr/bin/xcode-select')
# ------------------------------------------------------------------------------
# macOS: Install Apple's command line developer tools
"${DP_X_XCODE_SELECT[@]}" --install
# Homebrew: Install Homebrew itself
"${DP_X_BASH[@]}" "$("${DP_X_CURL[@]}" "${DP_HOMEBREW_INSTALL}")"
# Homebrew: Disable analytics
"${DP_X_BREW[@]}" analytics 'off'
# Homebrew: Install all taps defined in DP_HOMEBREW_TAPS
for tap in "${DP_HOMEBREW_TAPS[@]}"; do
"${DP_X_BREW[@]}" tap "${tap}"
done
# Homebrew: Update Homebrew itself & sync all taps
"${DP_X_BREW[@]}" update
# Homebrew: Install all formulae defined in DP_HOMEBREW_FORMULAE
"${DP_X_BREW[@]}" install --formula "${DP_HOMEBREW_FORMULAE[@]}"
# macOS: Link binaries
for bin in 'find' {,'e','f'}'grep' 'sed' 'tar' 'updatedb' 'xargs'; do
src_bin="/usr/local/bin/g${bin}"
dst_link="/usr/local/opt/coreutils/libexec/gnubin/${bin}"
if [[ -f "${src_bin}" && -x "${src_bin}" ]]; then
"${DP_X_LN[@]}" "${src_bin}" "${dst_link}"
else
echo "Error finding binary: g${bin}!"
fi
done
src_bin='/usr/local/opt/curl/bin/curl'
dst_link='/usr/local/bin/curl'
if [[ -f "${src_bin}" && -x "${src_bin}" ]]; then
"${DP_X_LN[@]}" "${src_bin}" "${dst_link}"
else
nf::carp 'Error finding binary: curl!'
fi
# Homebrew: Install all casks defined in DP_HOMEBREW_CASKS
"${DP_X_BREW[@]}" install --cask --force "${DP_HOMEBREW_CASKS[@]}"
# macOS: Install all Apple App Store apps defined in DP_APPSTORE_APPS
"${DP_X_MAS[@]}" install "${DP_APPSTORE_APPS[@]}"
# npm: Install all Node JavaScript packages defined in DP_NODE_PACKAGES
"${DP_X_NPM[@]}" install "${DP_NODE_PACKAGES[@]}"
# ------------------------------------------------------------------------------
exit 0
~/dev/deploy-apps-libs.sh