dotfiles/_src.posix/private_dot_config/sz.env/zzz_chezmoi.env.tmpl

32 lines
1.0 KiB
Bash

#!/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 "
eval "$( chezmoi completion "${SHELL##*/}" | sed -Ee 's/(complete -o default .* chezmoi)/\1 cz/' )"
export CHEZMOI_GITHUB_ACCESS_TOKEN={{- .githubToken | quote }}
czcd() {
cd "$(chezmoi source-path "${@}")"
}
czedext() {
local CZ_EXT="$(find $(chezmoi source-path) -mindepth 1 -maxdepth 1 -name '.chezmoiexternal.*')"
CZ_EXT="${CZ_EXT:-$(chezmoi source-path "${@}")/.chezmoiexternal.yaml.tmpl}"
"${VISUAL:-${EDITOR:-vi}}" "${CZ_EXT}"
}
czed() {
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
}
alias czx="CZ_EXTR=1 chezmoi "
fi
# vim: set ft=bash sw=4 sts=4 et: