dotfiles/chezmoi.roots/_home/private_dot_config/sz.env/981_chezmoi.env.tmpl

59 lines
2.2 KiB
Cheetah
Raw Normal View History

2024-09-19 04:31:48 +00:00
#!/usr/bin/env -S bash -c 'echo "Not a user script. source(aka .) only"'
# shellcheck disable=SC1090
if is_cmd 'chezmoi'; then
alias cz="chezmoi "
alias ll-cz='ll --color=always | grep -v remove_ '
2024-09-19 04:31:48 +00:00
eval "$( chezmoi completion "${SHELL##*/}" | sed -Ee 's/(complete -o default .* chezmoi)/\1 cz/' )"
export CHEZMOI_GITHUB_ACCESS_TOKEN={{- .githubToken | quote }}
CZG_ROOT="$(chezmoi git -- rev-parse --show-toplevel)"
alias czg="git --work-tree=$CZG_ROOT --git-dir=$CZG_ROOT/.git "
unset CZG_ROOT
complete -F _complete_alias czg
chezmoi() {
${SET_X:-:} -x
case "$1" in
cd) cz-cd "${2}" ;;
edit) ${VISUAL:-${EDITOR:-vi}} $(SET_X=':' chezmoi source-path "${@:2}") ;;
# source-path) printf '%s\n' "${@:2}" | xargs -r env chezmoi source-path ;;
*) env chezmoi "${@}" ;;
esac
${SET_X:-:} +x
2024-09-19 04:31:48 +00:00
}
cz-cd() { cd "$(chezmoi source-path ${1})"; }
2025-04-17 22:22:07 +00:00
czgcd() {
cd "$(SET_X=':' chezmoi git -- rev-parse --show-toplevel)${1:+/${1}}"
2025-04-17 22:22:07 +00:00
}
2025-03-17 20:31:01 +00:00
czedext() {
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}"
2025-03-17 20:31:01 +00:00
"${VISUAL:-${EDITOR:-vi}}" "${CZ_EXT}"
}
2025-03-17 21:43:04 +00:00
czed() {
2025-04-02 16:32:53 +00:00
local EDITLIST=() f _f
for _f in "${@}"; do
[[ -e "$_f" ]] || f="$(which "$_f")"
[[ -z "$f" ]] && is_cmd tv && f="$(tv "$_f")" || f=$_f
EDITLIST=( "${EDITLIST[@]}" "$f" )
done
EDITLIST=("${@}")
chezmoi edit "${EDITLIST[@]}" --apply --interactive
2025-03-17 21:43:04 +00:00
}
# 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.
2025-04-02 16:32:53 +00:00
alias czx="CZ_EXTR=1 chezmoi "
alias czu="czg pull && cz init --verbose && cz apply --verbose && _r"
alias czxu="cz upgrade && czg pull && cz init --verbose && czx apply --verbose && _r"
2025-04-30 16:36:12 +00:00
alias cz-reset-home="(czgcd && cd chezmoi.roots && RESET=reset SRC_DIR=_src.all ./symclone.sh _home && RESET=reset ./symclone.sh _home.macos)"
2024-09-19 04:31:48 +00:00
fi
2025-03-17 20:31:01 +00:00
2025-04-17 19:50:23 +00:00
# vim: set ft=sh sw=4 sts=4 et: