Update 28 files

- /home/.chezmoiscripts/universal/run_onchange_before_91-configure-gpg.tmpl
- /home/.chezmoiscripts/universal/run_before_01-decrypt-age-key.tmpl
- /home/.chezmoiscripts/ubuntu/run_onchange_before_10-install-ubuntu-dependencies.tmpl
- /home/.chezmoiscripts/qubes/run_onchange_before_12-update-dom0.tmpl
- /home/.chezmoiscripts/opensuse/run_onchange_before_11-install-opensuse-software.tmpl
- /home/.chezmoiscripts/linux/run_onchange_before_10-system-tweaks.tmpl
- /home/.chezmoiscripts/linux/run_onchange_before_11-configure-swap.tmpl
- /home/.chezmoiscripts/freebsd/run_onchange_before_11-install-freebsd-packages.tmpl
- /home/.chezmoiscripts/fedora/run_onchange_before_10-install-fedora-dependencies.tmpl
- /home/.chezmoiscripts/debian/run_onchange_before_10-install-debian-dependencies.tmpl
- /home/.chezmoiscripts/darwin/run_onchange_before_10-install-darwin-dependencies.tmpl
- /home/.chezmoiscripts/darwin/run_onchange_before_20-ensure-user-group.tmpl
- /home/.chezmoiscripts/centos/run_onchange_before_10-install-centos-dependencies.tmpl
- /home/.chezmoiscripts/archlinux/run_onchange_before_10-install-archlinux-dependencies.tmpl
- /home/.chezmoiscripts/_universal/run_onchange_before_08-install-zx.tmpl
- /home/.chezmoiscripts/_universal/run_onchange_before_09-ensure-node-version.tmpl
- /home/.chezmoiscripts/_universal/run_onchange_before_10-remove-bloatware.tmpl
- /home/.chezmoiscripts/_universal/run_onchange_before_11-install-docker.tmpl
- /home/.chezmoiscripts/_universal/run_onchange_before_05-install-homebrew.tmpl
- /home/.chezmoiscripts/_universal/run_before_01-add-temporary-includes.tmpl
- /home/.chezmoitemplates/universal/logg
- /home/.chezmoitemplates/universal/profile
- /home/.chezmoitemplates/universal/profile-before
- /home/.chezmoitemplates/universal/logg-before
- /home/.chezmoitemplates/universal/logg-compat
- /home/.chezmoitemplates/universal/logg-inline
- /home/.chezmoitemplates/universal/profile-inline
- /home/.chezmoidata.yaml
This commit is contained in:
Brian Zalewski 2023-01-25 04:31:32 +00:00
parent 108d61a779
commit 6c95c870b0
28 changed files with 263 additions and 223 deletions

View file

@ -977,6 +977,19 @@ softwarePlugins:
- https://github.com/tpope/vim-surround.git
- https://github.com/nanotee/zoxide.vim.git
qubes:
dom0Packages:
- latte-dock
- nautilus
- nautilus-gtkhash
- nautilus-search-tool
- kde-settings-qubes
- kdeplasma-addons
- konsole
- kscreen
- kvantum
- plymouth-kcm
- sssd-kcm
- sddm-kcm
mirageUrl: https://github.com/mirage/qubes-mirage-firewall/releases/latest/download/mirage-firewall.tar.bz2
promptKeyboards: false
provisionVM: provision

View file

@ -0,0 +1,20 @@
{{- if (ne .host.distro.family "windows") -}}
### Add pre-scaffolding profile to /tmp/tmp-profile so it's easier to navigate through scripts
cat << EOF > /tmp/tmp-profile
#!/usr/bin/env bash
{{ includeTemplate "universal/profile-inline" }}
EOF
### Make /tmp/tmp-profile owned by root to prevent tampering
sudo chown root /tmp/tmp-profile
### Add pre-scaffolding /tmp/tmp-logg
cat << EOF > /tmp/tmp-logg
#!/usr/bin/env bash
{{ includeTemplate "universal/logg-inline" }}
EOF
### Make /tmp/tmp-logg owned by root to prevent tampering
sudo chown root /tmp/tmp-logg
{{ end -}}

