Skip to content

Instantly share code, notes, and snippets.

@wraithan
Forked from rhelmer/gist:5905781
Last active December 19, 2015 05:39
Show Gist options
  • Save wraithan/5905833 to your computer and use it in GitHub Desktop.
Save wraithan/5905833 to your computer and use it in GitHub Desktop.
#!/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
if [ `echo $remote | grep '^git://'` ]
then
remote=`echo $remote | 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