Clone and switch between git repos
Go to file
Monty Taylor 5e95d84573 Replace in README
Change-Id: Iebabe5bf8f6fe314cb5b287ae157ceb706b3a0ae
2020-06-18 17:14:24 -05:00
.gitreview added .gitreview 2019-12-08 14:50:42 -05:00
.zuul.yaml added noop jobs 2019-12-08 14:50:41 -05:00
LICENSE Initial commit 2017-06-20 11:18:28 -05:00
README.rst Replace in README 2020-06-18 17:14:24 -05:00 Add bash auto-complete 2019-12-08 14:50:42 -05:00


Simple shell function to clone and navigate git source respositories in a golang-style directory layout.

golang dictates a strict directory layout and provides helper programs to fetch source code into the right structure. Other languages do not mandate such a layout, but neither do they have any problems if one is used. was written to facilitate managing all of ones source repos in the same structure, regardless of whether one is programming in go or not.


Either copy the contents of to your ~/.bash_profile or copy the file into /etc/profile.d then re-login. It's also possible to source in the current shell if you don't want to re-login.

A new shell function src will be available.

Usage either clones or changes directories to a given source repo location.

src ansible/ansbile

Results in the ansible/ansible repo being cloned to ~/src/ if it's not already there and that being set to the current directory.

Configuration uses the golang source directory layout scheme, but uses $SRCSRCDIR instead of $GOPATH as the primary variable. If $GOPATH is set and $SRCSRCDIR is not set, $SRCSRCDIR defaults to $GOPATH/src. If neither are set, $SRCSRCDIR defaults to ~/src.

$SRCSRCDIR, while ugly, was chosen because the function is called "src" but $SRCDIR is much more likely to be already be used, possibly for some other purpose. supports a configurable ordered list of prefixes to try, for folks who have frequent groups of things they work with. $SRCSRCPREFIXES defaults to "". For instance:

export SRCSRCPREFIXES=" \ \ \ \"

Results in shade being cloned to ~/src/ defaults to using cd to change directories. Setting $SRCSRCUSEPUSHD=1 will cause it to use pushd instead.

Use of go get by default

By default, uses go get -d to do the cloning. If you do not have go get in your path, it will use a less efficient set of shell commands and attempt cloning directly. go get has a better idea of whether or not you're requesting a full path to something or not, so it's recommended to just have it installed somewhere in your path.