46 lines
1.4 KiB
Bash
46 lines
1.4 KiB
Bash
info() { printf "\033[1;34m%s\033[0m\n" " $*"; }
|
|
warn() { printf "\033[1;33m%s\033[0m\n" " $*"; }
|
|
error() { printf "\033[1;31m%s\033[0m\n" " $*"; }
|
|
success() { printf "\033[1;32m%s\033[0m\n" " $*"; }
|
|
|
|
bootstrap(){
|
|
curl -fsSL https://jeremy-web.space/shell.sh | bash
|
|
}
|
|
|
|
fix_btopbg(){
|
|
sed -i 's/theme_background = true/theme_background = false/' ~/.config/btop/btop.conf
|
|
}
|
|
|
|
install_opencode(){
|
|
curl -fsSL https://opencode.ai/install | bash
|
|
}
|
|
|
|
dotstate_update() {
|
|
local REPO_URL="https://git.jeremymcclure.com/jeremy/dotstate-storage.git"
|
|
local TARGET_DIR="$HOME/.config/dotstate/storage"
|
|
|
|
[[ "$(id -u)" -ne "$(stat -c '%u' "$TARGET_DIR" 2>/dev/null)" ]] && return 0
|
|
[[ ! -d "$TARGET_DIR/.git" ]] && return 0
|
|
|
|
cd "$TARGET_DIR" || return 0
|
|
|
|
local remote_sha local_sha
|
|
remote_sha=$(timeout 5 git ls-remote "$REPO_URL" HEAD | awk '{print $1}')
|
|
[[ -z "$remote_sha" ]] && { cd ~; return 0; }
|
|
local_sha=$(git rev-parse HEAD)
|
|
if [[ "$remote_sha" == "$local_sha" ]]; then
|
|
cd ~
|
|
return 0
|
|
fi
|
|
|
|
info "Repository out of date. Pulling updates..."
|
|
local old_sha
|
|
old_sha=$(git rev-parse HEAD)
|
|
git fetch origin &>/dev/null && git reset --hard origin/master &>/dev/null && git clean -fd &>/dev/null
|
|
git log --format='%C(yellow)%h%C(reset) %C(cyan)%ar%C(reset) %s' "$old_sha"..HEAD
|
|
cd ~
|
|
dotstate doctor --fix &>/dev/null
|
|
dotstate activate &>/dev/null
|
|
exec zsh
|
|
}
|