czu improvements

fix: shell will actually restart
fix: apply will only run once
change: externals will be applied before cz apply
This commit is contained in:
Gal Szkolnik 2025-08-05 15:00:13 +00:00
parent ff4d5fd7bc
commit 27e2ede303

View file

@ -59,6 +59,7 @@ if is_cmd 'chezmoi'; then
'--no-refresh') refresh=0 ;;
'--quiet') verbose='' ;;
'--debug') debug='--debug' ;;
'--help') echo '--all| --prompt | --no-refresh | --quiet | --debug | --help'; return 1;;
esac
shift
done
@ -67,17 +68,19 @@ if is_cmd 'chezmoi'; then
fi
chezmoi git -- pull --autostash --rebase \
&& chezmoi init $prompts $verbose $debug \
&& chezmoi status $verbose $debug \
&& chezmoi apply --interactive --verbose $verbose $debug
&& chezmoi status $verbose $debug
if [[ $all -eq 1 ]]; then
CZ_EXTR=1
CZ_EZA_PREFIX=""
chezmoi status $verbose $debug \
|| (CZ_EZA_PREFIX='./' && chezmoi status $verbose $debug ) && chezmoi apply $verbose $debug
chezmoi status --include externals $verbose $debug \
|| (CZ_EZA_PREFIX='./' && chezmoi status --include externals $verbose $debug ) && chezmoi apply --include externals $verbose $debug
unset CZ_EXTR
fi
[[ $refresh -ne 1 ]] || (printf "restarting shell...\n" >&2 || exec $SHELL -l)
chezmoi apply --interactive --verbose $verbose $debug
[[ $refresh -ne 1 ]] || (printf "restarting shell...\n" >&2 && false ) || exec $SHELL -l
}
alias czxu="cz upgrade && czg pull && cz init --verbose && czx apply --verbose && _r"