Gito intelligently manages where your source code lives.
This very lightweight solution lets you stay organized and find your code without ever thinking about it.
Inspired by go get, your configurable source path will have
directories namespaced by organization and repository
($HOME/src/github.com/r-medina/gito, for example).
# download a new project
gito get github.com/r-medina/dotfiles
# set an alias
gito alias dot r-medina/dotfiles
# configure a few aliases in your terminal for quick cd/open
# takes you to dotfiles
gicd dot
# open the repository in a browser
gpen .
# make a new git project where your personal code lives
gmk new-projectfull documentation below
go install -u github.com/r-medina/gito# this defaults to GOPATH[0]/src/github.com/... or $HOME/src/...
gito get github.com/r-medina/gitothe get command does need the full GitHub path to a repo, but from
here on you can use any subset of the repo name (eg gito)
You can include the entire github url, eg https://github.com/r-medina/gito
gito where r-medina/gito # $HOME/go/src/github.com/r-medina/gitoCan also find code with just repo name
gito where gito # $HOME/go/src/github.com/r-medina/gitoWhich you can easily cd into
cd $(gito where gito)it’s helpful to set an alias in your shell to that cd command
gito url gito # https://github.com/r-medina/gito
open $(gito url gito) # opens in brownsergito set r-medina/gito <path> # saves the location information to path
gito where r-medina/gito # <path>when a repo’s location is set, only that name can be used, but you
can set r-medina/gito and gito to <path> so that both work!
gito alias g github.com/mvdan/garble
gito where g # $HOME/go/src/github.com/mvdan/garblegito alias d dotfiles
gito set dotfiles ~/.dotfiles # $HOME
cd $(gito where d)gito set-self github.com/r-medina
cd $(gito self)see config for how to set these up, but
gito -w=work where gh # $HOME/where-i-keep-work-code/src/github.com/github usage: gito [<flags>] <command> [<args> ...]
Manage code intelligently.
See http://github.com/r-medina/gito for documentation.
Flags:
-w WORKSPACE which workspace to use (defaults to first in config)
Commands:
help
show this message
get <repo>
download a repo
where <repo>
find out where repo lives
url [<repo>|.]
get the url of the repo (for web browsing) - can also pass no argument or "." for current directory
alias <alias> <to>
alias a name to something - eg "k8s" -> "github.com/kubernetes/kubernetes"
set <alias> <location>
for code living outside your configured path, tell gito where to find it
set-self <location>
configuring gito to use a default folder for your code
self
get location of self in config (default location to put your code)
Add the following to your shell:
# Ensure 'gito' is available in the PATH
whence gito >/dev/null || return 1
# Function to change directory to a Git repository's top-level directory or a specific repo location
gicd() {
if [[ -z "$1" ]]; then
echo "Usage: gicd <repository> | ."
return 1
fi
if [[ $1 == "." ]]; then
local top_level
top_level=$(git rev-parse --show-toplevel 2>/dev/null)
if [[ -z "$top_level" ]]; then
echo "Error: Not inside a Git repository."
return 1
fi
cd "$top_level" || return 1
else
local repo_path
repo_path=$(gito where "$1" 2>/dev/null)
if [[ -z "$repo_path" ]]; then
echo "Error: Repository '$1' not found."
return 1
fi
cd "$repo_path" || return 1
fi
}
# Function to open a URL related to a Git repository
gpen() {
if [[ -z "$1" ]]; then
echo "Usage: gpen <repository>"
return 1
fi
local url
url=$(gito url "$1" 2>/dev/null)
if [[ -z "$url" ]]; then
echo "Error: URL for repository '$1' not found."
return 1
fi
open "$url" || return 1
}
# Function to create a new Git repository directory and initialize it
gmk() {
if [[ -z "$1" ]]; then
echo "Usage: gmk <directory_name>"
return 1
fi
local dir_name=$1
local self
self=$(gito self 2>/dev/null)
if [[ -z "$self" ]]; then
echo "Error: Could not determine self repository location."
return 1
fi
cd "$self" || return 1
mkdir -p "$dir_name" || return 1
cd "$dir_name" || return 1
git init || return 1
}This makes going into your source code directories really easy gcd
gito as well as opening the repository in a web browser.
gito cannot do shell expansion for now, so add full paths to the config file.
workspaces:
- name: personal
path: "/Users/ricky"
aliases:
g: gito
d: dotfiles
custom:
dotfiles: "/Users/ricky/.dotfiles"
- name: work
path: "/Users/ricky/gh"
aliases:
ghe: super-secret
custom:
super-secret: "somewhereElse/theMoneyMaker- only works with git
- only tested with github