chezmoi alias cosmetic fixes / cleaner syntax

This commit is contained in:
Lockszmith (VAST@MacBook) 2025-04-23 14:45:14 -04:00
parent 88a7aba840
commit e4cfff9fcc
1 changed files with 15 additions and 8 deletions

View File

@ -18,20 +18,20 @@ if is_cmd 'chezmoi'; then
chezmoi() {
${SET_X:-:} -x
case "$1" in
cd) cd "$(SET_X=':' command chezmoi source-path ${2})" ;;
cd) cz-cd "${2}" ;;
edit) ${VISUAL:-${EDITOR:-vi}} $(SET_X=':' chezmoi source-path "${@:2}") ;;
source-path) printf '%s\n' "${@:2}" | xargs -r chezmoi source-path ;;
*) command chezmoi "${@}" ;;
# source-path) printf '%s\n' "${@:2}" | xargs -r env chezmoi source-path ;;
*) env chezmoi "${@}" ;;
esac
${SET_X:-:} +x
}
czcd() { chezmoi cd "${@}"; }
cz-cd() { cd "$(chezmoi source-path ${1})"; }
czgcd() {
cd "$(chezmoi git -- rev-parse --show-toplevel)${1:+/${1}}"
cd "$(SET_X=':' chezmoi git -- rev-parse --show-toplevel)${1:+/${1}}"
}
czedext() {
local CZ_EXT="$(find $(command chezmoi source-path) -mindepth 1 -maxdepth 1 -name '.chezmoiexternal.*')"
CZ_EXT="${CZ_EXT:-$(chezmoi source-path "${@}")/.chezmoiexternal.yaml.tmpl}"
local CZ_EXT="$(find $(SET_X=':' chezmoi source-path) -mindepth 1 -maxdepth 1 -name '.chezmoiexternal.*')"
CZ_EXT="${CZ_EXT:-$(SET_X=':' chezmoi source-path "${@}")/.chezmoiexternal.yaml.tmpl}"
"${VISUAL:-${EDITOR:-vi}}" "${CZ_EXT}"
}
czed() {
@ -44,8 +44,15 @@ if is_cmd 'chezmoi'; then
EDITLIST=("${@}")
chezmoi edit "${EDITLIST[@]}" --apply --interactive
}
# CZ_EXTR is evaluated in .chezmoiexternal.yaml.
# By default, a very small portion of the externals are being
# evaluated, when CZ_EXTR is set to 1, full evaluation of the
# externals yaml is performed.
alias czx="CZ_EXTR=1 chezmoi "
alias cz-reset-home="(czcd; cd ..; RESET=reset SRC_DIR=_src.all ./symclone _home; RESET=reset ./symclone.sh _home.macos)"
alias czu="czg pull && cz init --verbose && cz apply --verbose && _r"
alias czxu="cz upgrade && czg pull && cz init --verbose && czx apply --verbose && _r"
alias cz-reset-home="(czgcd && cd chezmoi.roots && RESET=reset SRC_DIR=_src.all ./symclone _home && RESET=reset ./symclone.sh _home.macos)"
fi
# vim: set ft=sh sw=4 sts=4 et: