A tool like gh browse for generating the (git)hub URLs from your local
repository.
- Share precise URLs to files, directories and repositories with friends or co-workers
- Speed up your personal workflows when working with multiple repositories across different hubs
- Generates file, file+line, directory and repository URLs
- Discovers the current branch and adds it to the URL
- Supports multiple remotes
- Supported (git)hubs: Github, Gitlab, Gitea, Forgejo, Azure DevOps, SourceHut
- Supports private hubs via a custom configuration
- 3 actions: print, copy or open URLs
- Supports git and jujutsu
- Work in Progress: Generate Pull Request URLs
huburl [flags] (path)Flags:
-h, --help: Display the help message for this command
-o, --open: Open URL in browser
-c, --copy: Copy URL into the clipboard
-r, --remote <string>: Specific remote name, defaults to the first remote
-v, --verbose: Verbose log output
-V, --version: Print huburl version
-P, --pr: Create PR
-R, --remote-pr <string>: Name of remote
-B, --branch-pr <string>: Name of target branch for PR, defaults to main
--test: Run tests (just for development)
Parameters:
path <path>: File or directory path, defaults to root of the repository (optional)
Important
ssh remotes are supported and converted to https automatically. Shortened
paths such as git@github.com:someone/repo.git are only supported if they
begin with git@.
nushellfor executing the script itselfjujutsu/jjto find bookmarks and remotes in jujutsu repositoriesgitto find branches and remotes in git repositoriesxdg-openfor opening URLs (Linux)
curl -o /usr/local/bin/huburl https://github.com/jceb/huburl/raw/refs/heads/main/huburl
chmod u+x /usr/local/bin/huburl
cd my-repository
huburl # generates the URL to your hub- Add the
huburlsection to your Flake'sinputs:
inputs = {
# (...)
huburl = {
url = "github:jceb/huburl/main";
inputs.nixpkgs.follows = "nixpkgs";
};
};- Add the following to your
nixpkgs.overlays:
(final: prev: {
# (...)
huburl = import inputs.huburl {
inherit system;
inherit (prev) pkgs;
};
})-
Rebuild your configuration (
nixos-rebuild switch --flake your-system-config) and check if it works withhuburl --help. -
Execute the file from inside a git or jujutsu repository:
huburl # generates the URL to your hubnix run github:jceb/huburlAdd this snippet to your vimrc to add a :Huburl command:
" Print the (git)hub's URL for the current file
" <bang> behaves like -o and opens then URL
" Manually pass arguments to :Huburl, e.g. -o to open the URL or -c to copy it to the clipboard
function! Huburl(bang, args)
let l:args = a:args
if a:bang == "!"
let l:args = l:args.' -o'
end
let l:file = expand('%:p')
let l:line = ":".line('.')
if l:file == ""
let l:file = getcwd()
let l:line = ""
end
exec '!huburl '.fnameescape(l:file).l:line.' '.l:args
endfunction
command! -nargs=* -complete=file -bang Huburl :call Huburl("<bang>", <q-args>)The file ~/.config/huburl/config.toml contains options for the tool.
To configure a hostname to be associated with a specific hub:
[hubs.gitlab]
hostnames = [ "git.example.com" ]Supported hub types: github, gitlab, gitea, forgejo, azure, srht
The --copy option doesn't work inside tmux by default, to fix it set:
set -g set-clipboard on