#! bash # bash completion for the `rails` command. # # Copyright (c) 2008-2017 Daniel Luz . # Distributed under the MIT license. # http://mernen.com/projects/completion-ruby # # To use, source this file on bash: # . completion-rails # Sets $rails_command and $rails_subcommand __rails_get_command() { local i for ((i=1; i < $COMP_CWORD; ++i)); do local arg=${COMP_WORDS[$i]} case $arg in -b | --builder | -r | --ruby | --root | -m | --template |\ -s | --source | -e | --environment) # Ignore next argument ((++i)) ;; [^-]*) if [[ -n $rails_command ]]; then rails_subcommand=$arg return else rails_command=$arg case $arg in generate | g | destroy | plugin) # Continue processing, looking for a subcommand ;; *) # End processing return;; esac fi ;; esac done } __rails_complete_environments() { local environments=(config/environments/*.rb) if [[ -f $environments ]]; then environments=("${environments[@]##*/}") environments=("${environments[@]%.rb}") else environments=(development test production) fi COMPREPLY=($(compgen -W "${environments[*]}" -- "$1")) } # __rails_exec # __rails_exec \|