Last active
December 18, 2015 17:19
-
-
Save BaseCase/5817645 to your computer and use it in GitHub Desktop.
GitHub Blame: given a filename argument, this will open GitHub's Git Blame view on that file in your current repo and branch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -e | |
| filename=$1 | |
| function repo_name { | |
| git remote -v | | |
| grep -m 1 "git@.*\.git" | | |
| awk '{print $2}' | | |
| cut -d ':' -f 2 | | |
| sed s/\.git// | |
| } | |
| function branch_name { | |
| git status | | |
| grep "On branch" | | |
| cut -d ' ' -f 4 | |
| } | |
| function path_to_file { | |
| git ls-files --full-name $filename | |
| } | |
| function github_blame_url { | |
| echo "https://github.com/$(repo_name)/blame/$(branch_name)/$(path_to_file)" | |
| } | |
| open `github_blame_url` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment