Created
May 23, 2022 14:02
-
-
Save jlumbroso/7e6c69bddf5642f8432bd0fa4784cf6c to your computer and use it in GitHub Desktop.
Introduces a command `gh` to clone your repos in a few keystrokes
This file contains 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
# Fast command-line cloning of GitHub repos | |
# | |
# usage: add to your .bashrc or .zsh like this: | |
# source gh_clone.sh | |
# replace 'jlumbroso' with your own GitHub username | |
export GITHUB_USERNAME="jlumbroso" | |
# one-line repo clone | |
# gh <repo> [<-- will default to username=${GITHUB_USERNAME}] | |
# gh <username> <repo> | |
function gh { | |
username=${1:?"The repo must be specified."} | |
repo=${2} | |
if [ -z "$repo" ]; then | |
repo=${username} | |
username=${GITHUB_USERNAME} | |
fi | |
git clone https://github.com/${username}/${repo}.git | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment