Created
July 22, 2016 23:46
-
-
Save oldratlee/169217285a6c3901a623d01ca6829aa9 to your computer and use it in GitHub Desktop.
Git/Http Converter
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
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