Skip to content

Instantly share code, notes, and snippets.

@hackugyo
Last active February 2, 2016 10:13
Show Gist options
  • Save hackugyo/e06803fa8a6d94bd111f to your computer and use it in GitHub Desktop.
Save hackugyo/e06803fa8a6d94bd111f to your computer and use it in GitHub Desktop.
現在のgitリポジトリのoriginのremoteをWebで開きます。
git_open_origin() {
(set -eu -o pipefail; \
commit_hash=${1:-""}; \
blob_where=${2:-""};
if [ -n "${commit_hash}" ]; then \
if [ -n "${blob_where}" ]; then \
commit_hash="/blob/${commit_hash}/${blob_where}"; \
else \
commit_hash="/commits/${commit_hash}"; \
fi; \
fi; \
git remote -v | grep origin | \
sed -e 's/origin//' | \
sed -e 's/\/git\//\//' | \
sed -e 's/\.git (.*$//' | \
sed -e 's/git@github.com:/https:\/\/github.com\//' | \
head -n 1 | \
xargs -I {} open {}${commit_hash};
)
}
@hackugyo
Copy link
Author

hackugyo commented Feb 2, 2016

Usage

$ git_open_origin
$ git_open_origin develop/develop
$ git_open_origin c1a2f89 app/src/main/java/jp/ne/hatena/hackugyo/thoughtscalendar/util/SensorUtils.java#L26-L27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment