fix(completions): install bash completions into all login + non-login rc files#288
Closed
sachiniyer wants to merge 2 commits intomainfrom
Closed
fix(completions): install bash completions into all login + non-login rc files#288sachiniyer wants to merge 2 commits intomainfrom
sachiniyer wants to merge 2 commits intomainfrom
Conversation
… rc files Bash login shells read .bash_profile (or .bash_login), not .bashrc. The previous logic preferred .bashrc when it existed, so on macOS Terminal and SSH setups where both files are present, completions never loaded in login shells. Mirror rustup's approach: append the snippet to every existing bash rc file (.bash_profile, .bash_login, .bashrc), creating .bashrc if none exist. Each file is written independently and skipped when the snippet is already present, so re-runs and partial installs converge. Fixes #267. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Closing — taking a different approach. Rather than a multi-file dotfile installer (rustup-style), we're going to switch |
5 tasks
sachiniyer
added a commit
that referenced
this pull request
May 9, 2026
…iles (#293) ## Summary - `detail completions [SHELL]` now prints the activation snippet (`eval ...` / `source <(...)` / etc.) to stdout and exits, instead of appending it to a chosen rc file. - Users wire it up however they want — e.g. `source <(detail completions bash)` in `.bashrc`, or copy the line into `.bash_profile` for login shells. This sidesteps the .bashrc-vs-.bash_profile login-shell question entirely (issue #267). - Same pattern as `kubectl completion`, `gh completion`, `terraform -install-autocomplete` peers — well-trodden territory and easy to document. - `SHELL` is an optional positional arg; default is still auto-detected from `$SHELL`. Supported shells unchanged: bash, zsh, fish, elvish, powershell. - `Completions` is now `is_silent() == true` so the auto-update notice on stderr doesn't fire every time a shell rc file evaluates `source <(detail completions bash)` at startup. Closes #267. Supersedes #288 (which tried a rustup-style multi-file install — closed in favour of this simpler pattern). ## Migration If you previously ran `detail completions` and it appended a `# Detail CLI shell completions` block to your rc file, you can leave it in place (the snippet is identical) or delete it and re-wire via `source <(detail completions bash)` instead. ## Test plan - [x] `cargo fmt --check` - [x] `cargo clippy -- -D warnings` (matches CI) - [x] `cargo test` — 290 lib + 18 integration passing, including new `print_snippet_*` tests and the `silent_for_completions` / `completions_*shell_arg` parser tests - [x] `cargo xtask check-help` — `docs/HELP.md` regenerated and in sync - [x] Manual: `cargo run -- completions bash` prints `eval "\$(COMPLETE=bash detail 2>/dev/null)"` to stdout 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rc_pathfor bash picked a single rc file (preferring.bashrc), but bash login shells read.bash_profile/.bash_logininstead — so on macOS Terminal and SSH setups where both files exist, completions never loaded in login shells..bash_profile,.bash_login,.bashrc), creating.bashrcif none exist. Each file is checked independently for the snippet and skipped if already present, so re-runs and partial installs converge.install_snippethelper andbash_rc_pathshelper so the per-file idempotency and the bash file-selection logic are unit-testable.Fixes #267.
Test plan
cargo fmt --checkcargo clippy -- -D warnings(matches CI)cargo test --lib— 298 passed, including new cases:bash_rc_paths_only_bashrcbash_rc_paths_only_bash_profilebash_rc_paths_both_existbash_rc_paths_all_three_existbash_rc_paths_neither_exists_creates_bashrcinstall_snippet_appends_to_new_fileinstall_snippet_preserves_existing_contentinstall_snippet_is_idempotentinstall_snippet_per_file_idempotency_across_bash_rcs🤖 Generated with Claude Code