src script

A convenience script to for rapidly switching context between different git repositories.

Installation

Assuming /usr/local/bin is in your PATH, you can install it by running:

curl --create-dirs -o "/usr/local/bin/src" https://raw.githubusercontent.com/samsalisbury/home/master/bin/src && chmod +x "/usr/local/bin/src"

Usage Examples

Clone github.com/samsalisbury/home if needed and print the directory where it was cloned. (If it’s already cloned just print the directory.)

$ src github.com/samsalisbury/home


Clone if needed and cd into the directory:

$ cd "$(src github.com/samsalisbury/home)"


Clone if needed and open a new tmux pane in the clone directory. (Only works if running inside tmux of course.):

$ src -t github.com/samsalisbury/home


Because there is a default host set to github.com, you can also just use samsalisbury/home in place of github.com/samsalisbury/home in the examples above.


Because there is a default username, mine currently set to hashicorp you can also omit the username for cloning repos from that user, e.g.: src -t vault is equivalent to src -t hashicorp/vault is equivalent to src -t github.com/hashicorp/vault.


See the source code at https://github.com/samsalisbury/home/blob/master/bin/src

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: