Add gitcd (and czgcd) functions

This commit is contained in:
Lockszmith (VAST@MacBook) 2025-04-17 18:22:07 -04:00
parent 66ffbc9098
commit a546290cf6
2 changed files with 9 additions and 0 deletions

View File

@ -24,6 +24,9 @@ if is_cmd 'chezmoi'; then
${SET_X:-:} +x ${SET_X:-:} +x
} }
czcd() { chezmoi cd "${@}"; } czcd() { chezmoi cd "${@}"; }
czgcd() {
cd "$(chezmoi git -- rev-parse --show-toplevel)${1:+/${1}}"
}
czedext() { czedext() {
local CZ_EXT="$(find $(command chezmoi source-path) -mindepth 1 -maxdepth 1 -name '.chezmoiexternal.*')" local CZ_EXT="$(find $(command chezmoi source-path) -mindepth 1 -maxdepth 1 -name '.chezmoiexternal.*')"
CZ_EXT="${CZ_EXT:-$(chezmoi source-path "${@}")/.chezmoiexternal.yaml.tmpl}" CZ_EXT="${CZ_EXT:-$(chezmoi source-path "${@}")/.chezmoiexternal.yaml.tmpl}"

View File

@ -35,5 +35,11 @@ alias vim='nvim '
alias nvimdiff='nvim -d ' alias nvimdiff='nvim -d '
alias vimdiff='nvimdiff ' alias vimdiff='nvimdiff '
if is_cmd git; then
gitcd() {
cd "$(git rev-parse --show-toplevel)${1:+/${1}}"
}
fi
# vim: set ft=sh expandtab tabstop=4 shiftwidth=4: # vim: set ft=sh expandtab tabstop=4 shiftwidth=4: