From 30ccf50c282c942796f31e3843f278ae1fbdf076 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 22 Jul 2023 22:00:59 -0300 Subject: per-device configuration support --- .zshrc | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/.zshrc b/.zshrc index b7a3e7e..e9b83c4 100644 --- a/.zshrc +++ b/.zshrc @@ -1,6 +1,31 @@ # ~nebula/.zshrc, 2023 edition +# //// per-device configuration ///////////////////////////////////////////// # + +# Per-device configuration is kept here in dotfiles.git too, but it won't be +# activated just by linking .zshrc. You also need to link ~/.device_pre and +# ~/.device_post to the relevant per-device files under `device`. + +# All exports in pre-config are prefixed with `DEVICE_`, and are used to toggle +# features or identify installations in .zshrc or other scripts which are part +# of dotfiles.git. + +device_preconfig() { + source ~/.device_pre +} + +# The post-config file is intended to run commands that are so specialized to +# the relevant device that it wouldn't make sense to include as a toggleable +# feature in the main .zshrc. + +device_postconfig() { + source ~/.device_post +} + +device_preconfig + + # //// zsh configuration //////////////////////////////////////////////////// # if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then @@ -18,21 +43,41 @@ path+=("$HOME/bin") # -- GPG -- -export GPG_TTY=$(tty) +if [[ -v DEVICE_HAS_GPG ]]; then + export GPG_TTY=$(tty) +fi # -- Homebrew -- -eval "$(/opt/homebrew/bin/brew shellenv)" +if [[ -v DEVICE_HAS_HOMEBREW ]]; then + eval "$("$DEVICE_HOMEBREW_INSTALLATION"/bin/brew shellenv)" +fi # -- Node Version Manager -- -export NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" -[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" +if [[ -v DEVICE_HAS_NVM ]]; then + export NVM_DIR="$DEVICE_NVM_INSTALLATION" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" +fi # -- Python -- -path+=("$HOME/Library/Python/3.9/bin") -path+=("/Applications/Sublime Text.app/Contents/SharedSupport/bin") +if [[ -v DEVICE_HAS_PYTHON_3 ]]; then + PATH+=("$DEVICE_PYTHON_3_INSTALLATION/bin") +fi + +# -- Sublime Text -- + +if [[ -v DEVICE_HAS_SUBLIME_TEXT ]]; then + PATH+=("$DEVICE_SUBLIME_TEXT_INSTALLATION)/Contents/SharedSupport/bin") +fi + export PATH + + +# //// per-device configuration ///////////////////////////////////////////// # + +device_postconfig + -- cgit 1.3.0-6-gf8a5 From 567491a5713844d26ab87c68901b8b1aa3fa2636 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 22 Jul 2023 22:01:36 -0300 Subject: towerofbssd config --- device/towerofbssd_post | 2 ++ device/towerofbssd_pre | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100755 device/towerofbssd_post create mode 100755 device/towerofbssd_pre diff --git a/device/towerofbssd_post b/device/towerofbssd_post new file mode 100755 index 0000000..5ccaf2c --- /dev/null +++ b/device/towerofbssd_post @@ -0,0 +1,2 @@ +# Tower of BSSD (post) +# See towerofbssd_pre for info. diff --git a/device/towerofbssd_pre b/device/towerofbssd_pre new file mode 100755 index 0000000..4b114cf --- /dev/null +++ b/device/towerofbssd_pre @@ -0,0 +1,15 @@ +# Tower of BSSD (pre) +# towerofbssd.local +# +# This is a Mac Pro 3,1 (Early 2008). +# Acquired in 2022. +# +# It's primarily used as a LAN-attached-storage device, +# but also has a host of ports that make it convenient for +# audio shenanigans between devices (e.g. recording output +# of consoles, being an Airplay satellite, and so on). + +export DEVICE_HAS_GPG + +export DEVICE_HAS_HOMEBREW +export DEVICE_HOMEBREW_INSTALLATION=/usr/local/Homebrew -- cgit 1.3.0-6-gf8a5