dotfiles.2022/_home/dot_sz.shrc.d/97_chezmoi_aliases
Gal Szkolnik d6687d8fa4 Single repo + chezmoi status in oh-my-posh prompt
Oh-My-Posh prompt displaying chezmoi status when changes are in working
copy (home dir) and/or uncommitted changes in the source path.

Externals manages as a separate chezmoi source in a subdir of the source
repo.
2022-09-26 18:39:41 -04:00

48 lines
1.3 KiB
Text

if [[ -n "$(which-command chezmoi)" ]]; then
export CHEZMOIROOT="$(chezmoi source-path)"
export CZ="$CHEZMOIROOT/_home"
export CZ_X="$CHEZMOIROOT/_externals"
alias czcd="cd $CZ"
alias czxcd="cd $CZ_X"
alias cz="chezmoi "
alias czx="chezmoi --source $CZ_X --config $HOME/.config/chezmoi/chezmoi.externals.toml "
alias czs="cz status "
alias cz-refresh="czs | cut -d\ -f2 | grep '^\.sz\.shrc\.d' | xargs cz forget --force; cz add ~/.sz.shrc.d --recursive; cz status; cz git status"
alias cz-commit="cz git -- commit -a "
function cz() {
chezmoi "${@}"
}
function cz-remove-missing() {
pushd ~ > /dev/null
changes=$(cz status | sed -n 's/^DA[ \t]\+//p')
for c in $changes; do
cz rm $c
done
popd > /dev/null
}
function cz-add-changes() {
pushd ~ > /dev/null
changes=$(cz status | sed -n 's/^MM[ \t]\+//p')
for c in $changes; do
echo Adding $c
cz add $c
done
popd > /dev/null
}
function cz-set-ssh-github() {
cz git -- remote set-url origin "$(cz git -- remote get-url origin | sed 's|https://github.com/|git@github.com:|')"
cz git -- remote get-url origin
}
function cz-set-https-github() {
cz git -- remote set-url origin "$(cz git -- remote get-url origin | sed 's|git@github.com:|https://github.com/|')"
cz git -- remote get-url origin
}
fi