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 "
|
|
|
|
eval "$( chezmoi completion "${SHELL##*/}" | sed -Ee 's/(complete -o default .* chezmoi)/\1 cz/' )"
|
|
|
|
|
2025-03-10 20:53:00 +00:00
|
|
|
export CHEZMOI_GITHUB_ACCESS_TOKEN={{- .githubToken | quote }}
|
|
|
|
|
2025-04-09 20:28:02 +00:00
|
|
|
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
|
|
|
|
|
2025-04-10 00:50:05 +00:00
|
|
|
chezmoi() {
|
|
|
|
${SET_X:-:} -x
|
|
|
|
case "$1" in
|
2025-04-10 15:16:55 +00:00
|
|
|
cd) cd "$(SET_X=':' command chezmoi source-path ${2})" ;;
|
|
|
|
edit) ${VISUAL:-${EDITOR:-vi}} $(SET_X=':' chezmoi source-path "${@:2}") ;;
|
|
|
|
source-path) printf '%s\n' "${@:2}" | xargs -r chezmoi source-path ;;
|
2025-04-10 00:50:05 +00:00
|
|
|
*) command chezmoi "${@}" ;;
|
|
|
|
esac
|
|
|
|
${SET_X:-:} +x
|
2024-09-19 04:31:48 +00:00
|
|
|
}
|
2025-04-10 00:50:05 +00:00
|
|
|
czcd() { chezmoi cd "${@}"; }
|
2025-03-17 20:31:01 +00:00
|
|
|
czedext() {
|
2025-04-10 16:27:16 +00:00
|
|
|
local CZ_EXT="$(find $(command chezmoi source-path) -mindepth 1 -maxdepth 1 -name '.chezmoiexternal.*')"
|
2025-03-17 20:31:01 +00:00
|
|
|
CZ_EXT="${CZ_EXT:-$(chezmoi source-path "${@}")/.chezmoiexternal.yaml.tmpl}"
|
|
|
|
"${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
|
|
|
}
|
2025-04-02 16:32:53 +00:00
|
|
|
alias czx="CZ_EXTR=1 chezmoi "
|
2024-09-19 04:31:48 +00:00
|
|
|
fi
|
2025-03-17 20:31:01 +00:00
|
|
|
|
|
|
|
# vim: set ft=bash sw=4 sts=4 et:
|