{"modulePath":"github.com/CommitBrief/commitbrief","version":"v1.23.0","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package alias\n\nPackage alias installs a shell alias (e.g. \\`cbr\\` → \\`commitbrief\\`) into the user's shell startup file, cross-platform. It is the OS-level half of \\`commitbrief setup --alias\\`; the interactive orchestration lives in internal/setup.\n\nEach supported shell is an Installer. A managed block delimited by blockStart/blockEnd is written into the shell's startup file, so re-running updates the block in place (changing the alias name removes the old one) and lines outside the block are never touched. Conflict detection is best-effort: an executable of the same name on PATH (exec.LookPath) plus a scan of the startup file for an existing alias/function definition outside our block. Shell builtins, functions defined elsewhere, and aliases in a different shell's rc are out of scope (they cannot be detected without invoking the shell).\n\n## Constants\n\n```go\nconst (\n\t// DefaultName is the alias installed when the user accepts the default.\n\tDefaultName = \"cbr\"\n\n\t// Command is what the alias expands to. A bare binary name (not an\n\t// absolute path) is deliberate: interactive shells have the install\n\t// directory on PATH, and a bare name survives `brew upgrade` /\n\t// reinstalls that would invalidate an embedded path. (install-hook\n\t// embeds an absolute path because GUI git clients run hooks with a\n\t// stripped PATH — that constraint does not apply to a user shell.)\n\tCommand = \"commitbrief\"\n)\n```\n\n## Functions\n\n```go\nfunc IsValidName(name string) bool\n```\nIsValidName reports whether name is a safe shell alias identifier.\n\n## Types\n\n```go\ntype Installer interface {\n\t// Name is the machine id: \"bash\", \"zsh\", \"fish\", \"powershell\", \"cmd\".\n\tName() string\n\t// Label is the human-facing name shown in the shell picker.\n\tLabel() string\n\t// Target is the resolved destination (file path, or a short\n\t// description for the registry-backed cmd installer).\n\tTarget() string\n\t// Conflict returns a non-empty human reason when `alias` is already\n\t// taken outside our managed block — an existing definition in the\n\t// startup surface, or an executable of that name on PATH. Empty means\n\t// the name is free.\n\tConflict(alias string) (string, error)\n\t// Install writes/updates the managed alias and returns the shell\n\t// reload command the user should run (empty ⇒ \"restart your terminal\").\n\t// changed is false when the file already held the identical block.\n\tInstall(alias string) (changed bool, reloadCmd string, err error)\n}\n```\nInstaller knows how to write a managed alias into one shell's startup surface and how to detect a conflicting prior definition there.\n\n```go\nfunc All() []Installer\n```\nAll returns the shells we can install an alias for on this Unix-like OS: bash, zsh and fish.\n\n```go\nfunc ByName(name string) (Installer, bool)\n```\nByName returns the installer with the given machine name on the current OS, or false if it is unsupported here.\n\n```go\nfunc Detect() (Installer, bool)\n```\nDetect picks the installer matching the login shell ($SHELL). Returns false when $SHELL is unset or names a shell we do not support, so the caller can fall back to an interactive picker.\n\n","path":"github.com/CommitBrief/commitbrief/internal/alias","name":"alias","synopsis":"Package alias installs a shell alias (e.g.","isRedistributable":true}