View file

@ -1,9 +1,8 @@
{{- if (ne .host.distro.family "windows") -}}
#!/usr/bin/env bash
{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}
{{ includeTemplate "universal/profile-bundle" }}
{{ includeTemplate "universal/logg-bundle" }}
### Install Xcode CLI tools on macOS
if [ -d /Applications ] && [ -d /Library ]; then

View file

@ -1,8 +1,8 @@
{{- if (ne .host.distro.family "windows") -}}
#!/usr/bin/env bash
{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}
{{ includeTemplate "universal/profile-bundle" }}
{{ includeTemplate "universal/logg-bundle" }}
### Ensure node is installed
if ! command -v node > /dev/null; then

View file

@ -3,8 +3,8 @@
# Node.js version: {{ output "node" "--version" }}
{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}
{{ includeTemplate "universal/profile-bundle" }}
{{ includeTemplate "universal/logg-bundle" }}
### Ensure recent version of Node.js is being used
if command -v volta > /dev/null; then

View file

@ -1,8 +1,8 @@
{{- if eq .host.distro.family "linux" -}}
#!/usr/bin/env bash
{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}
{{ includeTemplate "universal/profile-bundle" }}
{{ includeTemplate "universal/logg-bundle" }}
{{- $removePackages := join " " .removeLinuxPackages }}

View file

@ -1,8 +1,8 @@
{{- if ne .host.distro.family "windows" -}}
#!/usr/bin/env bash
{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}
{{ includeTemplate "universal/profile-bundle" }}
{{ includeTemplate "universal/logg-bundle" }}
### Install Docker
if [ -d /Applications ] && [ -d /System ]; then

View file

@ -3,7 +3,7 @@
# universal/common-dependencies hash: {{ include (joinPath ".chezmoitemplates" "universal" "common-dependencies") | sha256sum }}
# archlinux/common-dependencies hash: {{ include (joinPath ".chezmoitemplates" "archlinux" "common-dependencies") | sha256sum }}
{{ includeTemplate "universal/logg" }}
{{ includeTemplate "universal/logg-bundle" }}
{{- $packages := splitList " " (includeTemplate "universal/common-dependencies" .) -}}
{{- $additionalPackages := splitList " " (includeTemplate "archlinux/common-dependencies" .) -}}

View file

@ -3,7 +3,7 @@
# universal/common-dependencies hash: {{ include (joinPath ".chezmoitemplates" "universal" "common-dependencies") | sha256sum }}
# centos/common-dependencies hash: {{ include (joinPath ".chezmoitemplates" "centos" "common-dependencies") | sha256sum }}
{{ includeTemplate "universal/logg" }}
{{ includeTemplate "universal/logg-bundle" }}
{{- $packages := splitList " " (includeTemplate "universal/common-dependencies" .) -}}
{{- $additionalPackages := splitList " " (includeTemplate "centos/common-dependencies" .) -}}

View file

@ -2,8 +2,8 @@
# darwin/Brewfile hash: {{ include (joinPath ".chezmoitemplates" "darwin" "Brewfile") | sha256sum }}
{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}
{{ includeTemplate "universal/profile-bundle" }}
{{ includeTemplate "universal/logg-bundle" }}
if command -v brew > /dev/null; then
logg 'Installing base dependencies for macOS using `brew bundle`'

View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash
{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}
{{ includeTemplate "universal/profile-bundle" }}
{{ includeTemplate "universal/logg-bundle" }}
### Ensure user has group of same name (required for Macports)
logg info 'Ensuring user has a group with the same name and that it is a member. Sudo privileges may be required'

View file

