{{- if eq .chezmoi.os "linux" -}} #!/bin/sh # Point the claude:// and claude-cli:// URL schemes at our handlers. # # ~/.config/mimeapps.list is rewritten by every desktop and by xdg-mime itself, # so it is not a file this repo can own. Setting the two defaults through # xdg-mime touches only those two lines. # # claude:// -> claude-url-dispatch, which routes OAuth callbacks and # deep links to the Claude Desktop profile that asked for # them. The packaged com.anthropic.Claude.desktop starts an # unflagged instance that cannot keep the sign-in. # claude-cli:// -> Claude Code's own handler. # # Linux only (the template renders empty elsewhere, and chezmoi skips an empty # script). Skipped with a note when xdg-mime is absent, e.g. a headless box. # It re-runs when this file changes, or when a handler's .desktop does: # dispatch {{ include "dot_local/share/applications/claude-url-dispatch.desktop.tmpl" | sha256sum }} # cli {{ include "dot_local/share/applications/create_claude-code-url-handler.desktop.tmpl" | sha256sum }} set -u if ! command -v xdg-mime >/dev/null 2>&1; then echo "claude URL handlers: xdg-mime not found, skipped" >&2 exit 0 fi rc=0 xdg-mime default claude-url-dispatch.desktop x-scheme-handler/claude || rc=1 xdg-mime default claude-code-url-handler.desktop x-scheme-handler/claude-cli || rc=1 [ "$rc" -eq 0 ] || echo "claude URL handlers: xdg-mime failed; set them by hand with xdg-mime default" >&2 exit 0 {{ end -}}