From ca991c461e79c1257dd629a0fa9edc582a947d24 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Wed, 13 Dec 2017 22:35:17 +0300 Subject: [PATCH] Feat: Split git-open into git-open-remote git-open can now open any config key. git-open-remote opens remotes URLs. --- git-open | 16 ++++++---------- git-open-remote | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 10 deletions(-) create mode 100755 git-open-remote diff --git a/git-open b/git-open index bb5d648..ebb6e0a 100755 --- a/git-open +++ b/git-open @@ -1,18 +1,14 @@ #! /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_name]" >&2 +if [ -z "$1" -o -n "$2" ]; then + echo "Usage: git open url_key" >&2 exit 1 else - remote="$1" + url_key="$1" fi -if [ -z "$remote" ]; then - echo "Cannot find remote for branch $branch" >&2 - echo "Usage: git open [remote_name]" >&2 +if [ -z "$url_key" ]; then + echo "Usage: git open url_key" >&2 exit 1 fi @@ -22,4 +18,4 @@ if [ -z "$browser_cmd" ]; then browser_cmd="webbrowser -n" fi -exec $browser_cmd "`git config --get remote.$remote.url`" +exec $browser_cmd "`git config --get $url_key`" diff --git a/git-open-remote b/git-open-remote new file mode 100755 index 0000000..45c3a7e --- /dev/null +++ b/git-open-remote @@ -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 -- 2.39.5