Open RonaldBarnes opened 1 year ago
bash-add-alias.sh
User is prompted before any changes made:
# . ./bash-add-alias.sh
Web server user name: "www-data".
Alias for occ command not found for user "root".
Run "alias occ='sudo --user www-data php /var/www/nextcloud/occ'" (y/N)? Y
alias occ='sudo --user www-data php /var/www/nextcloud/occ'
Add alias to /root/.bash_aliases? (y/N) N
Add alias to /home/ron/.bash_aliases? (y/N) N
Run bash completion script complete.occ? (Y/n) Y
Running /var/www/nextcloud/complete.occ ... success.
Add complete.occ to /etc/bash_completion.d? (y/N) N
DONE.
occ
tab completionRun occ
successfully from any directory, not just in the nextcloud directory (no occ
in current dir in this example):
root@(dell):/tmp/nextcloud-occ-bash-completion# occ[TAB]
activity: encryption: memories: text:
app: federation: notification: theming:
background: files: onlyoffice: trashbin:
background-job: group: preview: twofactorauth:
broadcast: help recognize: update:
check integrity: security: upgrade
circles: l10n: serverinfo: user:
config: list sharing: versions:
dav: log: status workflows:
db: maintenance: tag:
deck: maps: talk:
root@(dell):/tmp/nextcloud-occ-bash-completion# occ
occ
tab completion for options / switchesAccess all options / switches by starting word with -
:
root@(dell):/tmp/nextcloud-occ-bash-completion# occ -[TAB]
--ansi --no-ansi --quiet --version
-h --no-interaction -v -vv
--help --no-warnings -V -vvv
-n -q --verbose
root@(dell):/tmp/nextcloud-occ-bash-completion# occ -
Would also love to see this!
Once implemented, it should be easy to port it to zsh
and fish
shell as well.
How to use GitHub
Is your feature request related to a problem? Please describe. Having bash tab/auto completion for
occ
would make administration much easier.The current method is not discoverable (multiple NextCloud admins had no idea it existed), and requires fiddling with file ownership / permissions. #14309, https://github.com/stecman/symfony-console-completion/issues/71.
Describe the solution you'd like A method of invoking bash tab completion that is obvious and works like other bash completions.
Describe alternatives you've considered A script,
bash-add-alias.sh
that willocc
, etc.)alias occ='sudo --user www-data php /var/www/nextcloud/occ'
~/.bash_aliases
for persistenceSUDO_USER
's.bash_aliases
for persistencecomplete.occ
script to enable bash tab completioncomplete.occ
script to directory so it's run each time bash is started/etc/bash_completion.d/
)/etc/bash_completion.d/complete.occ
occ
is the same as the web server user detectedAdditional context Pull request is ready for testing. Needs better OS agnostic support (i.e. different web server user names and bash_completion.d directory locations).