Giter VIP home page Giter VIP logo

gitcd's Introduction

gitcd

Quickly navigate to your GitHub repositories.

Gitter chat

Examples

Without gitcd, you may need to manage multiple GitHub repo clones manually:

mkdir -p ~/github/coollog
cd ~/github/coollog
git clone https://github.com/coollog/gitcd.git
cd gitcd
# Now make some commits.
# Time to work on another repo.
mkdir -p ~/github/foo
git clone -C ~/github/foo/bar https://github.com/foo/bar.git
cd ~/github/foo/bar
# Make some edits.
# Now time to go back to coollog/gitcd. Where is it again? Oh, right.
cd ~/github/coollog/gitcd
# Some days later. Did I clone foo/bar already?
ls ~/github/foo/bar
# Ah okay, time to go work on that.
cd ~/github/foo/bar
...

With gitcd, this becomes just:

gcd coollog/gitcd # Clones https://github.com/coollog/gitcd.git
# Make some commits.
gcd foo/bar       # Clones https://github.com/foo/bar.git
# Make some commits.
gcd gitcd
# Some days later.
gcd bar
...

Usage

1) Install gitcd.

Linux

curl -Lo ./gitcd https://storage.googleapis.com/gitcd/gitcd-linux-amd64 && \
    chmod +x ./gitcd && sudo mv ./gitcd /usr/local/bin

macOS

curl -Lo ./gitcd https://storage.googleapis.com/gitcd/gitcd-darwin-amd64 && \
    chmod +x ./gitcd && sudo mv ./gitcd /usr/local/bin

Windows

Download the latest Windows build: https://storage.googleapis.com/gitcd/gitcd-windows-amd64.exe

Build from source

go get -u github.com/coollog/gitcd
# `gitcd` will be at `$GOPATH/bin/gitcd`

2) Add gcd to your bash profile (~/.bashrc or ~/.bash_profile):

This adds gcd as a bash function.

[ -f ~/.bashrc ] && echo 'gcd() { GITCD_GCD=1 gitcd "$@" && cd `gitcd "$@"`; }' >> ~/.bashrc && . ~/.bashrc
[ -f ~/.bash_profile ] && echo 'gcd() { GITCD_GCD=1 gitcd "$@" && cd `gitcd "$@"`; }' >> ~/.bash_profile && . ~/.bash_profile

3) Use gcd to navigate to a repository.

gcd coollog/gitcd

gitcd clones the repository first if it does not exist.

Configuration

Set GITCD_HOME to change the root directory for the cloned repositories. By default, gitcd uses ~/gitcd.

How it works

# These all navigate to the directory for the cloned repo, cloning the repo if necessary.
gcd https://github.com/coollog/gitcd.git
gcd http://github.com/coollog/gitcd.git
gcd https://github.com/coollog/gitcd
gcd [email protected]:coollog/gitcd.git
gcd github.com/coollog/gitcd
gcd coollog/gitcd.git
gcd coollog/gitcd
gcd gitcd # If you have used repos under coollog/ before.

# This makes another clone under ~/github2.
GITCD_HOME=~/github2 gcd coollog/gitcd

# This navigates to the directory in your GOPATH.
GITCD_HOME=$GOPATH/src/github.com gcd coollog/gitcd

When the name is ambiguous (just the repo name like gitcd rather than coollog/gitcd), gitcd tries to find the name under owners in the order in which they were last used. For example, if gitcd had used foo/, bar/, and cat/ (in that order), gcd dog would try to find dog in cat/dog, then bar/dog, then foo/dog.

gitcd's People

Contributors

coollog avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

wilder

gitcd's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.