]> git.phdru.name Git - dotfiles.git/blobdiff - bin/git-open-remote
Update configs after upgrading to Debian 9 "stretch"
[dotfiles.git] / bin / git-open-remote
diff --git a/bin/git-open-remote b/bin/git-open-remote
new file mode 100755 (executable)
index 0000000..45c3a7e
--- /dev/null
@@ -0,0 +1,19 @@
+#! /bin/sh
+
+if [ -z "$1" ]; then
+   branch="`git rev-parse --abbrev-ref HEAD`"
+   remote="`git config --get branch.$branch.remote`"
+elif [ -n "$2" ]; then
+   echo "Usage: git open-remote [remote_name]" >&2
+   exit 1
+else
+   remote="$1"
+fi
+
+if [ -z "$remote" ]; then
+   echo "Cannot find remote for branch $branch" >&2
+   echo "Usage: git open-remote [remote_name]" >&2
+   exit 1
+fi
+
+exec git-open remote.$remote.url