Last active
April 28, 2020 04:35
-
-
Save loganlinn/5b506c9c708859ad99a766842dbce9a8 to your computer and use it in GitHub Desktop.
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
| # @description clones git repository (including submodules) and changes working | |
| # directory to it. If `directory` not specified, uses $PROJECTS. | |
| # and if that's not set, fallsback to current directory. | |
| # | |
| # @example gclone [email protected]:loganlinn/blog.git | |
| # @example gclone loganlinn/blog | |
| function gclone { | |
| emulate -L zsh | |
| if [[ "$#" -eq 0 ]]; then | |
| echo "Usage: $0 <repository> [<directory>]" >&2 | |
| return 1 | |
| fi | |
| local repository="$1" | |
| local directory="$2" | |
| if [[ -z "$directory" ]]; then | |
| directory="${GCLONE_HOME:-${PROJECTS:-$(pwd)}}/${repository:t:r}" | |
| fi | |
| hub clone --recurse-submodules -- "$repository" "$directory" | |
| cd "$directory" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment