Initial commit of scripts

This commit is contained in:
Phillip 2024-05-23 17:39:59 +01:00
parent 1fbc16e267
commit 42cfbbfc56
4 changed files with 217 additions and 0 deletions

48
Brewfile Normal file
View File

@ -0,0 +1,48 @@
tap "homebrew/bundle"
tap "homebrew/cask-fonts"
tap "homebrew/services"
brew "xz"
brew "openssl@3"
brew "readline"
brew "sqlite"
brew "php"
brew "composer"
brew "dnsmasq"
brew "ffmpeg"
brew "git"
brew "imagemagick"
brew "mas"
brew "nginx"
brew "nvm"
brew "pipx"
brew "pkg-config"
brew "pyenv"
brew "tcl-tk"
brew "yt-dlp"
brew "zlib"
cask "1password"
cask "adguard"
cask "arq"
cask "bbedit"
cask "choosy"
cask "dbngin"
cask "discord"
cask "firefox"
cask "font-jetbrains-mono"
cask "mullvad-browser"
cask "mullvadvpn"
cask "netnewswire"
cask "obsidian"
cask "onyx"
cask "rectangle"
cask "responsively"
cask "sequel-ace"
cask "syncthing"
cask "transmit"
cask "visual-studio-code"
cask "vlc"
cask "vmware-fusion"
mas "Numbers", id: 409203825
mas "Pages", id: 409201541
mas "Pixelmator Pro", id: 1289583905
mas "Xcode", id: 497799835

40
Dock.sh Executable file
View File

@ -0,0 +1,40 @@
#!/bin/bash
LOGGED_USER=`stat -f%Su /dev/console`
sudo su $LOGGED_USER -c 'defaults delete com.apple.dock persistent-apps'
dock_item() {
printf '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>%s</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>', "$1"
}
settings=$(dock_item /System/Applications/System\ Settings.app)
launch=$(dock_item /System/Applications/Launchpad.app)
terminal=$(dock_item /System/Applications/Utilities/Terminal.app)
calendar=$(dock_item /System/Applications/Calendar.app)
reminders=$(dock_item /System/Applications/Reminders.app)
mail=$(dock_item /System/Applications/Mail.app)
rss=$(dock_item /Applications/NetNewsWire.app)
messages=$(dock_item /System/Applications/Messages.app)
discord=$(dock_item /Applications/Discord.app)
firefox=$(dock_item /Applications/Firefox.app)
safari=$(dock_item /System/Cryptexes/App/System/Applications/Safari.app)
music=$(dock_item /System/Applications/Music.app)
video=$(dock_item /System/Applications/QuickTime\ Player.app)
video2=$(dock_item /Applications/VLC.app)
notes=$(dock_item /System/Applications/Notes.app)
notes2=$(dock_item /Applications/Obsidian.app)
pages=$(dock_item /Applications/Pages.app)
numbers=$(dock_item /Applications/Numbers.app)
photos=$(dock_item /System/Applications/Photos.app)
pixel=$(dock_item /Applications/Pixelmator\ Pro.app)
vscode=$(dock_item /Applications/Visual\ Studio\ Code.app)
rwd=$(dock_item /Applications/ResponsivelyApp.app)
db=$(dock_item /Applications/Sequel\ Ace.app)
ftp=$(dock_item /Applications/Transmit.app)
xcode=$(dock_item /Applications/Xcode.app)
xcodesim=$(dock_item /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app)
textedit=$(dock_item /Applications/BBEdit.app)
sudo su $LOGGED_USER -c "defaults write com.apple.dock persistent-apps -array '$settings' '$launch' '$terminal' '$calendar' '$reminders' '$mail' '$rss' '$messages' '$discord' '$firefox' '$safari' '$music' '$video' '$video2' '$notes' '$notes2' '$pages' '$numbers' '$photos' '$pixel' '$vscode' '$rwd' '$db' '$ftp' '$xcode' '$xcodesim' '$textedit' "
killall Dock

101
setup.sh Executable file
View File

