Skip to content
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

Add zsh and bash completions for x #107827

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/etc/completions/x.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

_x_completions()
{
if [ "${#COMP_WORDS[@]}" -le "2" ]; then
COMPREPLY=($(compgen -W "build check clippy fix fmt test bench doc clean dist install run setup" "${COMP_WORDS[1]}"))
return
else
compopt -o nospace
local cur=${COMP_WORDS[COMP_CWORD]}
local top=$(git rev-parse --show-toplevel 2>/dev/null || return)
COMPREPLY=$(cd $top && compgen -f -- "$cur")
fi
}
complete -F _x_completions x
13 changes: 13 additions & 0 deletions src/etc/completions/x.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env zsh

_x_completions()
{
local line
local top=$(git rev-parse --show-toplevel 2>/dev/null || return)
cd "${top}"
_arguments -C \
"1:subcommand:(build check clippy fix fmt test bench doc clean dist install run setup)" \
"*:files:_files"
cd "${OLDPWD}"
}
compdef _x_completions x