Multiple scripts, go packages, shared configs...

Documentation, links, renaming files for clarity, and all that.
This commit is contained in:
Ismo Vuorinen
2022-12-19 17:19:00 +02:00
parent 7921e079da
commit a708085dda
19 changed files with 964 additions and 36 deletions

View File

@@ -1,8 +1,10 @@
#!/usr/bin/env bash
# Install GitHub CLI extensions
source "$HOME/.dotfiles/scripts/shared.sh"
if ! command -v gh &> /dev/null; then
echo "gh (GitHub Client) could not be found, please install it first"
msg_run "gh (GitHub Client) could not be found, please install it first"
exit 1
fi
@@ -35,10 +37,17 @@ extensions=(
stoe/gh-report
)
msg "Starting to install GitHub CLI extensions..."
for ext in "${extensions[@]}"; do
# Trim spaces
ext=${ext// /}
# Skip comments
if [[ ${ext:0:1} == "#" ]]; then continue; fi
echo "-> Installing $ext"
msg_run "Installing $ext"
gh extensions install "$ext"
echo ""
done
msg_ok "Done"

View File

@@ -0,0 +1,27 @@
#!/usr/bin/env zsh
# Install Go packages
source "$HOME/.dotfiles/scripts/shared.sh"
if ! command -v go &> /dev/null; then
msg "go hasn't been installed yet."
exit 0
fi
packages=(
# sysadmin/scripting utilities, distributed as a single binary
github.com/skx/sysbox@latest
)
for pkg in "${packages[@]}"; do
# Trim spaces
pkg=${pkg// /}
# Skip comments
if [[ ${pkg:0:1} == "#" ]]; then continue; fi
msg_run "Installing go package:" "$pkg"
go install "$pkg"
echo ""
done
msg_ok "Done"

View File

@@ -79,9 +79,16 @@ handle_file_ln "$HOME/.dotfiles/git_profiles" "$HOME/.git_profiles"
handle_file_ln "$HOME/.dotfiles/huskyrc" "$HOME/.huskyrc"
handle_file_ln "$HOME/.dotfiles/local/bin/antigen.zsh" "$HOME/.local/bin/antigen.zsh"
handle_file_ln "$HOME/.dotfiles/local/bin/dfm" "$HOME/.local/bin/dfm"
handle_file_ln "$HOME/.dotfiles/local/bin/foreach" "$HOME/.local/bin/foreach"
handle_file_ln "$HOME/.dotfiles/local/bin/x-check-git-attributes" "$HOME/.local/bin/x-check-git-attributes"
handle_file_ln "$HOME/.dotfiles/local/bin/x-dupes" "$HOME/.local/bin/x-dupes"
handle_file_ln "$HOME/.dotfiles/local/bin/x-foreach" "$HOME/.local/bin/x-foreach"
handle_file_ln "$HOME/.dotfiles/local/bin/x-multi-ping" "$HOME/.local/bin/x-multi-ping"
handle_file_ln "$HOME/.dotfiles/local/bin/x-open-ports" "$HOME/.local/bin/x-open-ports"
handle_file_ln "$HOME/.dotfiles/local/bin/x-ssl-expiry-date" "$HOME/.local/bin/x-ssl-expiry-date"
handle_file_ln "$HOME/.dotfiles/local/bin/x-until-error" "$HOME/.local/bin/x-until-error"
handle_file_ln "$HOME/.dotfiles/local/bin/x-until-success" "$HOME/.local/bin/x-until-success"
handle_file_ln "$HOME/.dotfiles/local/bin/x-when-down" "$HOME/.local/bin/x-when-down"
handle_file_ln "$HOME/.dotfiles/local/bin/x-when-up" "$HOME/.local/bin/x-when-up"
handle_file_ln "$HOME/.dotfiles/rcrc" "$HOME/.rcrc"
handle_file_ln "$HOME/.dotfiles/ssh/allowed_signers" "$HOME/.ssh/allowed_signers"
handle_file_ln "$HOME/.dotfiles/ssh/config" "$HOME/.ssh/config"

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# set-defaults.sh - Sets macOS Defaults that I like
# set-macos-defaults.sh - 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

88
scripts/shared.sh Normal file
View File

@@ -0,0 +1,88 @@
#!/usr/bin/env bash
#
# Shared bash functions and helpers
# that can be sourced to other scripts.
#
# -- Colors -- #
CLR_RED="\033[1;31m"
CLR_YELLOW='\033[1;33m'
CLR_GREEN="\033[1;32m"
CLR_BLUE='\033[1;34m'
CLR_RESET="\033[0m"
# -- Helpers -- #
function __log_marker() {
echo -e "${CLR_BLUE}${CLR_RESET}"
}
function __log_marker_ok() {
echo -e "${CLR_GREEN}${CLR_RESET}"
}
function __log_marker_ok_blue() {
echo -e "${CLR_BLUE}${CLR_RESET}"
}
function __log_marker_warn() {
echo -e "${CLR_YELLOW}${CLR_RESET}"
}
function __log_marker_err() {
echo -e "${CLR_RED}${CLR_RESET}"
}
function __log_indent() {
echo " "
}
# -- Log -- #
function msg() {
echo -e "$(__log_marker) $1"
}
function msg_done() {
echo -e "$(__log_marker) $1 ...$(__log_marker_ok)"
}
function msg_prompt() {
echo -e "$(__log_marker) $1"
}
function msg_prompt_done() {
echo -e "$(__log_marker) $1 ...$(__log_marker_ok)"
}
function msg_nested() {
echo -e "$(__log_indent)$(__log_marker) $1"
}
function msg_nested_done() {
echo -e "$(__log_indent)$(__log_marker) $1 ...$(__log_marker_ok)"
}
function msg_run() {
echo -e "${CLR_GREEN}$1${CLR_RESET} $2"
}
function msg_ok() {
echo -e "$(__log_marker_ok) $1"
}
function msg_warn() {
echo -e "$(__log_marker_warn) $1"
}
function msg_err() {
echo -e "$(__log_marker_err) $1"
}
# -- Menu builder -- #
function menu_section() {
LINE=$(printf '%-18s [ %-15s ]\n' "$1" "$2")
echo -e " $(__log_marker) $LINE"
}
function menu_item() {
LINE=$(printf '%-15s %-30s\n' "$1" "$2")
echo -e "$(__log_indent)$(__log_marker) $LINE"
}