@ -0,0 +1,101 @@
#!/bin/bash
echo "Configuring macOS System Settings (you may be asked to enter password)"
# Enable and configure firewall
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setstealthmode on
# Set DNS servers
networksetup -setdnsservers Ethernet 1.1.1.1 1.0.0.1 2606:4700:4700::1111 2606:4700:4700::1001
networksetup -setdnsservers Wi-Fi 1.1.1.1 1.0.0.1 2606:4700:4700::1111 2606:4700:4700::1001
# Disable Handoff
defaults -currentHost write com.apple.coreservices.useractivityd ActivityAdvertisingAllowed -bool no
defaults -currentHost write com.apple.coreservices.useractivityd ActivityReceivingAllowed -bool no
# Configure the Dock
# Disable "Show recent applications in Dock"
defaults write com.apple.dock "show-recents" -bool FALSE
# Set "Minimise windows using" to "Scale Effect"
defaults write com.apple.dock mineffect scale
# Enable "Minimise windows into application icon"
defaults write com.apple.dock "minimize-to-application" -bool TRUE
# Set numbers of rows and columns in Launchpad
defaults write com.apple.dock springboard-columns -int 6;
defaults write com.apple.dock springboard-columns -int 6;
# Increase mouse speed beyond available options in System Settings
echo "Increase mouse speed"
defaults write -g com.apple.mouse.scaling 9
# Configure Finder
echo "Configuring Finder"
# Set list view as default
defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv"
# Show the path and status bars (TODO: setting for tabs bar)
defaults write com.apple.finder ShowPathbar -bool true
defaults write com.apple.finder ShowStatusBar -bool true
# Sort files so directories appear above files
defaults write com.apple.finder _FXSortFoldersFirst -bool true
# Set the default search scope to be the current folder
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
# Set default location for Finder to the home directory
defaults write com.apple.finder "NewWindowTarget" -string "PfHm"
defaults write com.apple.finder "NewWindowTargetPath" -string "file://${HOME}/"
# Create location for saving screenshots and set it as the default
# Also remove shadow effect macOS adds to window screenshots
echo "- Screenshots saved to ~/Pictures/Screenshots with shadow effects disabled"
mkdir -p ~/Pictures/Screenshots
defaults write com.apple.screencapture location -string "${HOME}/Pictures/Screenshots"
defaults write com.apple.screencapture disable-shadow -bool true
# Avoid creating .DS_Store files on network or USB volumes
# ToDo - Check if this actually works
echo "- Avoid creating .DS_Store files on external volumes"
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
# Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Run Homebrew bundle with specified file
brew bundle --file Brewfile
# Run bash script to reconfigure Dock
./Dock.sh
# Applescript to open up Terminal using the downloaded theme
mv Custom.terminal ~/Downloads/Custom.terminal
osascript <<EOD
tell application "Terminal"
activate
set TerminalThemeFile to (POSIX path of ((path to home folder) as text) & "/Downloads/Custom.terminal")
open TerminalThemeFile
delay 1
end tell
EOD
# Set theme to default
defaults write com.apple.Terminal "Startup Window Settings" -string "Custom"
defaults write com.apple.Terminal "Default Window Settings" -string "Custom"
rm ~/Downloads/Custom.terminal
# Copy ZSH Profile
rsync zshrc ~/.zshrc
source ~/.zshrc
# Install LTS version of Node and the second most recent version of Python
# ToDo - programmatically set the Python version instead of directly specifying it
nvm install --lts
pyenv install 3.11
pyenv global 3.11
# Install imagemagic module for PHP
pecl install imagick
# Install Laravel Valet
composer global require laravel/valet
valet install
# Prompt user to reboot
echo "Setup complete, please reboot."

28
zshrc Normal file
View File

@ -0,0 +1,28 @@
# Composer
export PATH="$HOME/.composer/vendor/bin:$PATH"
# Homebrew
export PATH="/usr/local/sbin:$PATH"
# Node.js
## NVM
export NVM_DIR="$HOME/.nvm"
### Load NVM
[ -s "$(brew --prefix)/opt/nvm/nvm.sh" ] && \. "$(brew --prefix)/opt/nvm/nvm.sh"
### Load bash completion
[ -s "$(brew --prefix)/opt/nvm/etc/bash_completion.d/nvm" ] && \. "$(brew --prefix)/opt/nvm/etc/bash_completion.d/nvm"
# Python
## pyenv
export PYENV_ROOT="$HOME/.pyenv"
### pyenv setup
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
## pipx
export PATH="$PATH:/~/.local/bin"