@ -3,7 +3,7 @@
# universal/common-dependencies hash: {{ include (joinPath ".chezmoitemplates" "universal" "common-dependencies") | sha256sum }}
# debian/common-dependencies hash: {{ include (joinPath ".chezmoitemplates" "debian" "common-dependencies") | sha256sum }}
{{ includeTemplate "universal/logg" }}
{{ includeTemplate "universal/logg-bundle" }}
{{- $packages := splitList " " (includeTemplate "universal/common-dependencies" .) -}}
{{- $additionalPackages := splitList " " (includeTemplate "debian/common-dependencies" .) -}}

View file

@ -3,7 +3,7 @@
# universal/common-dependencies hash: {{ include (joinPath ".chezmoitemplates" "universal" "common-dependencies") | sha256sum }}
# fedora/common-dependencies hash: {{ include (joinPath ".chezmoitemplates" "fedora" "common-dependencies") | sha256sum }}
{{ includeTemplate "universal/logg" }}
{{ includeTemplate "universal/logg-bundle" }}
{{- $packages := splitList " " (includeTemplate "universal/common-dependencies" .) -}}
{{- $additionalPackages := splitList " " (includeTemplate "fedora/common-dependencies" .) -}}

View file

@ -3,7 +3,7 @@
# universal/common-dependencies hash: {{ include (joinPath ".chezmoitemplates" "universal" "common-dependencies") | sha256sum }}
# freebsd/common-dependencies hash: {{ include (joinPath ".chezmoitemplates" "freebsd" "common-dependencies") | sha256sum }}
{{ includeTemplate "universal/logg" }}
{{ includeTemplate "universal/logg-bundle" }}
{{- $packages := splitList " " (includeTemplate "universal/common-dependencies" .) -}}
{{- $additionalPackages := splitList " " (includeTemplate "freebsd/common-dependencies" .) -}}

View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash
{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}
{{ includeTemplate "universal/profile-bundle" }}
{{ includeTemplate "universal/logg-bundle" }}
### Set hostname (if redefined)
if command -v hostnamectl > /dev/null; then

View file

@ -1,8 +1,8 @@
#!/usr/bin/env bash
# TODO - make equivalent to https://gitlab.com/megabyte-labs/gas-station/-/blob/master/roles/system/common/tasks/linux/swap.yml
{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}
{{ includeTemplate "universal/profile-bundle" }}
{{ includeTemplate "universal/logg-bundle" }}
if [ ! -f /swapfile ]; then
MEMORY_IN_KB="$(grep MemTotal /proc/meminfo | sed 's/.* \(.*\) kB/\1/')"

View file

@ -3,7 +3,7 @@
# universal/common-dependencies hash: {{ include (joinPath ".chezmoitemplates" "universal" "common-dependencies") | sha256sum }}
# opensuse/common-dependencies hash: {{ include (joinPath ".chezmoitemplates" "opensuse" "common-dependencies") | sha256sum }}
{{ includeTemplate "universal/logg" }}
{{ includeTemplate "universal/logg-bundle" }}
{{- $packages := splitList " " (includeTemplate "universal/common-dependencies" .) -}}
{{- $additionalPackages := splitList " " (includeTemplate "opensuse/common-dependencies" .) -}}

View file

@ -11,7 +11,7 @@ logg info "Installing qubes-repo-contrib"
sudo qubes-dom0-update -y qubes-repo-contrib
### Install dependencies
for PACKAGE of latte-dock nautilus nautilus-gtkhash nautilus-search-tool kde-settings-qubes kdeplasma-addons konsole kscreen kvantum plymouth-kcm sssd-kcm sddm-kcm; do
for PACKAGE of {{ .qubes.dom0Packages | toString | replace "[" "" | replace "]" "" }}; do
logg info "Installing $PACKAGE"
sudo qubes-dom0-update -y "$PACKAGE" || true
done

View file

@ -3,7 +3,7 @@
# universal/common-dependencies hash: {{ include (joinPath ".chezmoitemplates" "universal" "common-dependencies") | sha256sum }}
# ubuntu/common-dependencies hash: {{ include (joinPath ".chezmoitemplates" "ubuntu" "common-dependencies") | sha256sum }}
{{ includeTemplate "universal/logg" }}
{{ includeTemplate "universal/logg-bundle" }}
{{- $packages := splitList " " (includeTemplate "universal/common-dependencies" .) -}}
{{- $additionalPackages := splitList " " (includeTemplate "ubuntu/common-dependencies" .) -}}

View file

@ -1,8 +1,7 @@
#!/usr/bin/env bash
{{ includeTemplate "universal/logg" }}
XDG_CONFIG_HOME="$HOME/.config"
{{ includeTemplate "universal/logg-bundle" }}
{{ includeTemplate "universal/profile-bundle" }}
### Decrypt private key if it is not already present
if [ ! -f "${XDG_CONFIG_HOME}/age/chezmoi.txt" ]; then

View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash
{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}
{{ includeTemplate "universal/profile-bundle" }}
{{ includeTemplate "universal/logg-bundle" }}
KEYID="{{ .user.gpg.id }}"

View file

@ -1,166 +1 @@
# @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
if ! command -v qubesctl > /dev/null; then
# Qubes dom0
installGum
fi
fi
# If gum's path was set, then turn on enhanced logging
if [ -n "$GUM_PATH" ]; then
chmod +x "$GUM_PATH"
fi
fi
format() {
# shellcheck disable=SC2001,SC2016
ANSI_STR_FORMATTED="$(echo "$1" | sed 's/^\([^`]*\)`\([^`]*\)`.*/\1\\u001b[47;30m \2 \\e[49;m/')"
# shellcheck disable=SC2001,SC2016
ANSI_STR="$(echo "$1" | sed 's/^\([^`]*\)`\([^`]*\)`\(.*\)$/\3/')"
if [ "$ANSI_STR_FORMATTED" != "$ANSI_STR" ]; then
if [[ $ANSI_STR == *'`'*'`'* ]]; then
ANSI_STR_FORMATTED="$ANSI_STR_FORMATTED$(format "$("$GUM_PATH" style --bold "$ANSI_STR")")"
else
ANSI_STR_FORMATTED="$ANSI_STR_FORMATTED$("$GUM_PATH" style --bold "$ANSI_STR")"
fi
fi
echo -e "$ANSI_STR_FORMATTED"
}
formatFaint() {
# shellcheck disable=SC2001,SC2016
ANSI_STR_FORMATTED="$(echo "$1" | sed 's/^\([^`]*\)`\([^`]*\)`.*/\1\\u001b[47;30m \2 \\e[49;m/')"
# shellcheck disable=SC2001,SC2016
ANSI_STR="$(echo "$1" | sed 's/^\([^`]*\)`\([^`]*\)`\(.*\)$/\3/')"
if [ "$ANSI_STR_FORMATTED" != "$ANSI_STR" ]; then
if [[ $ANSI_STR == *'`'*'`'* ]]; then
ANSI_STR_FORMATTED="$ANSI_STR_FORMATTED$(formatFaint "$("$GUM_PATH" style --faint "$ANSI_STR")")"
else
ANSI_STR_FORMATTED="$ANSI_STR_FORMATTED$("$GUM_PATH" style --faint "$ANSI_STR")"
fi
fi
echo -e "$ANSI_STR_FORMATTED"
}
# @description Logs using Node.js
# @example logger info "An informative log"
logg() {
TYPE="$1"
MSG="$2"
if [ "$TYPE" == '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 "$MSG")")"
elif [ "$TYPE" == 'info' ]; then
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#00ffff" "○") $("$GUM_PATH" style --faint "$(formatFaint "$MSG")")"
elif [ "$TYPE" == '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
if ! command -v qubesctl > /dev/null; then
# Qubes dom0
installGlow
fi
fi
if [ -n "$GLOW_PATH" ]; then
chmod +x "$GLOW_PATH"
fi
fi
"$GLOW_PATH" "$MSG"
elif [ "$TYPE" == 'prompt' ]; then
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#00008b" "▶") $("$GUM_PATH" style --bold "$(format "$MSG")")"
elif [ "$TYPE" == 'star' ]; then
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#d1d100" "◆") $("$GUM_PATH" style --bold "$(format "$MSG")")"
elif [ "$TYPE" == 'start' ]; then
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#00ff00" "▶") $("$GUM_PATH" style --bold "$(format "$MSG")")"
elif [ "$TYPE" == 'success' ]; then
"$GUM_PATH" style "$("$GUM_PATH" style --foreground="#00ff00" "✔") $("$GUM_PATH" style --bold "$(format "$MSG")")"
elif [ "$TYPE" == 'warn' ]; then
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#d1d100" "◆") $("$GUM_PATH" style --bold --background="#ffff00" --foreground="#000000" " WARNING ") $("$GUM_PATH" style --bold "$(format "$MSG")")"
else
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#00ff00" "▶") $("$GUM_PATH" style --bold "$(format "$TYPE")")"
fi
}
PATH="$HOME/.local/bin:$PATH"

View file

@ -0,0 +1 @@
. /tmp/tmp-logg

View file

@ -1,3 +1,3 @@
if command -v logg > /dev/null; then
alias logg='echo'
fi
fi

View file

@ -0,0 +1,166 @@
# @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
if ! command -v qubesctl > /dev/null; then
# Qubes dom0
installGum
fi
fi
# If gum's path was set, then turn on enhanced logging
if [ -n "$GUM_PATH" ]; then
chmod +x "$GUM_PATH"
fi
fi
format() {
# shellcheck disable=SC2001,SC2016
ANSI_STR_FORMATTED="$(echo "$1" | sed 's/^\([^`]*\)`\([^`]*\)`.*/\1\\u001b[47;30m \2 \\e[49;m/')"
# shellcheck disable=SC2001,SC2016
ANSI_STR="$(echo "$1" | sed 's/^\([^`]*\)`\([^`]*\)`\(.*\)$/\3/')"
if [ "$ANSI_STR_FORMATTED" != "$ANSI_STR" ]; then
if [[ $ANSI_STR == *'`'*'`'* ]]; then
ANSI_STR_FORMATTED="$ANSI_STR_FORMATTED$(format "$("$GUM_PATH" style --bold "$ANSI_STR")")"
else
ANSI_STR_FORMATTED="$ANSI_STR_FORMATTED$("$GUM_PATH" style --bold "$ANSI_STR")"
fi
fi
echo -e "$ANSI_STR_FORMATTED"
}
formatFaint() {
# shellcheck disable=SC2001,SC2016
ANSI_STR_FORMATTED="$(echo "$1" | sed 's/^\([^`]*\)`\([^`]*\)`.*/\1\\u001b[47;30m \2 \\e[49;m/')"
# shellcheck disable=SC2001,SC2016
ANSI_STR="$(echo "$1" | sed 's/^\([^`]*\)`\([^`]*\)`\(.*\)$/\3/')"
if [ "$ANSI_STR_FORMATTED" != "$ANSI_STR" ]; then
if [[ $ANSI_STR == *'`'*'`'* ]]; then
ANSI_STR_FORMATTED="$ANSI_STR_FORMATTED$(formatFaint "$("$GUM_PATH" style --faint "$ANSI_STR")")"
else
ANSI_STR_FORMATTED="$ANSI_STR_FORMATTED$("$GUM_PATH" style --faint "$ANSI_STR")"
fi
fi
echo -e "$ANSI_STR_FORMATTED"
}
# @description Logs using Node.js
# @example logger info "An informative log"
logg() {
TYPE="$1"
MSG="$2"
if [ "$TYPE" == '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 "$MSG")")"
elif [ "$TYPE" == 'info' ]; then
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#00ffff" "○") $("$GUM_PATH" style --faint "$(formatFaint "$MSG")")"
elif [ "$TYPE" == '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
if ! command -v qubesctl > /dev/null; then
# Qubes dom0
installGlow
fi
fi
if [ -n "$GLOW_PATH" ]; then
chmod +x "$GLOW_PATH"
fi
fi
"$GLOW_PATH" "$MSG"
elif [ "$TYPE" == 'prompt' ]; then
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#00008b" "▶") $("$GUM_PATH" style --bold "$(format "$MSG")")"
elif [ "$TYPE" == 'star' ]; then
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#d1d100" "◆") $("$GUM_PATH" style --bold "$(format "$MSG")")"
elif [ "$TYPE" == 'start' ]; then
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#00ff00" "▶") $("$GUM_PATH" style --bold "$(format "$MSG")")"
elif [ "$TYPE" == 'success' ]; then
"$GUM_PATH" style "$("$GUM_PATH" style --foreground="#00ff00" "✔") $("$GUM_PATH" style --bold "$(format "$MSG")")"
elif [ "$TYPE" == 'warn' ]; then
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#d1d100" "◆") $("$GUM_PATH" style --bold --background="#ffff00" --foreground="#000000" " WARNING ") $("$GUM_PATH" style --bold "$(format "$MSG")")"
else
"$GUM_PATH" style " $("$GUM_PATH" style --foreground="#00ff00" "▶") $("$GUM_PATH" style --bold "$(format "$TYPE")")"
fi
}

View file

@ -1,24 +1 @@
### Source .bashrc if it is present
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
elif [ -f "$HOME/.config/shell/exports.sh" ]; then
. "$HOME/.config/shell/exports.sh"
fi
### Ensure Homebrew PATHs
if [ -d /home/linuxbrew/.linuxbrew/bin ]; then
export HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew"
export HOMEBREW_CELLAR="/home/linuxbrew/.linuxbrew/Cellar"
export HOMEBREW_REPOSITORY="/home/linuxbrew/.linuxbrew/Homebrew"
export PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin${PATH+:$PATH}"
export MANPATH="/home/linuxbrew/.linuxbrew/share/man${MANPATH+:$MANPATH}:"
export INFOPATH="/home/linuxbrew/.linuxbrew/share/info:${INFOPATH:-}"
export WHALEBREW_INSTALL_PATH="/home/linuxbrew/.linuxbrew/whalebrew"
elif [ -f /opt/homebrew/bin/brew ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
elif [ -f /usr/local/bin/brew ]; then
eval "$(/usr/local/bin/brew shellenv)"
fi
### Ensure ~/.local/bin in PATH
export PATH="$HOME/.local/bin:$PATH"
. "$HOME/.bashrc"

View file

@ -0,0 +1 @@
. /tmp/tmp-profile

View file

@ -0,0 +1,29 @@
### Source .bashrc if it is present
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
elif [ -f "$HOME/.config/shell/exports.sh" ]; then
. "$HOME/.config/shell/exports.sh"
fi
### XDG
XDG_CONFIG_HOME="$HOME/.config"
XDG_CACHE_HOME="$HOME/.cache"
XDG_DATA_DIR="$HOME/.local/share"
### Ensure Homebrew PATHs
if [ -d /home/linuxbrew/.linuxbrew/bin ]; then
export HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew"
export HOMEBREW_CELLAR="/home/linuxbrew/.linuxbrew/Cellar"
export HOMEBREW_REPOSITORY="/home/linuxbrew/.linuxbrew/Homebrew"
export PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin${PATH+:$PATH}"
export MANPATH="/home/linuxbrew/.linuxbrew/share/man${MANPATH+:$MANPATH}:"
export INFOPATH="/home/linuxbrew/.linuxbrew/share/info:${INFOPATH:-}"
export WHALEBREW_INSTALL_PATH="/home/linuxbrew/.linuxbrew/whalebrew"
elif [ -f /opt/homebrew/bin/brew ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
elif [ -f /usr/local/bin/brew ]; then
eval "$(/usr/local/bin/brew shellenv)"
fi
### Ensure ~/.local/bin in PATH
export PATH="$HOME/.local/bin:$PATH"