chore: shfmt, cleanup

This commit is contained in:
2024-12-28 18:59:09 +02:00
parent eb91a43bbd
commit a8a473a46d
26 changed files with 299 additions and 516 deletions

View File

@@ -130,6 +130,6 @@ X_ALIAS_FILES=(
)
for aliasFile in "${X_ALIAS_FILES[@]}"; do
# shellcheck source=$HOME/.config/alias-secret
[ -f "$aliasFile" ] && source "$aliasFile" && msg "Sourced $aliasFile"
[ -f "$aliasFile" ] && source "$aliasFile" && msgr ok "Sourced $aliasFile"
done
unset X_ALIAS_FILES

View File

@@ -42,7 +42,7 @@ if ! declare -f msg > /dev/null; then
# $1 - message (string)
msg()
{
[ "$VERBOSE" -eq 1 ] && echo "$1"
[ "$VERBOSE" -eq 1 ] && msgr msg "$1"
return 0
}
msg "msg was not defined, defined it now"
@@ -54,7 +54,7 @@ if ! declare -f msg_err > /dev/null; then
# $1 - error message (string)
msg_err()
{
echo "(!) ERROR: $1" >&2
msgr err "$1" >&2
exit 1
}
fi
@@ -65,7 +65,7 @@ if ! declare -f msg_done > /dev/null; then
# $1 - message (string)
msg_done()
{
echo "$1"
msgr done "$1"
return 0
}
fi
@@ -76,7 +76,7 @@ if ! declare -f msg_run > /dev/null; then
# $1 - message (string)
msg_run()
{
echo "$1"
msgr run "$1"
return 0
}
fi
@@ -87,10 +87,29 @@ if ! declare -f msg_ok > /dev/null; then
# $1 - message (string)
msg_ok()
{
echo "$1"
msgr ok "$1"
return 0
}
fi
if ! declare -f array_diff > /dev/null; then
# Function to compare two arrays and return the difference
# Example: array_diff DIFFERENCE ARRAY1 ARRAY2
# $1 - variable to store the difference
# $2 - first array
# $3 - second array
# Output to $1 the difference between $2 and $3
# Source: https://stackoverflow.com/a/42399479/594940
array_diff()
{
# shellcheck disable=SC1083,SC2086
eval local ARR1=\(\"\${$2[@]}\"\)
# shellcheck disable=SC1083,SC2086
eval local ARR2=\(\"\${$3[@]}\"\)
local IFS=$'\n'
mapfile -t "$1" < <(comm -23 <(echo "${ARR1[*]}" | sort) <(echo "${ARR2[*]}" | sort))
}
fi
source "$DOTFILES/config/exports"
source "$DOTFILES/config/alias"

View File

@@ -25,9 +25,9 @@ git submodule update --init --recursive "${DOTBOT_DIR}"
if [ "${DOTBOT_HOST}" != "" ]; then
DOTBOT_HOST_CONFIG="${BASEDIR}/hosts/${DOTBOT_HOST}/${CONFIG}"
echo "-> Trying if host config can be found: ${DOTBOT_HOST_CONFIG}"
[ -r "$DOTBOT_HOST_CONFIG" ] && [ -f "$DOTBOT_HOST_CONFIG" ] &&
echo "(!) Found $DOTBOT_HOST_CONFIG" &&
"$DOTBOT_BIN_PATH" \
[ -r "$DOTBOT_HOST_CONFIG" ] && [ -f "$DOTBOT_HOST_CONFIG" ] \
&& echo "(!) Found $DOTBOT_HOST_CONFIG" \
&& "$DOTBOT_BIN_PATH" \
-d "$BASEDIR" \
--plugin-dir=tools/dotbot-asdf \
--plugin-dir=tools/dotbot-brew \

View File

@@ -19,7 +19,8 @@ for arg in "$@"; do
done
# Ensure log directory and file exist with correct permissions
prepare_log_file() {
prepare_log_file()
{
local log_dir
log_dir=$(dirname "$LOG_FILE")
@@ -40,7 +41,8 @@ prepare_log_file() {
prepare_log_file
# Logging function
log_message() {
log_message()
{
local message="$1"
echo "$(date +'%Y-%m-%d %H:%M:%S') - $message" >> "$LOG_FILE"
@@ -51,8 +53,9 @@ log_message() {
}
# Function to print usage
print_help() {
cat <<EOF
print_help()
{
cat << EOF
Usage: a [command] [file_or_directory] [options]
Commands:
@@ -88,13 +91,15 @@ EOF
}
# Function to print version
print_version() {
print_version()
{
echo "a version $VERSION"
echo "Created by Ismo Vuorinen <https://github.com/ivuorinen>"
}
# Function to fetch keys if missing
fetch_keys_if_missing() {
fetch_keys_if_missing()
{
if [[ ! -f "$KEYS_FILE" ]]; then
log_message "Keys file '$KEYS_FILE' not found. Attempting to fetch from $KEYS_SOURCE..."
mkdir -p "$(dirname "$KEYS_FILE")"
@@ -111,7 +116,8 @@ fetch_keys_if_missing() {
}
# Function to encrypt files or directories
encrypt_file_or_directory() {
encrypt_file_or_directory()
{
local file="$1"
if [[ -d "$file" ]]; then
for f in "$file"/*; do
@@ -120,7 +126,7 @@ encrypt_file_or_directory() {
elif [[ -f "$file" ]]; then
fetch_keys_if_missing
local output_file="${file}.age"
age -R "$KEYS_FILE" "$file" >"$output_file"
age -R "$KEYS_FILE" "$file" > "$output_file"
if [[ $? -eq 0 ]]; then
log_message "File encrypted successfully: $output_file"
else
@@ -131,7 +137,8 @@ encrypt_file_or_directory() {
}
# Function to decrypt files or directories
decrypt_file_or_directory() {
decrypt_file_or_directory()
{
local file="$1"
if [[ -d "$file" ]]; then
for f in "$file"/*.age; do
@@ -140,7 +147,7 @@ decrypt_file_or_directory() {
elif [[ -f "$file" ]]; then
fetch_keys_if_missing
local output_file="${file%.age}"
age -d -i "$KEYS_FILE" "$file" >"$output_file"
age -d -i "$KEYS_FILE" "$file" > "$output_file"
if [[ $? -eq 0 ]]; then
log_message "File decrypted successfully: $output_file"
else
@@ -152,7 +159,7 @@ decrypt_file_or_directory() {
# Main logic
case "$1" in
e|enc|encrypt)
e | enc | encrypt)
if [[ $# -lt 2 ]]; then
log_message "Error: No file or directory specified for encryption."
print_help
@@ -160,7 +167,7 @@ case "$1" in
fi
encrypt_file_or_directory "$2"
;;
d|dec|decrypt)
d | dec | decrypt)
if [[ $# -lt 2 ]]; then
log_message "Error: No file or directory specified for decryption."
print_help
@@ -168,10 +175,10 @@ case "$1" in
fi
decrypt_file_or_directory "$2"
;;
help|--help)
help | --help)
print_help
;;
version|--version)
version | --version)
print_version
;;
*)

View File

@@ -6,12 +6,12 @@ KEYS_FILE="${AGE_KEYSFILE:-$HOME/.ssh/keys.txt}"
KEYS_SOURCE="${AGE_KEYSSOURCE:-https://github.com/ivuorinen.keys}"
# Check for required commands
if ! command -v age &>/dev/null; then
if ! command -v age &> /dev/null; then
echo "Error: age is not installed. Please install it to continue."
exit 1
fi
if ! command -v curl &>/dev/null; then
if ! command -v curl &> /dev/null; then
echo "Error: curl is not installed. Please install it to continue."
exit 1
fi
@@ -28,7 +28,6 @@ if [[ ! -f "$FILE" ]]; then
exit 1
fi
# Check if keys file exists, otherwise fetch it
if [[ ! -f "$KEYS_FILE" ]]; then
echo "Keys file '$KEYS_FILE' not found. Attempting to fetch from $KEYS_SOURCE..."
@@ -51,7 +50,7 @@ fi
# Decrypt the file
OUTPUT_FILE="${FILE%.age}"
age -d -i "$KEYS_FILE" "$FILE" >"$OUTPUT_FILE"
age -d -i "$KEYS_FILE" "$FILE" > "$OUTPUT_FILE"
if [[ $? -eq 0 ]]; then
echo "File decrypted successfully: $OUTPUT_FILE"
@@ -59,4 +58,3 @@ else
echo "Error: Failed to decrypt file."
exit 1
fi

View File

@@ -6,17 +6,18 @@ KEYS_FILE="${AGE_KEYSFILE:-$HOME/.ssh/keys.txt}"
KEYS_SOURCE="${AGE_KEYSSOURCE:-https://github.com/ivuorinen.keys}"
# Check for required commands
if ! command -v age &>/dev/null; then
if ! command -v age &> /dev/null; then
echo "Error: age is not installed. Please install it to continue."
exit 1
fi
if ! command -v curl &>/dev/null; then
if ! command -v curl &> /dev/null; then
echo "Error: curl is not installed. Please install it to continue."
exit 1
fi
# Ensure a file is provided
# shellcheck disable=SC2181
if [[ $# -lt 1 ]]; then
echo "Usage: $0 <file-to-encrypt>"
exit 1
@@ -50,7 +51,7 @@ fi
# Encrypt the file
OUTPUT_FILE="${FILE}.age"
age -R "$KEYS_FILE" "$FILE" >"$OUTPUT_FILE"
age -R "$KEYS_FILE" "$FILE" > "$OUTPUT_FILE"
if [[ $? -eq 0 ]]; then
echo "File encrypted successfully: $OUTPUT_FILE"

View File

@@ -14,62 +14,8 @@
SCRIPT=$(basename "$0")
if ! declare -f msg > /dev/null; then
# Function to print messages if VERBOSE is enabled
# $1 - message (string)
msg()
{
[ "$VERBOSE" -eq 1 ] && echo "$1"
return 0
}
fi
if ! declare -f msg_err > /dev/null; then
# Function to print error messages and exit
# $1 - error message (string)
msg_err()
{
# shellcheck disable=SC2317
echo "(!) ERROR: $1" >&2
# shellcheck disable=SC2317
exit 1
}
fi
if ! declare -f msg_done > /dev/null; then
# Function to print done message
# $1 - message (string)
msg_done()
{
# shellcheck disable=SC2317
echo "✓ $1"
# shellcheck disable=SC2317
return 0
}
fi
if ! declare -f array_diff > /dev/null; then
# Function to compare two arrays and return the difference
# Example: array_diff DIFFERENCE ARRAY1 ARRAY2
# $1 - variable to store the difference
# $2 - first array
# $3 - second array
# Output to $1 the difference between $2 and $3
# Source: https://stackoverflow.com/a/42399479/594940
array_diff()
{
# shellcheck disable=SC1083,SC2086
eval local ARR1=\(\"\${$2[@]}\"\)
# shellcheck disable=SC1083,SC2086
eval local ARR2=\(\"\${$3[@]}\"\)
local IFS=$'\n'
mapfile -t "$1" < <(comm -23 <(echo "${ARR1[*]}" | sort) <(echo "${ARR2[*]}" | sort))
}
fi
# Loads configs for better installation experience
source "$DOTFILES/config/shared.sh"
source "${DOTFILES}/local/bin/msgr"
# -- Menu builder -- #
@@ -153,15 +99,15 @@ section_install()
"gh:Install GitHub CLI Extensions"
"go:Install Go Packages"
"imagick:Install ImageMagick CLI"
"starship:Install starship.rs"
"macos:Setup nice macOS defaults"
"neofetch:Install neofetch"
"nvm:Install Node Version Manager (nvm)"
"nvm-latest:Install latest lts node using nvm"
"npm:Install NPM Packages"
"ntfy:Install ntfy"
"nvm-latest:Install latest lts node using nvm"
"nvm:Install Node Version Manager (nvm)"
"ohmybash:Install oh-my-bash"
"pip:Install pip/python packages"
"starship:Install starship.rs"
"z:Install z"
)
@@ -171,124 +117,117 @@ section_install()
$0 install macos
$0 install fonts
$0 brew install
#$0 install ohmyposh
$0 install asdf
$0 install composer
$0 install fzf
#$0 install go
$0 install cheat-databases
#$0 install imagick
$0 install nvm
$0 install npm
# $0 install ntfy
$0 install npm-packages
$0 install z
msgr msg "Reloading configurations again..."
source "$DOTFILES/config/shared.sh"
msgr yay "All done!"
;;
asdf)
msg "Installing asdf..."
msgr run "Installing asdf..."
$0 asdf plugins-add \
&& msg_yay "asdf installed!"
&& msgr yay "asdf plugins installed!"
;;
cargo)
msg "Installing cargo packages..."
msgr run "Installing cargo packages..."
bash "$DOTFILES/scripts/install-cargo-packages.sh" \
&& msg_yay "cargo packages installed!"
&& msgr yay "cargo packages installed!"
;;
cheat-databases)
msg "Installing cheat databases..."
msgr run "Installing cheat databases..."
for database in "$DOTFILES"/scripts/install-cheat-*; do
bash "$database" \
&& msg_yay "Cheat: $database run"
&& msgr run_done "Cheat: $database run"
done
;;
composer)
msg "Installing composer..."
msgr run "Installing composer..."
bash "$DOTFILES/scripts/install-composer.sh" \
&& msg_yay "composer installed!"
&& msgr run_done "composer installed!"
;;
fonts)
msg "Installing fonts..."
msgr run "Installing fonts..."
bash "$DOTFILES/scripts/install-fonts.sh" \
&& msg_yay "Installed fonts!"
&& msgr yay "Installed fonts!"
;;
fzf)
msg "Installing fzf..."
msgr run "Installing fzf..."
bash "$DOTFILES/scripts/install-fzf.sh" \
&& msg_yay "fzf installed!"
&& msgr yay "fzf installed!"
;;
gh)
msg "Installing GitHub CLI Extensions..."
msgr run "Installing GitHub CLI Extensions..."
bash "$DOTFILES/scripts/install-gh-extensions.sh" \
&& msg_yay "github cli extensions installed!"
&& msgr yay "github cli extensions installed!"
;;
go)
msg "Installing Go Packages..."
msgr run "Installing Go Packages..."
bash "$DOTFILES/scripts/install-go-packages.sh" \
&& msg_yay "go packages installed!"
&& msgr yay "go packages installed!"
;;
imagick)
msg "Installing ImageMagick CLI..."
msgr run "Downloading and installing ImageMagick CLI..."
curl -L https://imagemagick.org/archive/binaries/magick > "$XDG_BIN_HOME/magick" \
&& chmod +x "$XDG_BIN_HOME/magick" \
&& msg_yay "imagick installed!"
&& msgr yay "imagick downloaded and installed!"
;;
macos)
msg "Setting up macOS defaults..."
bash "$DOTFILES/scripts/set-macos-defaults.sh" \
&& msg_yay "Brewfile defined apps has been installed!"
;;
neofetch)
msg "Installing neofetch..."
bash "$DOTFILES/scripts/install-neofetch.sh" \
&& msg_yay "neofetch installed!"
msgr run "Setting up macOS defaults..."
bash "$DOTFILES/scripts/install-macos-defaults.sh" \
&& msgr yay "macOS defaults set!"
;;
nvm)
msg "Installing nvm..."
msgr run "Installing nvm..."
local NVM_VERSION
NVM_VERSION=$(x-gh-get-latest-version nvm-sh/nvm)
msg "Latest nvm version: $NVM_VERSION"
NVM_INSTALL="https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_VERSION}/install.sh"
NVM_CURL="curl -o- \"$NVM_INSTALL\" | bash"
msgr ok "Latest nvm version: $NVM_VERSION"
local NVM_INSTALL="https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_VERSION}/install.sh"
local NVM_CURL="curl -o- \"$NVM_INSTALL\" | bash"
PROFILE=/dev/null bash -c "$NVM_CURL"
$0 install nvm-latest
msg_yay "nvm installed!"
msgr yay "nvm installed!"
;;
nvm-latest)
msg "Installing latest lts node..."
msgr run "Installing latest lts node..."
if [ -n "$NVM_DIR" ]; then
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
fi
nvm install --lts --latest-npm --default
git checkout "$DOTFILES/base/zshrc"
git checkout "$DOTFILES/base/bashrc"
msg_yay "latest lts node installed!"
msgr yay "latest lts node installed!"
;;
npm)
msg "NPM Packages install started..."
npm-packages)
msgr run "NPM Packages install started..."
bash "$DOTFILES/scripts/install-npm-packages.sh" \
&& msg_yay "NPM Packages have been installed!"
;;
ntfy)
msg "ntfy install started..."
bash "$DOTFILES/scripts/install-ntfy.sh" \
&& msg_yay "ntfy installed!"
;;
ohmyposh)
msg "oh-my-posh install started..."
bash "$DOTFILES/scripts/install-ohmyposh.sh" \
&& msg_yay "oh-my-posh installed!"
;;
pip)
msg "pip install started..."
bash "$DOTFILES/scripts/install-pip-packages.sh"
&& msgr yay "NPM Packages have been installed!"
;;
z)
msg "Installing z..."
msgr run "Installing z..."
bash "$DOTFILES/scripts/install-z.sh" \
&& msg_yay "z has been installed!"
&& msgr yay "z has been installed!"
;;
*) menu_usage "$USAGE_PREFIX" "${MENU[@]}" ;;
*) menu_builder "$USAGE_PREFIX" "${MENU[@]}" ;;
esac
}
@@ -309,12 +248,14 @@ section_brew()
x-have brew && {
case "$1" in
install)
brew bundle install --file="$BREWFILE" --force --quiet && msg_yay "Done!"
brew bundle install --file="$BREWFILE" --force --quiet && msgr yay "Done!"
;;
update)
brew update && brew outdated && brew upgrade && brew cleanup
msg_yay "Done!"
msgr yay "Done!"
;;
updatebundle)
# Updates .dotfiles/homebrew/Brewfile with descriptions
brew bundle dump \
@@ -324,11 +265,13 @@ section_brew()
--tap \
--formula \
--cask \
--describe && msg_yay "Done!"
--describe && msgr yay "Done!"
;;
leaves)
brew leaves --installed-on-request
;;
untracked)
declare -a BREW_LIST_ALL
while IFS= read -r line; do
@@ -361,7 +304,7 @@ section_brew()
# If there are no untracked packages, exit
if [ ${#BREW_LIST_UNTRACKED[@]} -eq 0 ]; then
msg_yay "No untracked packages found!"
msgr yay "No untracked packages found!"
exit 0
fi
@@ -370,20 +313,19 @@ section_brew()
echo " $f"
done
;;
clean)
brew bundle cleanup --file="$BREWFILE" && msg_yay "Done!"
;;
autoupdate)
brew autoupdate delete
brew autoupdate start 43200 --upgrade --cleanup --immediate
;;
*)
menu_usage "$USAGE_PREFIX" "${MENU[@]}"
;;
clean) brew bundle cleanup --file="$BREWFILE" && msgr yay "Done!" ;;
*) menu_builder "$USAGE_PREFIX" "${MENU[@]}" ;;
esac
}
! x-have brew && menu_section "$USAGE_PREFIX" "brew not available on this system"
! x-have brew && menu_builder "$USAGE_PREFIX" "brew not available on this system"
}
section_asdf()
@@ -431,13 +373,13 @@ section_asdf()
while IFS= read -r line; do
# Ohita tyhjät rivit ja kommentit
[[ -z "$line" || "$line" =~ ^# ]] && continue
[[ -z $line || $line =~ ^# ]] && continue
local plugin
plugin=$(echo "$line" | awk '{print $1}')
# Ohita direnv, käsiteltiin jo
[[ "$plugin" == "direnv" ]] && continue
[[ $plugin == "direnv" ]] && continue
if ! echo "$installed_plugins" | grep -q "^${plugin}$"; then
msgr nested "Installing $plugin plugin"
@@ -476,30 +418,30 @@ section_asdf()
msgr run "Fixing tool-versions file"
# Tarkista että tiedosto on olemassa
if [[ ! -f "$tool_versions_file" ]]; then
# Check that .tool-versions file exists
if [[ ! -f $tool_versions_file ]]; then
msgr error "tool-versions file not found: $tool_versions_file"
rm -f "$temp_file"
return 1
fi
# Tarkista että asdf on asennettu
# Check that asdf can be found in the path
if ! command -v asdf > /dev/null; then
msgr error "asdf not found"
rm -f "$temp_file"
return 1
fi
# Lue asennetut pluginit
# Read installed plugins
msgr nested "Reading installed plugins"
local installed_plugins
installed_plugins=$(asdf plugin list | sort)
# Käy läpi tool-versions tiedosto ja säilytä vain asennetut pluginit
# Compare .tool-versions and installed plugins, remove unknown plugins from .tool-versions
msgr nested "Updating tool-versions file"
while IFS= read -r line; do
# Säilytä kommentit ja tyhjät rivit
if [[ -z "$line" || "$line" =~ ^[[:space:]]*# ]]; then
if [[ -z $line || $line =~ ^[[:space:]]*# ]]; then
echo "$line" >> "$temp_file"
continue
fi
@@ -514,17 +456,17 @@ section_asdf()
fi
done < "$tool_versions_file"
# Tarkista että temp-tiedosto ei ole tyhjä tai sisällä vain kommentteja
if [[ ! -s "$temp_file" ]] || ! grep -v '^[[:space:]]*#' "$temp_file" | grep -q .; then
# Check that the temp file is valid
if [[ ! -s $temp_file ]] || ! grep -v '^[[:space:]]*#' "$temp_file" | grep -q .; then
msgr error "Generated file is empty or contains only comments, keeping original"
rm -f "$temp_file"
return 1
fi
# Varmuuskopioi alkuperäinen
# Backup the original .tool-versions
cp "$tool_versions_file" "${tool_versions_file}.bak"
# Siirrä uusi versio paikalleen
# Overwrite .tool-versions with the generated file
mv "$temp_file" "$tool_versions_file"
msgr run_done "Updated $tool_versions_file"
@@ -533,30 +475,12 @@ section_asdf()
return 0
;;
current)
asdf current
;;
global)
asdf global
;;
installed)
asdf list
;;
versions)
asdf list all
;;
where)
asdf where
;;
which)
asdf which
;;
current) asdf current ;;
global) asdf global ;;
installed) asdf list ;;
versions) asdf list all ;;
where) asdf where ;;
which) asdf which ;;
*) menu_builder "$USAGE_PREFIX" "${MENU[@]}" ;;
esac
}
@@ -586,6 +510,7 @@ section_helpers()
# shellcheck disable=2001
for i in $(echo "$PATH" | sed 's/:/ /g'); do echo "$i"; done
;;
aliases)
case "$SECTION" in
"zsh")
@@ -599,6 +524,7 @@ section_helpers()
;;
esac
;;
"colors")
max=255
start=0
@@ -622,24 +548,14 @@ section_helpers()
printf "\n"
start=$((start + 10))
done
;;
;;
"env")
env | sort
;;
"functions")
declare -F
;;
"nvim")
cat "$DOTFILES/docs/nvim-keybindings.md"
;;
"tmux")
cat "$DOTFILES/docs/tmux-keybindings.md"
;;
"wezterm")
cat "$DOTFILES/docs/wezterm-keybindings.md"
;;
*) menu_usage "$USAGE_PREFIX" "${MENU[@]}" ;;
"env") env | sort ;;
"functions") declare -F ;;
"nvim") cat "$DOTFILES/docs/nvim-keybindings.md" ;;
"tmux") cat "$DOTFILES/docs/tmux-keybindings.md" ;;
"wezterm") cat "$DOTFILES/docs/wezterm-keybindings.md" ;;
*) menu_builder "$USAGE_PREFIX" "${MENU[@]}" ;;
esac
}
@@ -663,7 +579,7 @@ section_docs()
tmux) bash "$DOTFILES/local/bin/x-dfm-docs-xterm-keybindings" ;;
nvim) bash "$DOTFILES/scripts/create-nvim-keymaps.sh" ;;
wezterm) bash "$DOTFILES/scripts/create-wezterm-keymaps.sh" ;;
*) menu_usage "$USAGE_PREFIX" "${MENU[@]}" ;;
*) menu_builder "$USAGE_PREFIX" "${MENU[@]}" ;;
esac
}
@@ -681,37 +597,42 @@ section_dotfiles()
case "$1" in
fmt)
msg_ok "Running all formatters"
msgr run "Running all formatters"
$0 dotfiles yamlfmt
$0 dotfiles shfmt
msg_done "...done!"
msgr run_done "...done!"
;;
reset_all)
msg_ok "Running all reset commands"
msgr ok "Running all reset commands"
$0 dotfiles reset_nvim
;;
reset_nvim)
msgr run "Cleaning nvim state, cache and config"
rm -rf \
~/.local/share/nvim \
~/.local/state/nvim \
~/.cache/nvim \
~/.config/nvim
msg_ok "Deleted old nvim files (share, state and cache + config)"
msgr ok "Deleted old nvim files (share, state and cache + config)"
ln -s "$DOTFILES/config/nvim" ~/.config/nvim
msg_ok "Linked nvim and astronvim"
msgr ok "Linked nvim and astronvim"
x-have npm && $0 install npm
msg_ok "Installed packages"
msg_done "nvim reset!"
msgr ok "Installed packages"
msgr run_done "nvim reset!"
;;
yamlfmt)
# format yaml files
x-have yamlfmt && yamlfmt -conf "$DOTFILES/.yamlfmt"
! x-have yamlfmt && msg_err "yamlfmt not found"
! x-have yamlfmt && msgr err "yamlfmt not found"
;;
shfmt)
# If system doesn't have fd or shfmt installed, exit
! x-have fd && msg_err "fd not found, install with asdf"
! x-have shfmt && msg_err "shfmt not found, install with asdf"
! x-have fd && msgr err "fd not found, install it to continue"
! x-have shfmt && msgr err "shfmt not found, install it to continue"
# Format shell scripts according to following rules.
fd --full-path "$DOTFILES" -tx \
--hidden \
@@ -722,9 +643,10 @@ section_dotfiles()
--func-next-line --list --write \
--indent 2 --case-indent --space-redirects \
--binary-next-line {} \;
msg_yay "dotfiles have been shfmt formatted!"
msgr yay "dotfiles have been shfmt formatted!"
;;
*) menu_usage "$USAGE_PREFIX" "${MENU[@]}" ;;
*) menu_builder "$USAGE_PREFIX" "${MENU[@]}" ;;
esac
}
@@ -744,11 +666,58 @@ section_check()
[[ $2 == "" ]] && echo "$X_ARCH" && exit 0
[[ $X_ARCH == "$2" ]] && exit 0 || exit 1
;;
h | host | hostname)
[[ $2 == "" ]] && echo "$X_HOSTNAME" && exit 0
[[ $X_HOSTNAME == "$2" ]] && exit 0 || exit 1
;;
*) menu_usage "$USAGE_PREFIX" "${MENU[@]}" ;;
*) menu_builder "$USAGE_PREFIX" "${MENU[@]}" ;;
esac
}
section_scripts()
{
USAGE_PREFIX="$SCRIPT scripts <command>"
# Get description from a file
get_script_description()
{
local file
local desc
file="$1"
desc=$(sed -n '/@description/s/.*@description *\(.*\)/\1/p' "$file" | head -1)
echo "${desc:-No description available}"
}
# Collect scripts and their descriptions
declare -A SCRIPT_MENU
for script in "$DOTFILES/scripts/install-"*.sh; do
if [ -f "$script" ]; then
name=$(basename "$script" .sh | sed 's/install-//')
desc=$(get_script_description "$script")
SCRIPT_MENU[$name]="$desc"
fi
done
case "$1" in
"")
# Show the menu
local menu_items=()
for name in "${!SCRIPT_MENU[@]}"; do
menu_items+=("$name:${SCRIPT_MENU[$name]}")
done
menu_builder "$USAGE_PREFIX" "${menu_items[@]}"
;;
*)
# Run the chosen script
script_path="$DOTFILES/scripts/install-$1.sh"
if [ -f "$script_path" ]; then
bash "$script_path"
else
msgr err "Script not found: $1"
fi
;;
esac
}
@@ -758,7 +727,7 @@ section_tests()
USAGE_PREFIX="$SCRIPT tests <command>"
MENU=(
"msg:List all log functions from shared.sh"
"msgr:List all available msgr message types"
"params:List all parameters"
)
@@ -770,29 +739,29 @@ section_tests()
done
;;
msg)
msg "msg"
msg_done "msg_done"
msg_done_suffix "msg_done_suffix"
msg_err "msg_err"
msg_nested "msg_nested"
msg_nested_done "msg_nested_done"
msg_ok "msg_ok"
msg_prompt "msg_prompt"
msg_prompt_done "msg_prompt_done"
msg_run "msg_run" "second_param"
msg_run_done "msg_run_done" "second_param"
msg_warn "msg_warn"
msg_yay "msg_yay"
msg_yay_done "msg_yay_done"
# shellcheck disable=SC1010
msgr done "msgr done"
msgr done_suffix "msgr done_suffix"
msgr err "msgr err"
msgr nested "msgr nested"
msgr nested_done "msgr nested_done"
msgr ok "msgr ok"
msgr prompt "msgr prompt"
msgr prompt_done "msgr prompt_done"
msgr run "msgr run" "second_param"
msgr run_done "msgr run_done" "second_param"
msgr warn "msgr warn"
msgr yay "msgr yay"
msgr yay_done "msgr yay_done"
;;
*) menu_usage "$USAGE_PREFIX" "${MENU[@]}" ;;
*) menu_builder "$USAGE_PREFIX" "${MENU[@]}" ;;
esac
}
usage()
{
echo ""
msg_prompt "Usage: $SCRIPT <section> <command>"
msgr prompt "Usage: $SCRIPT <section> <command>"
echo $" Empty <command> prints <section> help."
echo ""
section_install
@@ -807,6 +776,8 @@ usage()
echo ""
section_docs
echo ""
section_scripts
echo ""
section_helpers
}
@@ -823,6 +794,7 @@ main()
dotfiles) section_dotfiles "$@" ;;
helpers) section_helpers "$@" ;;
docs) section_docs "$@" ;;
scripts) section_scripts "$@" ;;
tests) section_tests "$@" ;;
*) usage && exit 0 ;;
esac

View File

@@ -1,18 +0,0 @@
#!/usr/bin/env bash
#
# Export oh-my-posh configuration as an image
#
# shellcheck source=shared.sh
source "${DOTFILES}/config/shared.sh"
main()
{
cd "$DOTFILES" || msg_err "Failed to change directory to $DOTFILES"
oh-my-posh config export image \
--config "$OHMYPOSH_CFG" \
--output "$HOME/.dotfiles/.github/screenshots/oh-my-posh.png" \
--author "Ismo Vuorinen"
}
main "$@"

View File

@@ -1,12 +0,0 @@
#!/usr/bin/env bash
#
# Install asdf and plugins I use
#
# It also updates asdf and the plugins, and then reshim asdf.
#
# Usage: ./install-asdf.sh [both|install|update|add_plugins]
# Author: Ismo Vuorinen <https://github.com/ivuorinen>
# License: MIT
msgr warn "The asdf plugins should be installed with dotbot, and 'dfm asdf'."
exit 0

View File

@@ -3,9 +3,6 @@
#
# shellcheck source=shared.sh
echo "This file ($0) has been deprecated in favor of asdf. Please use asdf instead."
exit 0
eval "$HOME/.dotfiles/config/shared.sh"
msg "Starting to install rust/cargo packages"

View File

@@ -2,7 +2,7 @@
# Install PHP Package Manager Composer
#
# shellcheck source="shared.sh"
eval "$HOME/.dotfiles/config/shared.sh"
source "$HOME/.dotfiles/config/shared.sh"
if ! command -v php &> /dev/null; then
msg_err "PHP Not Available, cannot install composer"

View File

@@ -7,24 +7,21 @@ source "$DOTFILES/config/shared.sh"
GIT_REPO="https://github.com/ryanoasis/nerd-fonts.git"
TMP_PATH="$XDG_CACHE_HOME/nerd-fonts"
msg "-- NerdFonts --"
msgr run "Starting to install NerdFonts"
fonts=(
Hack
IntelOneMono
JetBrainsMono
OpenDyslexic
SpaceMono
)
# Function to clone or update the NerdFonts repository
clone_or_update_repo()
{
if [ ! -d "$TMP_PATH" ]; then
git clone --quiet --filter=blob:none --sparse "$GIT_REPO" "$TMP_PATH"
git clone --quiet --filter=blob:none --sparse --depth=1 "$GIT_REPO" "$TMP_PATH"
fi
cd "$TMP_PATH" || msg_err "No such folder $TMP_PATH"
cd "$TMP_PATH" || msgr err "No such folder $TMP_PATH"
}
# Function to add fonts to sparse-checkout
@@ -36,7 +33,7 @@ add_fonts_to_sparse_checkout()
# Skip comments
if [[ ${font:0:1} == "#" ]]; then continue; fi
msg_run "Adding $font to sparse-checkout"
msgr run "Adding $font to sparse-checkout"
git sparse-checkout add "patched-fonts/$font"
echo ""
done
@@ -45,9 +42,9 @@ add_fonts_to_sparse_checkout()
# Function to install NerdFonts
install_fonts()
{
msg "Starting to install NerdFonts..."
msgr run "Starting to install NerdFonts..."
./install.sh -q -s ${fonts[*]}
msg_ok "Done"
msgr run_done "Done"
}
remove_tmp_path()

View File

@@ -1,29 +0,0 @@
#!/usr/bin/env bash
#
# Install fzf
#
echo "This file ($0) has been deprecated in favor of asdf. Please use asdf instead."
exit 0
# shellcheck source=shared.sh
eval "$DOTFILES/config/shared.sh"
FZF_GIT="https://github.com/junegunn/fzf.git"
FZF_PATH="${XDG_CONFIG_HOME}/fzf"
FZF_BUILD="/tmp/fzf"
main()
{
if [ ! -d "$FZF_BUILD" ]; then
git clone --depth 1 "$FZF_GIT" "$FZF_BUILD"
"$FZF_BUILD/install" \
--xdg \
--bin
msg_done "fzf installed"
else
msg_done "fzf ($FZF_PATH/) already installed"
fi
}
main "$@"

View File

@@ -7,10 +7,10 @@ source "${DOTFILES}/config/shared.sh"
# Enable verbosity with VERBOSE=1
VERBOSE="${VERBOSE:-0}"
msg_run "Installing gh (GitHub Client) extensions"
msgr run "Installing gh (GitHub Client) extensions"
if ! command -v gh &> /dev/null; then
msg_err "gh (GitHub Client) could not be found, please install it first"
msgr err "gh (GitHub Client) could not be found, please install it first"
exit 0
fi
@@ -43,7 +43,7 @@ install_extensions()
# Skip comments
if [[ ${ext:0:1} == "#" ]]; then continue; fi
msg_nested "Installing $ext"
msgr nested "Installing $ext"
gh extension install "$ext"
echo ""
done
@@ -52,7 +52,7 @@ install_extensions()
main()
{
install_extensions
msg_ok "Done"
msgr run_done "Done"
}
main "$@"

View File

@@ -9,7 +9,7 @@ source "${DOTFILES}/config/shared.sh"
# Enable verbosity with VERBOSE=1
VERBOSE="${VERBOSE:-0}"
msg_run "Installing git-crypt"
msgr run "Installing git-crypt"
if ! command -v git-crypt &> /dev/null; then
REPO_URL="https://github.com/AGWA/git-crypt.git"
@@ -23,8 +23,8 @@ if ! command -v git-crypt &> /dev/null; then
cd "$BUILD_PATH" || msg_err "$BUILD_PATH not found"
make && make install PREFIX="$HOME/.local"
else
msg_done "git-crypt ($CHECK_PATH) already installed"
msgr run_done "git-crypt ($CHECK_PATH) already installed"
fi
fi
msg_done "Done installing git-crypt"
msgr run_done "Done installing git-crypt"

View File

@@ -2,18 +2,14 @@
# Install Go packages
#
# shellcheck source=shared.sh
echo "This file ($0) has been deprecated in favor of asdf. Please use asdf instead."
exit 0
eval "$DOTFILES/config/shared.sh"
source "$DOTFILES/config/shared.sh"
# Enable verbosity with VERBOSE=1
VERBOSE="${VERBOSE:-0}"
msg_run "Installing go packages"
msgr run "Installing go packages"
! x-have "go" && msg "go hasn't been installed yet." && exit 0
! x-have "go" && msgr err "go hasn't been installed yet." && exit 0
packages=(
# A shell parser, formatter, and interpreter with bash support; includes shfmt
@@ -49,7 +45,7 @@ install_packages()
# Skip comments
if [[ ${pkg:0:1} == "#" ]]; then continue; fi
msg_nested "Installing go package: $pkg"
msgr nested "Installing go package: $pkg"
go install "$pkg"
echo ""
done
@@ -58,23 +54,23 @@ install_packages()
# Function to install completions and run actions for selected packages
post_install()
{
msg_run "Installing completions for selected packages"
msgr run "Installing completions for selected packages"
if command -v git-profile &> /dev/null; then
git-profile completion zsh > "$ZSH_CUSTOM_COMPLETION_PATH/_git-profile" \
&& msg_ok "Installed completions for git-profile"
&& msgr run_done "Installed completions for git-profile"
fi
if command -v antidot &> /dev/null; then
antidot update \
&& msg_ok "Updated antidot database"
&& msgr run_done "Updated antidot database"
fi
}
# Function to clear go cache
clear_go_cache()
{
msg_run "Clearing go cache"
msgr run "Clearing go cache"
go clean -cache -modcache
}
@@ -83,7 +79,7 @@ main()
install_packages
post_install
clear_go_cache
msg_ok "Done"
msgr run_done "Done"
}
main "$@"

View File

@@ -1,73 +0,0 @@
#!/usr/bin/env bash
#
# Install neofetch from source
#
# shellcheck source=shared.sh
source "$DOTFILES/config/shared.sh"
if ! declare -f msg > /dev/null; then
# Function to print messages if VERBOSE is enabled
# $1 - message (string)
msg()
{
[ "$VERBOSE" -eq 1 ] && echo "$1"
return 0
}
fi
if ! declare -f msg_err > /dev/null; then
# Function to print error messages and exit
# $1 - error message (string)
msg_err()
{
echo "(!) ERROR: $1" >&2
exit 1
}
fi
if ! declare -f msg_done > /dev/null; then
# Function to print done message
# $1 - message (string)
msg_done()
{
echo "$1"
return 0
}
fi
NEOFETCH_VERSION="$(x-gh-get-latest-version dylanaraps/neofetch)"
NEOFETCH_REPO="https://github.com/dylanaraps/neofetch"
NEOFETCH_URL="${NEOFETCH_REPO}/archive/refs/tags/${NEOFETCH_VERSION}.tar.gz"
NEOFETCH_TEMP="/tmp/neofetch"
NEOFETCH_INSTALL_PREFIX="$HOME/.local"
# Enable verbosity with VERBOSE=1
VERBOSE="${VERBOSE:-0}"
# Function to install neofetch from source
install_neofetch()
{
LC_ALL=C
mkdir -p "$NEOFETCH_TEMP" "$NEOFETCH_INSTALL_PREFIX"
curl -L "$NEOFETCH_URL" -o "$NEOFETCH_TEMP.tar.gz"
tar zxvf "$NEOFETCH_TEMP.tar.gz" --directory="$NEOFETCH_TEMP"
cd "$NEOFETCH_TEMP/neofetch-$NEOFETCH_VERSION" \
&& make PREFIX="${NEOFETCH_INSTALL_PREFIX}" install \
&& rm -rf "$NEOFETCH_TEMP*" \
&& msg_yay "neofetch installed!"
}
main()
{
if ! command -v neofetch &> /dev/null; then
install_neofetch
elif [ "$NEOFETCH_VERSION" != "$(neofetch --version | awk '{print $2}')" ]; then
install_neofetch
else
msg_done "neofetch v.${NEOFETCH_VERSION} already installed"
fi
}
main "$@"

View File

@@ -2,8 +2,7 @@
# Install npm packages globally.
#
# shellcheck source=shared.sh
eval "$DOTFILES/config/shared.sh"
source "$DOTFILES/config/shared.sh"
# Enable verbosity with VERBOSE=1
VERBOSE="${VERBOSE:-0}"

View File

@@ -3,14 +3,14 @@
# Install ntfy
#
# shellcheck source=shared.sh
eval "$DOTFILES/config/shared.sh"
source "$DOTFILES/config/shared.sh"
# Enable verbosity with VERBOSE=1
VERBOSE="${VERBOSE:-0}"
# Check if ntfy is already installed
if x-have "ntfy"; then
msg "ntfy already installed"
msgr done "ntfy already installed"
exit 0
fi
@@ -23,7 +23,7 @@ case $(dfm check arch) in
NTFY_ARCH="macOS_all"
;;
*)
msg_err "Unsupported OS"
msgr err "Unsupported OS"
;;
esac
@@ -51,7 +51,7 @@ install_ntfy()
main()
{
install_ntfy
msg "ntfy installation complete"
msgr done "ntfy installation complete"
}
main "$@"

View File

@@ -1,33 +0,0 @@
#!/usr/bin/env bash
#
# Install oh-my-bash
#
# shellcheck source=shared.sh
source "${DOTFILES}/config/shared.sh"
set -euo pipefail
# Enable verbosity with VERBOSE=1
VERBOSE="${VERBOSE:-0}"
OSH="$HOME/.local/share/oh-my-bash"
# Function to install oh-my-bash
install_oh_my_bash()
{
if [ ! -d "$OSH" ]; then
[ -f "$HOME/.bashrc" ] && mv "$HOME/.bashrc" "$HOME/.bashrc.temp"
bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)" --unattended
[ -f "$HOME/.bashrc.temp" ] && mv "$HOME/.bashrc.temp" "$HOME/.bashrc"
msg "oh-my-bash installed to $OSH"
else
msg_done "oh-my-bash ($OSH) already installed"
fi
}
main()
{
install_oh_my_bash
}
main "$@"

View File

@@ -1,33 +0,0 @@
#!/usr/bin/env zsh
#
# Install oh-my-posh
#
# shellcheck source=shared.sh
source "${DOTFILES}/config/shared.sh"
# Enable verbosity with VERBOSE=1
VERBOSE="${VERBOSE:-0}"
msg "Starting to install oh-my-posh"
# Install oh-my-posh
install_oh_my_posh()
{
curl -s https://ohmyposh.dev/install.sh | bash -s -- -d ~/.local/bin
msg "oh-my-posh installed to ~/.local/bin"
}
# Initialize oh-my-posh
init_oh_my_posh()
{
eval "$(oh-my-posh init zsh --config $OHMYPOSH_CFG)"
msg "oh-my-posh initialized with config $OHMYPOSH_CFG"
}
main()
{
install_oh_my_posh
init_oh_my_posh
}
main "$@"

View File

@@ -2,20 +2,19 @@
# Install python/pip packages.
#
# shellcheck source=shared.sh
source "${DOTFILES}/config/shared.sh"
# Enable verbosity with VERBOSE=1
VERBOSE="${VERBOSE:-0}"
msg "Starting to install pip packages"
msgr run "Starting to install pip packages"
if ! command -v python3 &> /dev/null; then
msg_err "Could not find python3, something really weird is going on."
msgr err "Could not find python3, something really weird is going on."
exit 1
fi
msg_nested "Upgrading pip"
msgr nested "Upgrading pip"
python3 -m pip install --user --upgrade pip
packages=(
@@ -32,11 +31,11 @@ install_packages()
# Skip comments
if [[ ${pkg:0:1} == "#" ]]; then continue; fi
msg_nested "Installing pip package: $pkg"
msgr nested "Installing pip package: $pkg"
python3 -m pip install --user --upgrade "$pkg"
echo ""
done
}
install_packages
msg_yay "Run pip package installations"
msgr run_done "Run pip package installations"

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env bash
#
# Install XCode CLI Tools with osascript magic.
# Ismo Vuorinen <https://github.com/ivuorinen> 2018
#
@@ -9,13 +8,13 @@ VERBOSE="${VERBOSE:-0}"
# Check if the script is running on macOS
if [ "$(uname)" != "Darwin" ]; then
echo "Not a macOS system"
msgr warn "Not a macOS system"
exit 0
fi
# Check if xcode-select is available
if ! command -v xcode-select &> /dev/null; then
msg_err "xcode-select could not be found, skipping"
msgr err "xcode-select could not be found, skipping"
exit 0
fi
@@ -46,7 +45,7 @@ prompt_xcode_install()
if [ "$XCODE_MESSAGE" = "button returned:OK" ]; then
xcode-select --install
else
echo "You have cancelled the installation, please rerun the installer."
msgr warn "You have cancelled the installation, please rerun the installer."
exit 1
fi
}
@@ -57,7 +56,7 @@ main()
keep_alive_sudo
if [ -x "$XCODE_SWIFT_PATH" ]; then
echo "You have swift from xcode-select. Continuing..."
msgr run "You have swift from xcode-select. Continuing..."
else
prompt_xcode_install
fi

View File

@@ -1,5 +1,4 @@
#!/usr/bin/env bash
#
# Install z
#
# shellcheck source=shared.sh
@@ -16,9 +15,9 @@ clone_z_repo()
if [ ! -d "$bin_path" ]; then
git clone "$git_path" "$bin_path"
msg "z installed at $bin_path"
msgr run_done "z installed at $bin_path"
else
msg "z ($bin_path/) already installed"
msgr ok "z ($bin_path/) already installed"
fi
}

View File

@@ -1,17 +1,15 @@
#!/usr/bin/env bash
#
# set-macos-defaults.sh - Sets macOS Defaults that I like
# Sets macOS Defaults that I like
#
# This script contains large portions from following scripts:
# - https://github.com/freekmurze/dotfiles/blob/main/macos/set-defaults.sh
#
[ "$(uname)" != "Darwin" ] && echo "Not a macOS system" && exit 0
# shellcheck source=shared.sh
eval "$HOME/.dotfiles/config/shared.sh"
source "$HOME/.dotfiles/config/shared.sh"
msg_run "Starting to set macOS defaults, these require sudo privileges:"
msgr run "Starting to set macOS defaults, these require sudo privileges:"
# Ask for the administrator password upfront
sudo -v
@@ -24,7 +22,7 @@ while true; do
kill -0 "$$" || exit
done 2> /dev/null &
msg_nested "Change user shell to zsh if it is available and not the current"
msgr nested "Change user shell to zsh if it is available and not the current"
# Change user shell to zsh if not that already.
if hash zsh 2> /dev/null; then
@@ -35,7 +33,7 @@ fi
# General UI/UX #
###############################################################################
msg_nested "Setting General UI/UX settings"
msgr nested "Setting General UI/UX settings"
# Disable the sound effects on boot
sudo nvram SystemAudioVolume=" "
@@ -89,7 +87,7 @@ defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
# SSD-specific tweaks #
###############################################################################
msg_nested "Setting SSD-specific tweaks"
msgr nested "Setting SSD-specific tweaks"
# Disable hibernation (speeds up entering sleep mode)
sudo pmset -a hibernatemode 0
@@ -101,7 +99,7 @@ sudo pmset -a sms 0
# Trackpad, mouse, keyboard, Bluetooth accessories, and input #
###############################################################################
msg_nested "Settings for Trackpad, mouse, keyboard, Bluetooth accessories, and input"
msgr nested "Settings for Trackpad, mouse, keyboard, Bluetooth accessories, and input"
# Increase sound quality for Bluetooth headphones/headsets
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Max (editable)" 80
@@ -137,7 +135,7 @@ launchctl unload -w /System/Library/LaunchAgents/com.apple.rcd.plist 2> /dev/nul
# Screen #
###############################################################################
msg_nested "Settings for Screen"
msgr nested "Settings for Screen"
# Require password immediately after sleep or screen saver begins
defaults write com.apple.screensaver askForPassword -int 1
@@ -147,7 +145,7 @@ defaults write com.apple.screensaver askForPasswordDelay -int 0
# Finder #
###############################################################################
msg_nested "Settings for Finder"
msgr nested "Settings for Finder"
# Set Desktop as the default location for new Finder windows
# For other paths, use `PfLo` and `file:///full/path/here/`
@@ -207,7 +205,7 @@ defaults write com.apple.finder FXInfoPanesExpanded -dict \
# Screenshots #
###############################################################################
msg_nested "Settings for Screenshots"
msgr nested "Settings for Screenshots"
# Set default screenshot location
mkdir -p "$HOME/Documents/Screenshots"
@@ -223,7 +221,7 @@ defaults write com.apple.screencapture "name" -string "screenshot"
# Dock, Dashboard, and hot corners #
###############################################################################
msg_nested "Settings for Dock, Dashboard, and hot corners"
msgr nested "Settings for Dock, Dashboard, and hot corners"
# Prevent applications from bouncing in Dock
defaults write com.apple.dock no-bouncing -bool true
@@ -255,7 +253,7 @@ defaults write com.apple.dock showhidden -bool true
# Safari & WebKit #
###############################################################################
msg_nested "Settings for Safari & WebKit"
msgr nested "Settings for Safari & WebKit"
# Enable Safari's debug menu
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
@@ -281,7 +279,7 @@ defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
# Activity Monitor #
###############################################################################
msg_nested "Settings for ActivityMonitor"
msgr nested "Settings for ActivityMonitor"
# Show the main window when launching Activity Monitor
defaults write com.apple.ActivityMonitor OpenMainWindow -bool true
@@ -300,7 +298,7 @@ defaults write com.apple.ActivityMonitor SortDirection -int 0
# Address Book, Dashboard, iCal, TextEdit, and Disk Utility #
###############################################################################
msg_nested "Settings for Address Book, Dashboard, iCal, TextEdit, and Disk Utility"
msgr nested "Settings for Address Book, Dashboard, iCal, TextEdit, and Disk Utility"
# Use plain text mode for new TextEdit documents
defaults write com.apple.TextEdit RichText -int 0
@@ -313,7 +311,7 @@ defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4
# Messages #
###############################################################################
msg_nested "Settings for Messages"
msgr nested "Settings for Messages"
# Disable smart quotes as it's annoying for messages that contain code
defaults write com.apple.messageshelper.MessageController \
@@ -327,7 +325,7 @@ defaults write com.apple.messageshelper.MessageController \
-dict-add "continuousSpellCheckingEnabled" \
-bool false
msg_nested "Restarting applications to apply changes"
msgr nested "Restarting applications to apply changes"
###############################################################################
# Kill affected applications #

View File

@@ -1,19 +1,19 @@
#!/usr/bin/env bash
#
# Shared bash functions and helpers
# that can be sourced to other scripts.
# Shared bash functions and helpers.
# Helper env variables. Use like this: VERBOSE=1 ./script.sh
: "${VERBOSE:=0}"
# Set variable that checks if the shared.sh script has been sourced only once
# If the script has been sourced more than once, the script not be sourced again
# Set variable that checks if the shared.sh script has been
# sourced only once If the script has been sourced more than once,
# the script not be sourced again.
[ -z "$SHARED_SCRIPTS_SOURCED" ] && {
source "${DOTFILES}/config/shared.sh"
msgr warn "(!) shared.sh not sourced"
# Set variable that checks if the shared.sh script has been sourced only once
# Set variable that checks if the shared.sh script has been
# sourced only once.
# shellcheck disable=SC2034
export SHARED_SCRIPTS_SOURCED=1
}