git/Alias/md-url
- git git/Alias GitHub CLI yazi/Keyshort/Copy GitHub markdown link
git md-url — markdown link to a path's GitHub web view #card- Command:
git md-url [--no-copy] <path>... - Context: User-defined alias in the chezmoi-managed
~/.gitconfig, backed by ~/.config/git/scripts/generate_markdown_path_link.zsh. Sits beside git md-commit (which links the most recent commit), so the family is enumerable with git md-<TAB>. Clipboard writes route through the sibling git copy-text alias, which picks pbcopy / wl-copy / xclip per platform. - Description: Emits
[<repo>/<path-from-repo-root>](<github-url>) for each path given — files and directories alike — printing to stdout and copying to the clipboard. --no-copy prints only, for pipelines. Several paths yield one link per line. The URL targets the repository's default branch, never the checked-out branch, since a link into an unpushed branch is a 404 for everyone else. - Cost: one network round trip per invocation, ~0.7s, regardless of how many paths are passed. The default branch resolves offline from
refs/remotes/origin/HEAD; the base URL comes from a single gh browse -n call and every link is concatenated onto it. - Fails loudly: not a repository, no GitHub remote, a path outside the repository, or a missing gh all produce a message on stderr and a non-zero exit, leaving the clipboard untouched. A wrong link is not obviously wrong at paste time, so copying nothing is better.
- My Notes Bound in yazi as yazi/Keyshort/Copy GitHub markdown link (
c then g). The script strips GITHUB_TOKEN / GH_TOKEN itself rather than relying on the gh shell wrapper in .zshrc — that wrapper only exists for interactive shells, so a script behind a git alias would otherwise get the raw binary with the tokens still set.