feat(functions): add open-url and repo-open browser helpers #67

Merged
rootiest merged 1 commits from feat-open-url-and-repo-open into main 2026-07-04 06:12:31 +00:00
Owner

Summary

Why: The browser-launching logic (best-browser detection + backgrounded launch) was buried inside config-help --html and not reusable. This extracts it and builds a repo-browsing convenience on top.

What:

  • open-url — new function. Resolves the best graphical browser ($fish_help_browser$BROWSERxdg-mime https handler → known binaries → xdg-open) and launches it backgrounded. Silent by default (-v/--verbose reports the browser, -s/--silent accepted explicitly). Browser console chatter (e.g. "Opening in existing browser session.") is discarded.
  • repo-open — new function. Opens the current repo's origin remote in a browser via open-url. Normalizes HTTPS and SSH/scp remote forms, deep-links to the current branch (falling back to the remote default) and sub-directory. Provider layout resolved via git config browse.provider → hostname heuristic (github/gitlab/gitea/bitbucket, codeberg→gitea) → github default. -p/--print emits the URL; -r/--root ignores the sub-directory.
  • config-help — the inlined browser block (~65 lines) now just calls open-url.
  • Abbreviationsopen-repo and url-open expand to the canonical command names on space/enter (visible hint, not a silent alias).
  • Docs — both functions documented in the SSoT (fish-config.md + .index); README doc-browsing table gains a repo-open row.

Note: .gitignore has an unrelated pending change deliberately excluded from this PR — it'll ship with the next PR that generates it dynamically.

browse.provider=gitea was set on this repo's local git config so git.rootiest.dev links resolve to /src/branch/… (that's local config, not part of this diff).

Manual Verification

  • repo-open --print prints https://git.rootiest.dev/rootiest/fish-config from the repo root.
  • cd docs; repo-open --print prints …/src/branch/main/docs (gitea layout, current sub-directory).
  • repo-open (no flags) opens the repo web page in your browser with no terminal output.
  • open-url https://example.com opens the page silently; open-url -v https://example.com prints an Opening <browser>… line.
  • help config --html still opens the local HTML docs in the browser (config-help extraction intact).
  • Type open-repo then press space — it expands to repo-open; same for url-openopen-url.
## Summary **Why:** The browser-launching logic (best-browser detection + backgrounded launch) was buried inside `config-help --html` and not reusable. This extracts it and builds a repo-browsing convenience on top. **What:** - **`open-url`** — new function. Resolves the best graphical browser (`$fish_help_browser` → `$BROWSER` → `xdg-mime` https handler → known binaries → `xdg-open`) and launches it backgrounded. Silent by default (`-v/--verbose` reports the browser, `-s/--silent` accepted explicitly). Browser console chatter (e.g. "Opening in existing browser session.") is discarded. - **`repo-open`** — new function. Opens the current repo's `origin` remote in a browser via `open-url`. Normalizes HTTPS and SSH/scp remote forms, deep-links to the current branch (falling back to the remote default) and sub-directory. Provider layout resolved via `git config browse.provider` → hostname heuristic (github/gitlab/gitea/bitbucket, codeberg→gitea) → github default. `-p/--print` emits the URL; `-r/--root` ignores the sub-directory. - **`config-help`** — the inlined browser block (~65 lines) now just calls `open-url`. - **Abbreviations** — `open-repo` and `url-open` expand to the canonical command names on space/enter (visible hint, not a silent alias). - **Docs** — both functions documented in the SSoT (`fish-config.md` + `.index`); README doc-browsing table gains a `repo-open` row. > **Note:** `.gitignore` has an unrelated pending change deliberately excluded from this PR — it'll ship with the next PR that generates it dynamically. > > `browse.provider=gitea` was set on this repo's local git config so `git.rootiest.dev` links resolve to `/src/branch/…` (that's local config, not part of this diff). ## Manual Verification - [x] `repo-open --print` prints `https://git.rootiest.dev/rootiest/fish-config` from the repo root. - [x] `cd docs; repo-open --print` prints `…/src/branch/main/docs` (gitea layout, current sub-directory). - [x] `repo-open` (no flags) opens the repo web page in your browser with no terminal output. - [x] `open-url https://example.com` opens the page silently; `open-url -v https://example.com` prints an `Opening <browser>…` line. - [x] `help config --html` still opens the local HTML docs in the browser (config-help extraction intact). - [x] Type `open-repo` then press space — it expands to `repo-open`; same for `url-open` → `open-url`.
rootiest added 1 commit 2026-07-04 06:03:03 +00:00
Extract the browser-detection and launch logic out of config-help into a
reusable open-url function, then build repo-open on top of it to open the
current repo's origin remote in a browser.

- open-url: resolve the best graphical browser (fish_help_browser -> BROWSER
  -> xdg-mime https handler -> known binaries -> xdg-open) and launch it
  backgrounded. Silent by default; -v/--verbose reports the browser, -s/--silent
  is accepted explicitly. Browser console chatter is discarded.
- repo-open: normalize the origin URL from HTTPS and SSH/scp forms, deep-link
  to the current branch (falling back to the remote default) and sub-directory.
  Provider layout resolved via git config browse.provider, hostname heuristic
  (github/gitlab/gitea/bitbucket, codeberg->gitea), then github default.
  -p/--print emits the URL, -r/--root ignores the sub-directory.
- config-help: replace the inlined browser block with an open-url call.
- abbr: add open-repo and url-open abbreviations that expand to the canonical
  command names on space/enter.
- docs: document both functions in the SSoT (fish-config.md + index) and add a
  repo-open row to the README doc-browsing table.
rootiest merged commit 8068dcb312 into main 2026-07-04 06:12:31 +00:00
rootiest deleted branch feat-open-url-and-repo-open 2026-07-04 06:12:31 +00:00
Sign in to join this conversation.