#!/bin/sh # # == System wide installation == # # --- bash --- # # To install system-wide autocompletion for bash, copy the complete contents of # this file to /etc/bash_completion.d/autocomplete.phtml.sh . # # The easiest way will be to run # # $ sudo /vendor/zfcampus/zf-console/views/autocomplete.phtml autocomplete > /etc/bash_completion.d/autocomplete.phtml.sh # $ source /etc/bash_completion.d/autocomplete.phtml.sh # # --- zsh --- # # To install system-wide autocompletion for zsh, copy the complete contents of # this file to /etc/zsh/autocomplete.phtml.sh, and run: # # $ sudo echo "source /etc/zsh/autocomplete.phtml.sh" >> /etc/zsh/zprofile # # == User installation only == # # --- bash --- # # $ /vendor/zfcampus/zf-console/views/autocomplete.phtml autocomplete >> ~/.bashrc # $ source ~/.bashrc # # --- zsh --- # # $ /vendor/zfcampus/zf-console/views/autocomplete.phtml autocomplete >> ~/.zshrc # $ source ~/.zshrc if [[ -n ${ZSH_VERSION-} ]]; then autoload -U +X bashcompinit && bashcompinit fi _complete_c17ef4d2c8e516151b2a007aa6dbefdb() { local cur COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" # Assume first word is the actual app/console command console="${COMP_WORDS[0]}" if [[ ${COMP_CWORD} == 1 ]] ; then # No command found, return the list of available commands cmds=` ${console} help | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" | grep "^ [a-z\-]\{1,\}[[:space:]]\{1,\}" | awk '{print $1}'` else # Commands found, parse options RESULT=`${console} ${COMP_WORDS[1]} --help` cmds=` echo "$RESULT" | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" | grep '^ -' | awk '{ print $1 }'` cmds=`echo -e "$cmds\n--help"` # --help is a non-existing option, BUT it will give back the help for a command which is what we want fi COMPREPLY=( $(compgen -W "${cmds}" -- ${cur}) ) return 0 } export COMP_WORDBREAKS="\ \"\\'><=;|&(" complete -F _complete_c17ef4d2c8e516151b2a007aa6dbefdb autocomplete.phtml