From 58c86a7e81569e61c675017badd183a18aa79b83 Mon Sep 17 00:00:00 2001 From: "Lockszmith (wsl@Sygin)" Date: Wed, 9 Apr 2025 20:50:05 -0400 Subject: [PATCH] implement an old chezmoi cd idea of mine --- .../private_dot_config/sz.env/zzz_chezmoi.env.tmpl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/_src.posix/private_dot_config/sz.env/zzz_chezmoi.env.tmpl b/_src.posix/private_dot_config/sz.env/zzz_chezmoi.env.tmpl index 0e5ce42..aed37de 100644 --- a/_src.posix/private_dot_config/sz.env/zzz_chezmoi.env.tmpl +++ b/_src.posix/private_dot_config/sz.env/zzz_chezmoi.env.tmpl @@ -13,9 +13,18 @@ if is_cmd 'chezmoi'; then complete -F _complete_alias czg - czcd() { - cd "$(chezmoi source-path "${@}")" + chezmoi() { + ${SET_X:-:} -x + local _args=() + [ $# -ge 2 ] && _args=("${@:2}") + case "$1" in + "cd") cd "$(command chezmoi source-path "${_args[@]}")" ;; + "edit") ${VISUAL:-${EDITOR:-vi}} $(command chezmoi sourch-path "${_args[@]}") ;; + *) command chezmoi "${@}" ;; + esac + ${SET_X:-:} +x } + czcd() { chezmoi cd "${@}"; } czedext() { local CZ_EXT="$(find $(chezmoi source-path) -mindepth 1 -maxdepth 1 -name '.chezmoiexternal.*')" CZ_EXT="${CZ_EXT:-$(chezmoi source-path "${@}")/.chezmoiexternal.yaml.tmpl}"