diff --git a/.config/shell/git b/.config/shell/git index d350e15..363210b 100644 --- a/.config/shell/git +++ b/.config/shell/git @@ -13,11 +13,17 @@ yc() { } alias sysyadm="yadm --yadm-dir /etc/yadm --yadm-data /etc/yadm" -alias sysinit="sysyadm init -b main -w /; sysyadm gitconfig include.path '$XDG_CONFIG_HOME/git/config'" +alias sysinit="sysyadm init -b main -w /" #; sysyadm gitconfig include.path '$XDG_CONFIG_HOME/git/config'" sy() { unignore="/etc/yadm/unignore" test -r "$unignore" && cat "$unignore" | envsubst | sysyadm add --intent-to-add --pathspec-from-file=- - test "$#" -eq 0 && sysyadm s || sysyadm "$@" + case "$1" in + ("") sysyadm s;; + (p) sysyadm p;; + (l) sysyadm fetch && sy rebase main --onto origin/main;; + (*) sudo -E $(alias sysyadm | cut -d\' -f2) "$@";; + esac + sudo chown -R $USER /etc/yadm } gcn() { diff --git a/.local/bin/scripts/git-diffa b/.local/bin/scripts/git-diffa new file mode 100755 index 0000000..b9df61d --- /dev/null +++ b/.local/bin/scripts/git-diffa @@ -0,0 +1,3 @@ +#!/bin/sh +# Diff given files against all branches +git for-each-ref --format='%(refname:short)' | while read branch; do { highlight $branch && git diff --color=always $branch..HEAD "$@"; }; done | less diff --git a/.local/bin/scripts/git-origin b/.local/bin/scripts/git-origin index 2730d45..5ddc47f 100755 --- a/.local/bin/scripts/git-origin +++ b/.local/bin/scripts/git-origin @@ -1,9 +1,11 @@ #!/bin/sh -e # set repo as origin and set all branches upstream to a corresponding remote branch, if available -git remote remove origin 2>/dev/null -git remote add origin $(git-repo "$@") +git remote $(case "$(git remote)" in + (*origin*) echo set-url;; + (*) echo add;; +esac) origin "$(git-repo "$@")" git remote -v && git fetch -git branch | sed 's/ //g' | sed 's/*//' | while read branch +git branch --format='%(refname:short)' | while read branch do test $(git branch -a | grep origin/$branch | wc -l) -gt 0 && git branch -u origin/$branch $branch done diff --git a/.local/bin/scripts/git-week b/.local/bin/scripts/git-week index 7e53ce7..7ed32e3 100755 --- a/.local/bin/scripts/git-week +++ b/.local/bin/scripts/git-week @@ -1,4 +1,4 @@ #!/bin/sh # Commits by myself throughout the current week -# Depends on git-my alias listing commits by myself +# depends: git-my alias - listing own commits git my --after "$(date -d "Mon ${1:-1} weeks ago")" --before "$(date -d "Mon $(expr ${1:-1} - 1) weeks ago")" "${@:2}"