dotfiles

<-- duh.
git clone https://hhvn.uk/dotfiles
git clone git://hhvn.uk/dotfiles
Log | Files | Refs | Submodules | LICENSE

remote (805B)


      1 #!/bin/sh
      2 
      3 # I'm more interested in the URIs than the list of one, 
      4 # or two remotes, most of the time.
      5 [ -z "$@" ] 2>/dev/null && {
      6 	remotes=$(git remote -v)
      7 	[ -z "$remotes" ] && echo "no remotes configured" || echo "$remotes"
      8 
      9 	exit 0
     10 }
     11 
     12 # add/set-url act interchangably
     13 [ "$1" = "add" ] || [ "$1" = "set-url" ] && {
     14 	shift
     15 	for n in $(seq $#)
     16 	do
     17 		eval "echo \$$n" | grep -v '^-' >/dev/null && {
     18 			remote=$(eval "echo \$$n")
     19 			break
     20 		}
     21 	done
     22 	[ "$remote" = "" ] && echo "error: no remote given" && exit 1
     23 
     24 	for r in $(git remote)
     25 	do
     26 		[ "$r" = "$remote" ] && comm="set-url"
     27 	done
     28 
     29 	while [ $# -ne 0 ]
     30 	do
     31 		printf "%s\0" "$1"
     32 		shift
     33 	done | xargs -0 git remote ${comm:-add}
     34 
     35 	exit 0
     36 }
     37 
     38 # fallback to regular git-remote
     39 while [ $# -ne 0 ]
     40 do
     41 	printf "%s\0" "$1"
     42 	shift
     43 done | xargs -0 git remote