A bash library providing git repository management utilities for URL parsing, cloning, and workspace organization.
# Load the library using grab
if [ ! -f "$HOME/bin/grab" ]; then
mkdir -p $HOME/bin
export PATH=$PATH:$HOME/bin
curl -o $HOME/bin/grab -L https://github.com/shellib/grab/raw/master/grab.sh && chmod +x $HOME/bin/grab
fi
source $(grab github.com/shellib/git as git)git::extract_host(url)- Extract hostname from git repository URLgit::extract_organization(url)- Extract organization/owner namegit::extract_repository(url)- Extract repository namegit::extract_path(url)- Extract path after repositorygit::extract_github_pr_number(url)- Extract GitHub PR numbergit::extract_gitlab_mr_number(url)- Extract GitLab MR number
git::build_ssh_url(host, org, repo, [username])- Build SSH clone URLgit::build_https_url(host, org, repo)- Build HTTPS clone URLgit::workspace_path(host, org)- Build workspace directory path
git::clone(host, org, repo, target_dir)- Smart clone using configgit::clone_with_fallback(host, org, repo, target_dir, [username])- Clone with SSH->HTTPS fallback
git::get_method(host, org, repo)- Get configured clone methodgit::get_username(host, org, repo)- Get configured usernamegit::get_config_values(host, org, repo)- Get method and username
git::is_github(url)- Check if URL is from GitHub
The library supports TOML configuration files (default: ~/.config/qutebrowser/git.toml):
[default]
method = "fallback"
["github.com"]
method = "ssh"
["gitlab.example.com/org/special-repo"]
method = "https"
username = "myuser"Configuration hierarchy (most specific wins):
- Repository-specific:
["host/org/repo"] - Host-specific:
["host"] - Default:
[default]
./library.sh --test- shellib/toml - TOML parsing library