Created
June 11, 2023 13:05
-
-
Save cljoly/cbe931d6e0bb31cf9dc113774bb87f3f to your computer and use it in GitHub Desktop.
Revisions
-
cljoly created this gist
Jun 11, 2023 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ 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]+://([^@]+@)?(?<host>[^:/]+)(:\d+)?/)(?<path>.+?)(\.git/?)?$' $url || string match -rq '^(([\w-]+@)?(?<host>[^/:@]+):)(?<path>.+?)(\.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