Skip to content

fix(completion): complete commands after pipe and other separators#1159

Open
Fanteria wants to merge 3 commits into
reubeno:mainfrom
Fanteria:main
Open

fix(completion): complete commands after pipe and other separators#1159
Fanteria wants to merge 3 commits into
reubeno:mainfrom
Fanteria:main

Conversation

@Fanteria

Copy link
Copy Markdown

Summary

  • Treat tokens that follow |, ||, &&, ;, or & as command position in Config::get_completions and get_completions_using_basic_lookup, so they complete from $PATH (commands, builtins, functions, aliases) instead of $PWD files.
  • Previously only the token at index 0 was treated as command position, so cat /dev/null | ec<TAB> would offer file matches (e.g. echoing_file) rather than echo.
  • Add integration tests covering completion after | and &&, asserting that the builtin appears and a same-prefix file in $PWD does not.

Known limitations

  • Coloring of these commands is not addressed in this PR.
  • Completion still differs from bash in some argument-position cases. For example, grep ec<TAB>: bash performs no completion (grep's first argument is a pattern with no completion spec), while brush falls back to $PATH completion.

Validation

  • cargo test -p brush-shell --test brush-completion-tests native_complete_command_after_pipe
  • cargo test -p brush-shell --test brush-completion-tests native_complete_command_after_and_operator
  • cargo clippy -p brush-core --all-targets
  • cargo +nightly fmt -- $(git diff --name-only HEAD -- '*.rs')

Manual verification

  1. Build this branch: cargo build --bin brush.
  2. In a directory containing a file like echoing_file, launch ./target/debug/brush.
  3. Type cat /dev/null | ec and press <TAB>, confirm it completes to echo and ecpg.
  4. Type true && ec and press <TAB>, confirm the same behavior.
  5. Type ec at the start of a line and press <TAB> — confirm echo and ecpg still complete.

Jiří Alexandrovič and others added 3 commits May 14, 2026 23:53
Tokens that follow |, ||, &&, ;, or & are in command position and
should complete from $PATH.
Assisted-by: Claude Sonnet 4.6 (claude.ai/code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant