Update dotfiles/.local/share/chezmoi/home/.chezmoiexternal.toml, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_80-bash-completions, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_15_install-asdf-packages.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/ubuntu/run_onchange_before_10_install-ubuntu-dependencies.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/darwin/run_onchange_before_10_install-darwin-packages.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/darwin/run_onchange_after_20-ensure-zsh-macos.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/darwin/run_onchange_after_10_configure-macos.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/archlinux/run_onchange_before_10_install-archlinux-dependencies.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_10_install-aqua-packages.sh.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoiscripts/universal/run_onchange_after_99_bootstrap-z4h.tmpl, dotfiles/.local/share/chezmoi/home/.chezmoitemplates/universal/logg

Deleted dotfiles/.local/share/chezmoi/home/run_onchange_after_bash-completions, dotfiles/.local/share/chezmoi/home/run_once_before_install-software.sh.tmpl
This commit is contained in:
Brian Zalewski 2022-11-24 14:18:43 +00:00
parent c713c632f1
commit 7c9b53f1f6
12 changed files with 411 additions and 36 deletions

View file

@ -1,5 +1,5 @@
### VIM
{{- $refreshPeriod := "140h" }}
{{- $refreshPeriod := "240h" }}
{{- $vimPlugins := .softwarePlugins.vim.plugins }}
{{- range $vimPlugin := $vimPlugins }}
{{- $folderName := trimSuffix ".git" (last (splitList "/" $vimPlugin)) }}
@ -7,24 +7,24 @@
type = "git-repo"
url = "{{ $vimPlugin }}"
refreshPeriod = "{{ $refreshPeriod }}"
[".vim/plugged/{{ $folderName }}".pull]
args = ["--ff-only"]
clone.args = ["--depth", "1"]
pull.args = ["--ff-only"]
{{- end }}
### Betelgeuse Theme
[".local/share/betelgeuse"]
[".local/src/betelgeuse"]
type = "git-repo"
url = "https://gitlab.com/megabyte-labs/misc/betelgeuse.git"
clone.args = ["--depth", "1"]
pull.args = ["--ff-only"]
### Shell
[".config/desktop/gnome.yml"]
type = "file"
url = "https://gitlab.com/megabyte-labs/gas-station/-/raw/master/environments/prod/group_vars/all/defaults.yml"
refreshPeriod = "{{ $refreshPeriod }}"
[".config/desktop/settings.yml"]
type = "file"
url = "https://gitlab.com/megabyte-labs/gas-station/-/raw/master/roles/system/theme/vars/main.yml"
refreshPeriod = "{{ $refreshPeriod }}"
[".config/helm/config.yml"]
type = "file"
url = "https://gitlab.com/megabyte-labs/gas-station/-/raw/master/environments/prod/group_vars/all/helm.yml"
@ -74,22 +74,21 @@
refreshPeriod = "{{ $refreshPeriod }}"
### Taskfiles
[".local/shared-common"]
type = "archive"
url = "https://gitlab.com/megabyte-labs/common/shared/-/archive/master/shared-master.tar.gz"
exact = true
stripComponents = 3
[".local/src/shared-common"]
type = "git-repo"
url = "https://gitlab.com/megabyte-labs/common/shared.git"
refreshPeriod = "{{ $refreshPeriod }}"
include = ["taskfiles/**"]
clone.args = ["--depth", "1"]
pull.args = ["--ff-only"]
{{- if and (not .host.headless) (ne .chezmoi.os "windows") }}
### Neovim
[".config/nvim"]
type = "git-repo"
url = "https://github.com/AstroNvim/AstroNvim.git"
url = "https://github.com/NvChad/NvChad.git"
refreshPeriod = "{{ $refreshPeriod }}"
[".config/nvim".pull]
args = ["--ff-only"]
clone.args = ["--depth", "1"]
pull.args = ["--ff-only"]
{{- end }}
{{- if and (eq .chezmoi.os "linux") (not .host.headless) }}

View file

@ -1,6 +1,8 @@
{{- if eq .host.distro.id "arch" }}
#!/usr/bin/env bash
{{- includeTemplate "universal/logg" }}
{{- $packages := splitList " " (includeTemplate "universal/essential-packages" .) }}
{{- $pyenvDependencies := list
"base-devel"
@ -13,13 +15,18 @@
{{- $packages = concat $packages $pyenvDependencies -}}
{{- end }}
logg 'Installing common dependencies using pacman'
logg "Dependencies: {{ $packages | sortAlpha | uniq | join " " -}}"
### Install base dependencies
sudo packan -Sy --noconfirm --needed {{ $packages | sortAlpha | uniq | join " " -}}
### Install yay
if ! command -v yay > /dev/null; then
logg 'Cloning yay from `https://aur.archlinux.org/yay.git` to `/usr/local/src/yay`'
git clone https://aur.archlinux.org/yay.git /usr/local/src/yay
cd /usr/local/src/yay
logg 'Installing yay'
makepkg -si
fi
{{- end -}}

View file

@ -3,6 +3,10 @@
set -x
{{- includeTemplate "universal/logg" }}
logg 'Applying optimized macOS-specific settings'
# Close any open System Preferences panes, to prevent them from overriding
# settings were about to change
osascript -e 'tell application "System Preferences" to quit'

View file

@ -3,6 +3,10 @@
set -eufo pipefail
{{- includeTemplate "universal/logg" }}
logg 'Ensuring ZSH is set as the default shell'
{{- if (not .host.restricted) }}
if ! grep -qc "/usr/local/bin/zsh" /etc/shells; then
echo "/usr/local/bin/zsh" | sudo tee -a /etc/shells > /dev/null

View file

@ -1,10 +1,13 @@
{{- if eq .host.distro.id "darwin" }}
#!/usr/bin/env bash
{{- includeTemplate "universal/logg" }}
logg 'Ensuring `xcode-select` is installed'
xcode-select -p >/dev/null 2>&1 || xcode-select --install
if ! command -v brew >/dev/null 2>&1; then
echo "Installing Homebrew..."
logg 'Installing Homebrew'
/bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi

View file

@ -1,6 +1,8 @@
{{- if eq .host.distro.id "ubuntu" }}
#!/usr/bin/env bash
{{- includeTemplate "universal/logg" }}
{{- $packages := splitList " " (includeTemplate "universal/essential-packages" .) -}}
{{- $pyenvDependencies := list
"make"
@ -25,6 +27,10 @@
{{- $packages = concat $packages $pyenvDependencies -}}
{{- end }}
source "$HOME/.config/shell/exports"
logg 'Installing common dependencies using apt-get'
logg "Dependencies: {{ $packages | sortAlpha | uniq | join " " -}}"
sudo apt-get update
sudo apt-get install -y --no-install-recommends {{ $packages | sortAlpha | uniq | join " " -}}

View file

@ -2,6 +2,8 @@
#!/usr/bin/env bash
set -eufo pipefail
{{- includeTemplate "universal/logg" }}
source "$HOME/.config/shell/exports"
{{- $files := list -}}

View file

@ -1,20 +1,17 @@
{{- if or (eq .host.distro.id "darwin") (eq .host.distro.family "linux") }}
#!/usr/bin/env bash
source $HOME/.config/shell/exports.sh
{{- includeTemplate "universal/logg" }}
# dot_tool-versions.tmpl hash: {{ include "dot_tool-versions.tmpl" | sha256sum }}
[ ! -d $ASDF_DIR ] && git clone https://github.com/asdf-vm/asdf.git "${ASDF_DIR}"
. ${ASDF_DIR}/asdf.sh
source "$HOME/.config/shell/exports"
{{- if or .toolchains.java }}
asdf plugin-add java
asdf plugin-add maven
{{- end }}
{{- if or .toolchains.node }}
asdf plugin-add nodejs
{{- end }}
{{- if or .toolchains.python }}
asdf plugin-add python
{{- end }}
asdf install || true
if [ -f "$ASDF_DIR/asdf.sh" ] && [ -f ~/.tool-versions ]; then
logg 'Installing ASDF dependencies derived from `~/.tool-versions`'
. ${ASDF_DIR}/asdf.sh
asdf install || true
else
logg 'The `$ASDF_DIR/asdf.sh` or `~/.tool-versions` file is not present'
fi
{{- end -}}

View file

@ -1,8 +1,13 @@
{{- if or (eq .host.distro.id "darwin") (eq .host.distro.family "linux") }}
#!/usr/bin/env bash
# {{ output "sha256sum" (joinPath .chezmoi.sourceDir ".chezmoidata.yaml") }}
echo "Run onchange after bash completions hook"
{{- includeTemplate "universal/logg" }}
source "$HOME/.config/shell/exports"
logg 'Updating the `~/.local/share/bash-completion/completions` folder based on the installed applications'
### Initialize
COMPLETION_DIR="$HOME/.local/share/bash-completion/completions"
@ -164,3 +169,4 @@ if command -v zoxide >/dev/null; then
elif [ -f "$COMPLETION_DIR/zoxide.bash" ]; then
rm "$COMPLETION_DIR/zoxide.bash"
fi
{{- end -}}

View file

@ -1,5 +1,7 @@
{{- if and false .host.headless -}}
#!/usr/bin/env bash
{{- includeTemplate "universal/logg" }}
Z4H_BOOTSTRAPPING=1 exec zsh && exit 0
{{- end -}}

View file

@ -0,0 +1,350 @@
# @description Installs glow (a markdown renderer) from GitHub releases
# @example installGlow
installGlow() {
# TODO: Add support for other architecture types
if [ -d '/Applications' ] && [ -d '/Library' ] && [ -d '/Users' ]; then
GLOW_DOWNLOAD_URL="https://github.com/charmbracelet/glow/releases/download/v1.4.1/glow_1.4.1_Darwin_x86_64.tar.gz"
elif [ -f '/etc/ubuntu-release' ] || [ -f '/etc/debian_version' ] || [ -f '/etc/redhat-release' ] || [ -f '/etc/SuSE-release' ] || [ -f '/etc/arch-release' ] || [ -f '/etc/alpine-release' ]; then
GLOW_DOWNLOAD_URL="https://github.com/charmbracelet/glow/releases/download/v1.4.1/glow_1.4.1_linux_x86_64.tar.gz"
fi
if type curl &> /dev/null; then
if { [ -d '/Applications' ] && [ -d '/Library' ] && [ -d '/Users' ]; } || [ -f '/etc/ubuntu-release' ] || [ -f '/etc/debian_version' ] || [ -f '/etc/redhat-release' ] || [ -f '/etc/SuSE-release' ] || [ -f '/etc/arch-release' ] || [ -f '/etc/alpine-release' ]; then
TMP="$(mktemp)"
TMP_DIR="$(dirname "$TMP")"
curl -sSL "$GLOW_DOWNLOAD_URL" > "$TMP"
tar -xzf "$TMP" -C "$TMP_DIR"
if [ -n "$HOME" ]; then
if mkdir -p "$HOME/.local/bin" && mv "$TMP_DIR/glow" "$HOME/.local/bin/glow"; then
GLOW_PATH="$HOME/.local/bin/glow"
else
GLOW_PATH="$(dirname "${BASH_SOURCE[0]}")/glow"
mv "$TMP_DIR/gum" "$GLOW_PATH"
fi
chmod +x "$GLOW_PATH"
else
echo "WARNING: The HOME environment variable is not set! (Glow)"
fi
else
echo "WARNING: Unable to detect system type. (Glow)"
fi
fi
}
# @description Installs gum (a logging CLI) from GitHub releases
# @example installGum
installGum() {
# TODO: Add support for other architecture types
if [ -d '/Applications' ] && [ -d '/Library' ] && [ -d '/Users' ]; then
GUM_DOWNLOAD_URL="https://github.com/charmbracelet/gum/releases/download/v0.4.0/gum_0.4.0_Darwin_x86_64.tar.gz"
elif [ -f '/etc/ubuntu-release' ] || [ -f '/etc/debian_version' ] || [ -f '/etc/redhat-release' ] || [ -f '/etc/SuSE-release' ] || [ -f '/etc/arch-release' ] || [ -f '/etc/alpine-release' ]; then
GUM_DOWNLOAD_URL="https://github.com/charmbracelet/gum/releases/download/v0.4.0/gum_0.4.0_linux_x86_64.tar.gz"
fi
if type curl &> /dev/null; then
if { [ -d '/Applications' ] && [ -d '/Library' ] && [ -d '/Users' ]; } || [ -f '/etc/ubuntu-release' ] || [ -f '/etc/debian_version' ] || [ -f '/etc/redhat-release' ] || [ -f '/etc/SuSE-release' ] || [ -f '/etc/arch-release' ] || [ -f '/etc/alpine-release' ]; then
TMP="$(mktemp)"
TMP_DIR="$(dirname "$TMP")"
curl -sSL "$GUM_DOWNLOAD_URL" > "$TMP"
tar -xzf "$TMP" -C "$TMP_DIR"
if [ -n "$HOME" ]; then
if mkdir -p "$HOME/.local/bin" && mv "$TMP_DIR/gum" "$HOME/.local/bin/gum"; then
GUM_PATH="$HOME/.local/bin/gum"
else
GUM_PATH="$(dirname "${BASH_SOURCE[0]}")/gum"
mv "$TMP_DIR/gum" "$GLOW_PATH"
fi
chmod +x "$GUM_PATH"
else
echo "WARNING: The HOME environment variable is not set! (Gum)"
fi
else
echo "WARNING: Unable to detect system type. (Gum)"
fi
fi
}
# @description Configure the logger to use echo or gum
if [ "${container:=}" != 'docker' ]; then
# Acquire gum's path or attempt to install it
if type gum &> /dev/null; then
GUM_PATH="$(which gum)"
elif [ -f "$HOME/.local/bin/gum" ]; then
GUM_PATH="$HOME/.local/bin/gum"
elif [ -f "$(dirname "${BASH_SOURCE[0]}")/gum" ]; then
GUM_PATH="$(dirname "${BASH_SOURCE[0]}")/gum"
elif type brew &> /dev/null; then
brew install gum
GUM_PATH="$(which gum)"
else
installGum
fi
# If gum's path was set, then turn on enhanced logging
if [ -n "$GUM_PATH" ]; then
chmod +x "$GUM_PATH"
ENHANCED_LOGGING=true
fi
fi
# @description Disable logging for Semantic Release because it tries to parse it as JSON
if [ -n "$SEMANTIC_RELEASE" ]; then
NO_LOGGING=true
fi
# @description Logs using Node.js
# @example logger info "An informative log"
logger() {
if [ "$1" == 'error' ]; then
"$GUM_PATH" style --border="thick" "$("$GUM_PATH" style --foreground="#ff0000" "✖") $("$GUM_PATH" style --bold --background="#ff0000" --foreground="#ffffff" " ERROR ") $("$GUM_PATH" style --bold "$(format "$2")")"
elif [ "$1" == 'info' ]; then
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#00ffff" "○") $2"
elif [ "$1" == 'md' ]; then
# @description Ensure glow is installed
if [ "${container:=}" != 'docker' ]; then
if type glow &> /dev/null; then
GLOW_PATH="$(which glow)"
elif [ -f "$HOME/.local/bin/glow" ]; then
GLOW_PATH="$HOME/.local/bin/glow"
elif [ -f "$(dirname "${BASH_SOURCE[0]}")/glow" ]; then
GLOW_PATH="$(dirname "${BASH_SOURCE[0]}")/glow"
elif type brew &> /dev/null; then
brew install glow
GLOW_PATH="$(which glow)"
else
installGlow
fi
if [ -n "$GLOW_PATH" ]; then
chmod +x "$GLOW_PATH"
ENHANCED_LOGGING=true
fi
fi
"$GLOW_PATH" "$2"
elif [ "$1" == 'prompt' ]; then
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#00008b" "▶") $("$GUM_PATH" style --bold "$(format "$2")")"
elif [ "$1" == 'star' ]; then
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#d1d100" "◆") $("$GUM_PATH" style --bold --underline "$(format "$2")")"
elif [ "$1" == 'start' ]; then
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#00ff00" "▶") $("$GUM_PATH" style --bold "$(format "$2")")"
elif [ "$1" == 'success' ]; then
"$GUM_PATH" style "$("$GUM_PATH" style --foreground="#00ff00" "✔") $("$GUM_PATH" style --bold "$(format "$2")")"
elif [ "$1" == 'warn' ]; then
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#d1d100" "◆") $("$GUM_PATH" style --bold --background="#ffff00" --foreground="#000000" " WARNING ") $("$GUM_PATH" style --bold --italic "$(format "$2")")"
else
echo "WARNING: Unknown log type"
echo "$2"
fi
}
format() {
# shellcheck disable=SC2001,SC2016
ANSI_STR="$(echo "$1" | sed 's/^\([^`]*\)`\([^`]*\)`/\1\\u001b[47;1;30m \2 \\e[0;39m/')"
if [[ $ANSI_STR == *'`'*'`'* ]]; then
ANSI_STR="$(format "$ANSI_STR")"
fi
echo -e "$ANSI_STR"
}
# @description Display prompt that allows you to choose between options
# @example RESPONSE="$(.config/log choose "file.png" "another-file.jpg")"
choose() {
if type gum &> /dev/null; then
CHOOSE_ARGS="gum choose"
for CURRENT_VAR in "$@"; do
CHOOSE_ARGS="$CHOOSE_ARGS \"$CURRENT_VAR\""
done
eval $CHOOSE_ARGS
else
echo "ERROR: gum is not installed!"
fi
}
# @description Display a confirmation prompt that returns an exit code if "No" is selected
# @example RESPONSE="$(.config/log confirm "Are you sure?" "Yeah" "Naa")"
confirm() {
if type gum &> /dev/null; then
GUM_OPTS=""
if [ -n "$2" ]; then
# shellcheck disable=SC089
GUM_OPTS="$GUM_OPTS --affirmative=""'$2'"
fi
if [ -n "$3" ]; then
GUM_OPTS="$GUM_OPTS --negative=""'$3'"
fi
if [ -n "$1" ]; then
if [ -n "$GUM_OPTS" ]; then
gum confirm "$1" "$GUM_OPTS"
else
gum confirm "$1"
fi
else
gum confirm
fi
else
echo "ERROR: gum is not installed!"
fi
}
# @description Logs an error message
# @example .config/log error "Something happened!"
error() {
if [ -z "$NO_LOGGING" ]; then
if [ -n "$ENHANCED_LOGGING" ]; then
logger error "$1"
else
echo -e "\e[1;41m ERROR \e[0m $(format "$1")\e[0;39m"
fi
fi
}
# @description Display a filterable prompt that is populated with options from a text file
# @example echo Strawberry >> flavors.text && echo Banana >> flavors.text && RESPONSE="$(.config/log filter flavors.txt)"
filter() {
if type gum &> /dev/null; then
TMP="$(mktemp)"
gum filter < "$1"
else
echo "ERROR: gum is not installed!"
fi
}
# @description Logs an info message
# @example .config/log info "Here is some information"
info() {
if [ -z "$NO_LOGGING" ]; then
if [ -n "$ENHANCED_LOGGING" ]; then
logger info "$1"
else
echo -e "\e[1;46m INFO \e[0m $(format "$1")\e[0;39m"
fi
fi
}
# @description Displays an input with masked characters
# @example INPUT="$(.config/log input 'Enter the value..')"
input() {
if type gum &> /dev/null; then
if [ -n "$1" ]; then
gum input --placeholder="$1"
else
gum input
fi
else
echo "ERROR: gum is not installed!"
fi
}
# @description Logs a message written in markdown
# @example .config/log md "[styled_link](https://google.com)"
# @example .config/log md mymarkdown/file.md
md() {
if [ ! -f "$1" ]; then
echo "ERROR: A markdown file must be passed in as the parameter" && exit 1
fi
if [ -n "$ENHANCED_LOGGING" ]; then
logger md "$1"
fi
}
# @description Displays an input with masked characters
# @example PASSWORD="$(.config/log password 'Enter the Ansible vault password')"
password() {
if type gum &> /dev/null; then
if [ -n "$1" ]; then
gum input --password --placeholder="$1"
else
gum input --password
fi
else
echo "ERROR: gum is not installed!"
fi
}
# @description Logs a message that describes a prompt
# @example .config/log prompt "Enter text into the following prompt"
prompt() {
if [ -z "$NO_LOGGING" ]; then
if [ -n "$ENHANCED_LOGGING" ]; then
logger prompt "$1"
else
echo -e "\e[1;104m PROMPT \e[0m $(format "$1")\e[0;39m"
fi
fi
}
# @description Display a spinner that stays until a command is completed
# @example .config/log spin "brew install yq" "Installing yq..")"
spin() {
if type gum &> /dev/null; then
if [ -n "$1" ] && [ -n "$2" ]; then
gum spin --title="$2" "$1"
elif [ -n "$1" ]; then
gum spin "$1"
else
gum input
fi
else
echo "ERROR: gum is not installed!"
fi
}
# @description Logs a message that starts with a star emoji
# @example .config/log star "Congratulations"
star() {
if [ -z "$NO_LOGGING" ]; then
if [ -n "$ENHANCED_LOGGING" ]; then
logger star "$1"
else
echo -e "\e[1;104m LINK \e[0m $(format "$1")\e[0;39m"
fi
fi
}
# @description Logs a message at the beginning of a task
# @example .config/log start "Starting the process.."
start() {
if [ -z "$NO_LOGGING" ]; then
if [ -n "$ENHANCED_LOGGING" ]; then
logger start "$1"
else
echo -e "\e[1;46m START \e[0m $(format "$1")\e[0;39m"
fi
fi
}
# @description Logs a success message
# @example .config/log success "Yay!"
success() {
if [ -z "$NO_LOGGING" ]; then
if [ -n "$ENHANCED_LOGGING" ]; then
logger success "$1"
else
echo -e "\e[1;42m SUCCESS \e[0m $(format "$1")\e[0;39m"
fi
fi
}
# @description Logs a warning message
# @example .config/log warn "Just so you know.."
warn() {
if [ -z "$NO_LOGGING" ]; then
if [ -n "$ENHANCED_LOGGING" ]; then
logger warn "$1"
else
echo -e "\e[1;43m WARNING \e[0m $(format "$1")\e[0;39m"
fi
fi
}
# @description Displays a multi-line prompt for text input
# @example .config/log write "Write something..")"
write() {
if type gum &> /dev/null; then
if [ -n "$1" ]; then
gum write --placeholder="$1"
else
gum write
fi
else
echo "ERROR: gum is not installed!"
fi
}

View file

@ -1,5 +0,0 @@
{{- if eq .chezmoi.os "darwin" -}}
#!/bin/bash
echo "Run once before install software hook"
{{ end -}}