dotfiles

<-- duh.
Log | Files | Refs | LICENSE

commit d0aa98e54ea704e8234b3ab30275f030bb65254e
parent 5b4140843690531e21f1793fdd449c99c3fbf598
Author: hhvn <dev@haydenvh.com>
Date:   Sun,  7 Mar 2021 02:06:52 +0000

.config/git/remote[NEW] .config/git/config: ease managing of remotes

Diffstat:
M.config/git/config | 2++
A.config/git/remote | 43+++++++++++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/.config/git/config b/.config/git/config @@ -14,6 +14,8 @@ co = commit pu = push ac = !sh ~/.config/git/add-commit + pa = push --all + re = !sh ~/.config/git/remote [init] defaultBranch = master diff --git a/.config/git/remote b/.config/git/remote @@ -0,0 +1,43 @@ +#!/bin/sh + +# I'm more interested in the URIs than the list of one, +# or two remotes, most of the time. +[ -z "$@" ] 2>/dev/null && { + remotes=$(git remote -v) + [ -z "$remotes" ] && echo "no remotes configured" || echo "$remotes" + + exit 0 +} + +# add/set-url act interchangably +[ "$1" = "add" ] || [ "$1" = "set-url" ] && { + shift + for n in $(seq $#) + do + eval "echo \$$n" | grep -v '^-' >/dev/null && { + remote=$(eval "echo \$$n") + break + } + done + [ "$remote" = "" ] && echo "error: no remote given" && exit 1 + + for r in $(git remote) + do + [ "$r" = "$remote" ] && comm="set-url" + done + + while [ $# -ne 0 ] + do + printf "%s\0" "$1" + shift + done | xargs -0 git remote ${comm:-add} + + exit 0 +} + +# fallback to regular git-remote +while [ $# -ne 0 ] +do + printf "%s\0" "$1" + shift +done | xargs -0 git remote