Skip to content

Instantly share code, notes, and snippets.

@jlumbroso
Created May 23, 2022 14:02
Show Gist options
  • Save jlumbroso/7e6c69bddf5642f8432bd0fa4784cf6c to your computer and use it in GitHub Desktop.
Save jlumbroso/7e6c69bddf5642f8432bd0fa4784cf6c to your computer and use it in GitHub Desktop.
Introduces a command `gh` to clone your repos in a few keystrokes
# 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