Skip to content

Instantly share code, notes, and snippets.

@rhelmer
Created July 2, 2013 00:04
Show Gist options
  • Save rhelmer/5905781 to your computer and use it in GitHub Desktop.
Save rhelmer/5905781 to your computer and use it in GitHub Desktop.
turn a local git-controlled file path/name into a github link
#!/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