|
@@ -0,0 +1,48 @@
|
|
1
|
+#!/bin/bash
|
|
2
|
+
|
|
3
|
+#
|
|
4
|
+# Edit URL of remote $1 using vipe(1)
|
|
5
|
+#
|
|
6
|
+
|
|
7
|
+die() {
|
|
8
|
+ echo "$@" 1>&2
|
|
9
|
+ exit 1
|
|
10
|
+}
|
|
11
|
+
|
|
12
|
+usage() {
|
|
13
|
+ echo "usage: git $(basename "$0") [-v|--verbose] REMOTE"
|
|
14
|
+ exit 0
|
|
15
|
+}
|
|
16
|
+
|
|
17
|
+think() {
|
|
18
|
+ $verbose && echo "$@"
|
|
19
|
+}
|
|
20
|
+
|
|
21
|
+main() {
|
|
22
|
+ local remote
|
|
23
|
+ local oldurl
|
|
24
|
+ local newurl
|
|
25
|
+ local verbose=false
|
|
26
|
+ while true; do case $1 in
|
|
27
|
+ -v|--verbose) verbose=true; shift ;;
|
|
28
|
+ -*) usage ;;
|
|
29
|
+ *) break ;;
|
|
30
|
+ esac done
|
|
31
|
+ remote="$1"
|
|
32
|
+ test -n "$remote" || usage
|
|
33
|
+ command -v vipe >/dev/null \
|
|
34
|
+ || die "need vipe(1) from moreutils"
|
|
35
|
+ think "remote='$remote'"
|
|
36
|
+ oldurl=$(git remote get-url "$remote") \
|
|
37
|
+ || die "failed to get old URL"
|
|
38
|
+ think "oldurl='$oldurl'"
|
|
39
|
+ think "EDITOR='$EDITOR'"
|
|
40
|
+ think "VISUAL='$VISUAL'"
|
|
41
|
+ newurl=$(vipe <<<"$oldurl") \
|
|
42
|
+ || die "failed to edit URL (is vipe installed?)"
|
|
43
|
+ think "newurl='$newurl'"
|
|
44
|
+ git remote set-url "$remote" "$newurl" \
|
|
45
|
+ || die "failed to set new remote URL"
|
|
46
|
+}
|
|
47
|
+
|
|
48
|
+main "$@"
|