function ghq # Simplified https://github.com/x-motemen/ghq, so that it’s always available # Reference for git URLs: https://git-scm.com/docs/git-fetch#_git_urls # * ssh://[user@]host.xz[:port]/path/to/repo.git/ # * git://host.xz[:port]/path/to/repo.git/ # * http[s]://host.xz[:port]/path/to/repo.git/ # * ftp[s]://host.xz[:port]/path/to/repo.git/ # * [user@]host.xz:path/to/repo.git/ set -f url $argv[1] set -f path set -f host string match -rq '^([a-z]+://([^@]+@)?(?[^:/]+)(:\d+)?/)(?.+?)(\.git/?)?$' $url || string match -rq '^(([\w-]+@)?(?[^/:@]+):)(?.+?)(\.git/?)?$' $url set -f hqpath "$HOME/ghq/$host/$path" if test ! -d $hqpath echo "Cloning to $hqpath" git clone $url $hqpath end cd $hqpath end