Created
July 2, 2013 00:04
-
-
Save rhelmer/5905781 to your computer and use it in GitHub Desktop.
turn a local git-controlled file path/name into a github link
This file contains 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/sh | |
BRANCH=`git rev-parse --abbrev-ref HEAD` | |
REMOTES=`git remote -v | awk '{print $2}' | uniq | sort` | |
if [ $# != 1 ] | |
then | |
echo 'Syntax: githubify <path_to_file>' | |
exit 1 | |
fi | |
FILE=$1 | |
for remote in $REMOTES | |
do | |
if [ `echo $remote | grep '^git'` ] | |
then | |
remote=`echo $remote | sed 's/:/\//' | sed 's/^git\@/https:\/\//'` | |
fi | |
remote=`echo $remote | sed 's/.git$//'` | |
echo ${remote}/blob/${BRANCH}/${FILE} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment