Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions home/dot_gitconfig.tmpl → home/.gitconfig.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,26 @@ caa = commit --amend --all
caane = commit --amend --all --no-edit
cob = checkout -b

apply-gitignore = "!f() { \
apply-gitignore = !f() { \
set -ex; \
git rm -r --cached . >/dev/null; \
git add .; \
};f"
};f

remote-for-branch = "!f() { \
remote-for-branch = !f() { \
set -ex; \
branch="${1:-"$(git current-branch)"}"; \
git rev-parse --abbrev-ref --symbolic-full-name "${branch}@{upstream}" | sed -n 's,^\\(\\S*\\)/'"${branch}"'$,\\1,p' | grep .; \
};f"
git rev-parse --abbrev-ref --symbolic-full-name "${branch}@{upstream}" | sed -n 's,^\(\S*\)/'"${branch}"'$,\1,p' | grep .; \
};f

rr = "!f() { \
rr = !f() { \
set -ex; \
branch="${1:-"$(git current-branch)"}"; \
remote="$(git remote-for-branch "${branch}")"; \
git reset --hard "${remote}/${branch}"; \
};f"
};f

pfor = "!f() { \
pfor = !f() { \
set -ex; \
if echo "${1}" | grep -q %; then \
branch="$(echo "${1}" | cut -d'%' -f1)"; \
Expand All @@ -70,15 +70,15 @@ pfor = "!f() { \
push_opts="${push_opts:+"%${push_opts}"}"; \
remote="$(git remote-for-branch "${branch}")"; \
git push "${remote}" "HEAD:refs/for/${branch}${push_opts}"; \
};f"
};f

psfor = "!f() { \
psfor = !f() { \
set -ex; \
git caane; \
git pfor "$@"; \
};f"
};f

cptob = "!f() { \
cptob = !f() { \
set -ex; \
commit="${1}"; \
shift; \
Expand All @@ -97,4 +97,4 @@ cptob = "!f() { \
git cp "${commit}"; \
git pfor "${branch}${push_opts}"; \
done; \
};f"
};f
13 changes: 13 additions & 0 deletions home/modify_dot_gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- /* chezmoi:modify-template */ -}}

{{- /* Load existing configuration */ -}}
{{- $result := dict -}}
{{- if not (.chezmoi.stdin | trim | empty) -}}
{{- $result = fromIni .chezmoi.stdin -}}
{{- end -}}

{{- /* Load default configuration */ -}}
{{- $default := (includeTemplate ".gitconfig.tmpl" . | fromIni) -}}
{{- $result = merge $default $result -}}

{{- toIni $result -}}