Skip to content

Instantly share code, notes, and snippets.

@oldratlee
Created July 22, 2016 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oldratlee/169217285a6c3901a623d01ca6829aa9 to your computer and use it in GitHub Desktop.
Save oldratlee/169217285a6c3901a623d01ca6829aa9 to your computer and use it in GitHub Desktop.
Git/Http Converter
ghc() {
local url="${1:-$(git remote get-url origin)}"
if [ -z "$url" ]; then
echo "No arguement and Not a git repository!"
return 1
fi
if [[ "$url" =~ '^http' ]]; then
echo "$url" | sed 's#^https?://#git@#; s#$#\.git#; s#(\.com|\.org)/#\1:#' -r | c
else
echo "$url" | sed 's#^git@#http://#; s#http://github.com#https://github.com#; s#\.git##; s#(\.com|\.org):#\1/#' -r | c
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment