Skip to content

Instantly share code, notes, and snippets.

@daneden

daneden/Readme.md

Created Mar 21, 2020
Embed
What would you like to do?

git clone and cd function

A simple little alias function that lets you clone and cd into a GitHub repo in one command.

Installation

Add to your zsh or bash config (usually ~/.bash_profile or ~/.zshrc) and open a new terminal to be able to use the function.

Usage

gcd [github_repo_owner/repo_name]

# For example, the following with clone daneden/zeitgeist and `cd` into it:
gcd daneden/zeitgeist
function __gcd {
if [ "$1x" != "x" ]; then
git clone "https://github.com/$1"
DIRNAME="$(cut -d'/' -f2 <<<$1)"
cd "$DIRNAME"
fi
}
alias gcd='__gcd'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.