Added modiciation from a parallel project
This commit is contained in:
parent
e14d5f3566
commit
278be5a6c6
24 changed files with 492 additions and 143 deletions
|
@ -1,3 +1,8 @@
|
|||
if [[ -z "$(which-command chezmoi)" && -x "$HOME/bin/chezmoi" ]]; then
|
||||
function chezmoi() {
|
||||
"$HOME/bin/chezmoi" "${@}"
|
||||
}
|
||||
fi
|
||||
if [[ -n "$(which-command chezmoi)" ]]; then
|
||||
export CHEZMOIROOT="$(chezmoi source-path)"
|
||||
export CZ="$CHEZMOIROOT"
|
||||
|
@ -5,25 +10,65 @@ if [[ -n "$(which-command chezmoi)" ]]; then
|
|||
|
||||
alias czcd="cd $CZ"
|
||||
alias czxcd="cd $CZ_X"
|
||||
alias czx-edit="edit $CZ_X/.chezmoiexternal.*"
|
||||
|
||||
function cz() { chezmoi "${@}"; }
|
||||
function czx() {
|
||||
chezmoi --source $CZ_X --config $HOME/.config/chezmoi.externals/config.toml "${@}"
|
||||
}
|
||||
|
||||
alias czs="cz status "
|
||||
function czg() {
|
||||
cz git -- "${@}"
|
||||
}
|
||||
#alias czg="cz git -- "
|
||||
alias czgs="cz git -- status "
|
||||
alias czs="cz status --exclude scripts "
|
||||
|
||||
CZG_ROOT="$(cz git -- rev-parse --show-toplevel)"
|
||||
alias czg="git --work-tree=$CZG_ROOT --git-dir=$CZG_ROOT/.git "
|
||||
unset CZG_ROOT
|
||||
|
||||
alias czgs="czg status "
|
||||
alias czgca="czg add --all && czg commit "
|
||||
alias cza="cz apply && exec $SHELL"
|
||||
alias czu="cz upgrade && cz update && exec $SHELL "
|
||||
alias czxu="cz upgrade && cz update && czx apply && exec $SHELL "
|
||||
alias czxa="czx apply && exec $SHELL "
|
||||
|
||||
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"
|
||||
function cz-refresh() {
|
||||
local _tmp
|
||||
_tmp=$(chezmoi status --exclude scripts)
|
||||
if [[ -n "$_tmp" ]]; then
|
||||
echo "Adding modified files..."
|
||||
cz re-add
|
||||
else
|
||||
echo "No modified files found."
|
||||
fi
|
||||
|
||||
_tmp=$(chezmoi unmanaged | grep "^${SFP/\./\\.}\.shrc\.d/" | while read u; do
|
||||
printf "'$HOME/$u' "
|
||||
done)
|
||||
[[ -n "$(echo $_tmp | xargs)" ]] \
|
||||
&& echo "Adding new files..." \
|
||||
&& eval "chezmoi add --prompt $_tmp"
|
||||
}
|
||||
|
||||
alias cz-commit="cz git -- commit -a "
|
||||
|
||||
function cz-get-data() {
|
||||
chezmoi data --format json | jq -r ".${@:-${SFP#*.}}"
|
||||
}
|
||||
function cz-import-data() {
|
||||
# Use this with eval: eval $(cz-import-data)
|
||||
local tmp_SFP=${SFP^^}
|
||||
tmp_SFP=${tmp_SFP#*.}
|
||||
local UPPERCASE='|ascii_upcase'
|
||||
local PREFIX="CZ_${tmp_SFP}_DATA_"
|
||||
[[ "$1" == "promptString" ]] && unset UPPERCASE PREFIX
|
||||
local RESULTS=$(cz-get-data | jq -r "to_entries[] | \"$PREFIX\(.key${UPPERCASE})=\\\"\(.value)\\\"\"")
|
||||
if [[ "$1" == "promptString" ]] ; then
|
||||
printf "$RESULTS" | tr '\n' ',' | sed 's/"//g; s/^\(.*\),$/"\1/g;'
|
||||
#printf "$RESULTS" | tr '\n' ',' | sed 's/="/=/g; s/^\(.*\),$/"\1/g; s/,/,"/g;'
|
||||
else
|
||||
echo "$RESULTS"
|
||||
fi
|
||||
}
|
||||
|
||||
function cz-remove-missing() {
|
||||
pushd ~ > /dev/null
|
||||
changes=$(cz status | sed -n 's/^DA[ \t]\+//p')
|
||||
|
@ -33,16 +78,6 @@ if [[ -n "$(which-command chezmoi)" ]]; then
|
|||
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 \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue