-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add Bash and Zsh completion scripts #22646
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
6199e31
Add Bash and Zsh completion scripts
zeripath c5c3327
fix a small bug and enable bash completion on docker
zeripath 445380a
add docs and minor adjustment to zsh completion script
zeripath a98ade9
Update docs/content/doc/installation/from-source.en-us.md
zeripath 2d1019f
Apply suggestions from code review
zeripath f36a7b5
Merge branch 'main' into bash-completion
zeripath 38b60d1
Merge branch 'main' into bash-completion
zeripath e02a4e3
fix docker
zeripath 5252849
Update Dockerfile
zeripath 60baf88
Update Dockerfile.rootless
zeripath 023ef49
Update Dockerfile.rootless
zeripath 97bcdb5
Update Dockerfile
zeripath 2313621
Update docs/content/doc/installation/from-binary.en-us.md
zeripath 294138c
Merge branch 'main' into bash-completion
zeripath a97a62f
Merge branch 'main' into bash-completion
zeripath 0155ce7
Merge branch 'main' into bash-completion
zeripath 4002295
Merge branch 'main' into bash-completion
techknowlogick 5ea2808
Merge branch 'main' into bash-completion
techknowlogick 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
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,17 @@ | ||
Bash and Zsh completion | ||
======================= | ||
|
||
From within the gitea root run: | ||
|
||
```bash | ||
source contrib/autocompletion/bash_autocomplete | ||
``` | ||
|
||
or for zsh run: | ||
|
||
```bash | ||
source contrib/autocompletion/zsh_autocomplete | ||
``` | ||
|
||
These scripts will check if gitea is on the path and if so add autocompletion for `gitea`. Or if not autocompletion will work for `./gitea`. | ||
If gitea has been installed as a different program pass in the `PROG` environment variable to set the correct program name. |
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,30 @@ | ||
#! /bin/bash | ||
# Heavily inspired by https://github.com/urfave/cli | ||
|
||
_cli_bash_autocomplete() { | ||
if [[ "${COMP_WORDS[0]}" != "source" ]]; then | ||
local cur opts base | ||
COMPREPLY=() | ||
cur="${COMP_WORDS[COMP_CWORD]}" | ||
if [[ "$cur" == "-"* ]]; then | ||
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion ) | ||
else | ||
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion ) | ||
fi | ||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | ||
return 0 | ||
fi | ||
} | ||
|
||
if [ -z "$PROG" ] && [ ! "$(command -v gitea &> /dev/null)" ] ; then | ||
complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete gitea | ||
elif [ -z "$PROG" ]; then | ||
complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete ./gitea | ||
complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete "$PWD/gitea" | ||
else | ||
complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete "$PROG" | ||
unset PROG | ||
fi | ||
|
||
|
||
|
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,30 @@ | ||
#compdef ${PROG:=gitea} | ||
|
||
|
||
# Heavily inspired by https://github.com/urfave/cli | ||
|
||
_cli_zsh_autocomplete() { | ||
|
||
local -a opts | ||
local cur | ||
cur=${words[-1]} | ||
if [[ "$cur" == "-"* ]]; then | ||
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}") | ||
else | ||
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}") | ||
fi | ||
|
||
if [[ "${opts[1]}" != "" ]]; then | ||
_describe 'values' opts | ||
else | ||
_files | ||
fi | ||
|
||
return | ||
} | ||
|
||
if [ -z $PROG ] ; then | ||
compdef _cli_zsh_autocomplete gitea | ||
else | ||
compdef _cli_zsh_autocomplete $(basename $PROG) | ||
fi |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.