Skip to content

Instantly share code, notes, and snippets.

@gdugas
Created March 22, 2013 19:44
Show Gist options
  • Save gdugas/5224168 to your computer and use it in GitHub Desktop.
Save gdugas/5224168 to your computer and use it in GitHub Desktop.
basic jelix bash_completion
_jelix_completion()
{
local cur prev opts actions
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# Standalone options
opts=""
# Actions
actions="acl2group acl2right aclgroup aclright aclvalue cleartemp \
closeapp createaction createclassfromdao createctrl \
createdao createdaocrud createentrypoint createform \
createlangpackage createmodule createzone help initadmin \
installapp installmodule migrate openapp resetfilesrights"
if [[ # cmd.php
( ${COMP_CWORD} -eq 1 && ${COMP_WORDS[0]} == ./cmd.php ) ||
# php cmd.php
( ${COMP_CWORD} -eq 2 &&
$( basename -- ${COMP_WORDS[0]} ) == php?([1-9]\.[0-9]) &&
$( basename -- ${COMP_WORDS[1]} ) == cmd.php ) ]]; then
COMPREPLY=( $(compgen -W "${actions}" -- ${cur}) )
action=$COMPREPLY
return 0
else
case ${prev} in
help)
COMPREPLY=( $(compgen -W "${actions}" -- ${cur}) )
return 0
;;
*)
COMPREPLY=()
return 0
;;
esac
fi
}
complete -F _jelix_completion cmd.php
complete -F _jelix_completion php
@gdugas
Copy link
Author

gdugas commented Mar 22, 2013

Created with jelix 1.4.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment