60 lines
2.2 KiB
Bash
60 lines
2.2 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" " $*"; }
|
|
|
|
dotstate-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
|
|
}
|
|
whence opencode >/dev/null >/dev/null && unset -f install-opencode
|
|
|
|
install-omp(){
|
|
curl -fsSL https://omp.sh/install | sh
|
|
}
|
|
whence omp >/dev/null && unset -f install-omp
|
|
|
|
dotstate-update() {
|
|
local TARGET_DIR="$HOME/.config/dotstate/storage"
|
|
local REPO_URL="$(git -C "$TARGET_DIR" remote get-url origin)"
|
|
|
|
[[ "$(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)
|
|
local has_changes=false
|
|
[[ -n "$(git status --porcelain)" ]] && has_changes=true
|
|
if [[ "$remote_sha" == "$local_sha" && "$has_changes" == "false" ]]; then
|
|
cd ~
|
|
return 0
|
|
fi
|
|
|
|
warn "Dotfiles out of date. Updating..."
|
|
printf "\033[1;34m────────────────────────────────────────────────────\033[0m\n"
|
|
git fetch origin &>/dev/null && git reset --hard origin/master &>/dev/null && git clean -fd &>/dev/null
|
|
git log -5 --format='%C(yellow)%h%C(reset) %C(cyan)%ar%C(reset) %s'
|
|
printf "\033[1;34m────────────────────────────────────────────────────\033[0m\n"
|
|
cd ~
|
|
dotstate doctor --fix &>/dev/null
|
|
dotstate activate &>/dev/null
|
|
info "Use \"dotstate-logs\" to view what was changed"
|
|
[[ $USER == "savannah" ]] && info "Because we both know you have a log fetish ❤️"
|
|
exec zsh
|
|
}
|
|
|
|
dotstate-logs(){
|
|
lazygit -p $HOME/.config/dotstate/storage
|
|
}
|