From e923be3f0b1b45286986f0a0a0e13f044d5e2296 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 2 Aug 2025 22:07:42 +0200 Subject: [PATCH] Split omarchy-migrate into its own command So it can be updated independently and apply quicker --- bin/omarchy-migrate | 26 ++++++++++++++++++++++++++ bin/omarchy-update | 28 ++++++---------------------- 2 files changed, 32 insertions(+), 22 deletions(-) create mode 100755 bin/omarchy-migrate diff --git a/bin/omarchy-migrate b/bin/omarchy-migrate new file mode 100755 index 0000000..f547570 --- /dev/null +++ b/bin/omarchy-migrate @@ -0,0 +1,26 @@ +#!/bin/bash + +# Exit immediately if a command exits with a non-zero status +set -e + +# Create the migrations state directory, we will store an empty file for each migration that has already been performed. +STATE_DIR="$HOME/.local/state/omarchy/migrations" +mkdir -p "$STATE_DIR" + +# Run any pending migrations +cd ~/.local/share/omarchy + +for file in migrations/*.sh; do + filename=$(basename "$file") + migrate_at="${filename%.sh}" + + # Migration already applied, to re-run it simply delete the state file and try again + [ -e "${STATE_DIR}/$filename" ] && continue + + echo -e "\e[32m\nRunning migration (${filename%.sh})\e[0m" + source $file + touch "${STATE_DIR}/$filename" +done + +# Back to where we came from +cd - >/dev/null diff --git a/bin/omarchy-update b/bin/omarchy-update index 61cbf4b..b76e54c 100755 --- a/bin/omarchy-update +++ b/bin/omarchy-update @@ -3,30 +3,17 @@ # Exit immediately if a command exits with a non-zero status set -e +# Show logo clear cat <~/.local/share/omarchy/logo.txt -cd ~/.local/share/omarchy - -# Create the migrations state directory, we will store an empty file for each migration that has already been performed. -STATE_DIR="$HOME/.local/state/omarchy/migrations" -mkdir -p "$STATE_DIR" # Get the latest while trying to preserve any modifications -git pull --autostash -git diff --check || git reset --merge +omarchy_path=~/.local/share/omarchy +git -C $omarchy_path pull --autostash +git -C $omarchy_path diff --check || git -C $omarchy_path reset --merge -# Run any pending migrations -for file in migrations/*.sh; do - filename=$(basename "$file") - migrate_at="${filename%.sh}" - - # Migration already applied, to re-run it simply delete the state file and try again - [ -e "${STATE_DIR}/$filename" ] && continue - - echo -e "\e[32m\nRunning migration (${filename%.sh})\e[0m" - source $file - touch "${STATE_DIR}/$filename" -done +# Run migrations +"$HOME/.local/share/omarchy/bin/omarchy-migrate" # Update system packages echo -e "\e[32m\nUpdate system packages\e[0m" @@ -36,6 +23,3 @@ yay -Syu --noconfirm if [ "$(uname -r | sed 's/-arch/\.arch/')" != "$(pacman -Q linux | awk '{print $2}')" ]; then gum confirm "Linux kernel has been updated. Reboot?" && sudo reboot now fi - -# Back to where we came from -cd - >/dev/null