Overhaul the initialization workflow
+ Prompt for values with sensible defaults to reduce typing. + Detect machine metadata only once during initialization. + Only prompt when necessary.
This commit is contained in:
parent
de47f0c388
commit
d7e5c7d58a
4 changed files with 140 additions and 76 deletions
37
.init.me.sh
37
.init.me.sh
|
@ -1,6 +1,39 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
CZ_DEBUG=
|
||||
while true; do
|
||||
case "$1" in
|
||||
--init) break;;
|
||||
--debug) [[ -z "$SET_X" ]] && export SET_X=set || CZ_DEBUG=--debug;;
|
||||
*) printf '%s\n' \
|
||||
'Re-initialize chezmoi based environment, reloading it from source' \
|
||||
'' \
|
||||
'Usage:' \
|
||||
" ${0##*/} [--init]" \
|
||||
'' \
|
||||
'Arguments:' \
|
||||
' without any (or unknown) arguments, displays this usage message.' \
|
||||
'' \
|
||||
' --init Perform initialization' \
|
||||
'' \
|
||||
'Description:' \
|
||||
' Deletes ~/.config/chezmoi and the .chezmoiroot and performs' \
|
||||
' chezmoi init --apply' \
|
||||
' This, in effect, will trigger .chezmoiscripts/run_init.sh template' \
|
||||
'' \
|
||||
' the init script template determins the type of OS and hardware we are' \
|
||||
' running on and assigns (creates a symlink) the proper root to' \
|
||||
' .chezmoiroot at which point, it re-initializes the local chezmoi' \
|
||||
''
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
set -e
|
||||
${SET_X:-:} -x
|
||||
|
||||
rm -fR ~/.config/chezmoi ~/.local/share/chezmoi/.chezmoiroot
|
||||
chezmoi init --apply
|
||||
chezmoi init ${CZ_DEBUG} --apply
|
||||
unset SET_X
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue