-
-
Notifications
You must be signed in to change notification settings - Fork 191
Adds shell completions for lychee #1972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mre
wants to merge
9
commits into
master
Choose a base branch
from
add-shell-completions
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
556593b
Adds shell completions for lychee
mre c0a608f
add temporary test completions workflow
mre b1a1ba5
Configure doc-valid-idents for rustdoc and clippy
mre e64b09c
cleanup
mre 5f7bb2a
cleanup
mre c765094
fix doc test
mre d120d40
Add `make completions`
mre 78eb112
Avoid rebuilding binary for testing shell completions
mre 4a88fa9
Clean up autogenerated shell-completions
mre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| name: Test Completions Generation | ||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| branches: | ||
| - add-shell-completions | ||
|
|
||
| jobs: | ||
| test-linux: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: dtolnay/rust-toolchain@stable | ||
|
|
||
| - name: Build binary | ||
| run: cargo build --release --features vendored-openssl | ||
|
|
||
| - name: Test completion generation | ||
| run: | | ||
| BIN="target/release/lychee" | ||
| chmod +x $BIN | ||
|
|
||
| # Test all completion types | ||
| echo "Testing Bash completion..." | ||
| $BIN --generate complete-bash > /tmp/lychee.bash | ||
|
|
||
| echo "Testing Elvish completion..." | ||
| $BIN --generate complete-elvish > /tmp/lychee.elv | ||
|
|
||
| echo "Testing Fish completion..." | ||
| $BIN --generate complete-fish > /tmp/lychee.fish | ||
|
|
||
| echo "Testing PowerShell completion..." | ||
| $BIN --generate complete-powershell > /tmp/_lychee.ps1 | ||
|
|
||
| echo "Testing Zsh completion..." | ||
| $BIN --generate complete-zsh > /tmp/_lychee | ||
|
|
||
| # Verify files were created and are not empty | ||
| for file in /tmp/lychee.bash /tmp/lychee.elv /tmp/lychee.fish /tmp/_lychee.ps1 /tmp/_lychee; do | ||
| if [ ! -s "$file" ]; then | ||
| echo "Error: $file is empty or missing" | ||
| exit 1 | ||
| fi | ||
| echo "✓ $(basename $file): $(wc -l < $file) lines" | ||
| done | ||
|
|
||
| echo "✅ All completions generated successfully!" | ||
|
|
||
| test-macos: | ||
| runs-on: macos-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: dtolnay/rust-toolchain@stable | ||
|
|
||
| - name: Build and test completions | ||
| run: | | ||
| cargo build --release | ||
| BIN="target/release/lychee" | ||
|
|
||
| # Quick test | ||
| $BIN --generate complete-bash > /tmp/test.bash | ||
| $BIN --generate complete-fish > /tmp/test.fish | ||
| $BIN --generate complete-zsh > /tmp/test.zsh | ||
|
|
||
| echo "✅ macOS completions work!" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| doc-valid-idents = ["PowerShell", ".."] |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| # Shell Completions for lychee | ||
|
|
||
| This directory contains shell completion scripts for lychee. | ||
| It unlocks tab-completion for commands, options, and arguments in your shell! | ||
|
|
||
| ## Quick Reference | ||
|
|
||
| Generate completions for your shell: | ||
|
|
||
| ```bash | ||
| lychee --generate complete-bash # Bash | ||
| lychee --generate complete-elvish # Elvish | ||
| lychee --generate complete-fish # Fish | ||
| lychee --generate complete-powershell # PowerShell | ||
| lychee --generate complete-zsh # Zsh | ||
| ``` | ||
|
|
||
| ## Installation | ||
|
|
||
| ### Bash | ||
|
|
||
| **User installation:** | ||
| ```bash | ||
| dir="${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion" | ||
thomas-zahner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| mkdir -p "$dir" | ||
| lychee --generate complete-bash > "$dir/lychee.bash" | ||
| ``` | ||
|
|
||
| Then source it in your `~/.bashrc` or `~/.bash_profile`: | ||
| ```bash | ||
| source "$dir/lychee.bash" | ||
| ``` | ||
|
|
||
| **System-wide installation:** | ||
| ```bash | ||
| # On Linux | ||
| sudo lychee --generate complete-bash > /usr/share/bash-completion/completions/lychee | ||
|
|
||
| # On macOS with Homebrew | ||
| lychee --generate complete-bash > $(brew --prefix)/etc/bash_completion.d/lychee | ||
| ``` | ||
|
|
||
| ### Zsh | ||
|
|
||
| **Recommended approach:** | ||
|
|
||
| ```zsh | ||
| dir="$HOME/.zsh-completions" | ||
| mkdir -p "$dir" | ||
| lychee --generate complete-zsh > "$dir/_lychee" | ||
| ``` | ||
|
|
||
| Add to your `~/.zshrc`: | ||
| ```zsh | ||
| fpath=($HOME/.zsh-completions $fpath) | ||
| autoload -Uz compinit && compinit | ||
| ``` | ||
|
|
||
| **System-wide installation:** | ||
| ```bash | ||
| # On Linux | ||
| sudo lychee --generate complete-zsh > /usr/local/share/zsh/site-functions/_lychee | ||
|
|
||
| # On macOS with Homebrew | ||
| lychee --generate complete-zsh > $(brew --prefix)/share/zsh/site-functions/_lychee | ||
| ``` | ||
|
|
||
| **Alternative (slower, not recommended for daily use):** | ||
|
|
||
| You can generate completions on-the-fly by adding this to `~/.zshrc`: | ||
| ```zsh | ||
| source <(lychee --generate complete-zsh) | ||
| ``` | ||
|
|
||
| Note: This is easier to set up but slower, adding startup time to your shell. | ||
|
|
||
| ### Fish | ||
|
|
||
| **User installation:** | ||
| ```bash | ||
| dir="${XDG_CONFIG_HOME:-$HOME/.config}/fish/completions" | ||
| mkdir -p "$dir" | ||
| lychee --generate complete-fish > "$dir/lychee.fish" | ||
| ``` | ||
|
|
||
| Fish will automatically load the completions on next shell start. | ||
|
|
||
| **System-wide installation:** | ||
| ```bash | ||
| # On Linux | ||
| sudo lychee --generate complete-fish > /usr/share/fish/vendor_completions.d/lychee.fish | ||
|
|
||
| # On macOS with Homebrew | ||
| lychee --generate complete-fish > $(brew --prefix)/share/fish/vendor_completions.d/lychee.fish | ||
| ``` | ||
|
|
||
| ### Elvish | ||
|
|
||
| ```bash | ||
| dir="${XDG_CONFIG_HOME:-$HOME/.config}/elvish/lib" | ||
| mkdir -p "$dir" | ||
| lychee --generate complete-elvish > "$dir/lychee.elv" | ||
| ``` | ||
|
|
||
| Then add the following to your `~/.elvish/rc.elv`: | ||
| ```elvish | ||
| use lychee | ||
| ``` | ||
|
|
||
| **PowerShell:** Verify your execution policy allows running scripts: | ||
| ```powershell | ||
| Get-ExecutionPolicy | ||
| # If restricted, run: | ||
| Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser | ||
| ``` | ||
|
|
||
| ### Updating completions | ||
|
|
||
| After upgrading lychee, regenerate completions to get the latest options: | ||
| ```bash | ||
| lychee --generate complete-<your-shell> > <completion-file> | ||
| ``` | ||
|
|
||
| ### PowerShell | ||
|
|
||
| **Windows:** | ||
|
|
||
| Generate the completion file: | ||
| ```powershell | ||
| lychee --generate complete-powershell | Out-File -Encoding UTF8 _lychee.ps1 | ||
| ``` | ||
|
|
||
| Then add to your PowerShell profile: | ||
| ```powershell | ||
| # Find your profile location | ||
| echo $PROFILE | ||
|
|
||
| # Add this line to your profile | ||
| . C:\Path\To\_lychee.ps1 | ||
| ``` | ||
|
|
||
| **Linux/macOS with PowerShell:** | ||
| ```bash | ||
| lychee --generate complete-powershell > ~/.config/powershell/_lychee.ps1 | ||
| ``` | ||
|
|
||
| Add to your profile (`~/.config/powershell/Microsoft.PowerShell_profile.ps1`): | ||
| ```powershell | ||
| . ~/.config/powershell/_lychee.ps1 | ||
| ``` | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a test file to see if the workflow passes and generates those completion files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we remove this workflow before merging, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes yes