|  | # The MIT License | 
|  | # | 
|  | # Copyright (C) 2013 Sony Mobile Communications. All rights reserved. | 
|  | # | 
|  | # Permission is hereby granted, free of charge, to any person obtaining a copy | 
|  | # of this software and associated documentation files (the "Software"), to deal | 
|  | # in the Software without restriction, including without limitation the rights | 
|  | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 
|  | # copies of the Software, and to permit persons to whom the Software is | 
|  | # furnished to do so, subject to the following conditions: | 
|  | # | 
|  | # The above copyright notice and this permission notice shall be included in | 
|  | # all copies or substantial portions of the Software. | 
|  | # | 
|  | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 
|  | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
|  | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 
|  | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 
|  | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 
|  | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | 
|  | # THE SOFTWARE. | 
|  | # | 
|  | # ######################################################################### | 
|  | # This bash script adds tab-completion to the gerrit.sh script. | 
|  | # | 
|  | # Testing it out without installing | 
|  | # ================================= | 
|  | # | 
|  | # To test out the completion without "installing" this, just run this file | 
|  | # directly, like so: | 
|  | # | 
|  | #     . ~/path/to/bash_completion | 
|  | # | 
|  | # Note: There's a dot ('.') at the beginning of that command. | 
|  | # | 
|  | # After you do that, tab completion will immediately be made available in your | 
|  | # current Bash shell. It will not, however, be available next time you log in. | 
|  | # | 
|  | # Installing | 
|  | # ========== | 
|  | # | 
|  | # To install the completion, copy this file to the appropriate folder for | 
|  | # your distribution, for example: | 
|  | # | 
|  | #     cp ~/path/to/bash_completion /etc/bash_completion.d/gerrit_sh | 
|  | # | 
|  | # Alternatively you can invoke this file from your .bash_profile, like so: | 
|  | # | 
|  | #     . ~/path/to/bash_completion | 
|  | # | 
|  | # Do the same in your .bashrc if .bashrc doesn't invoke .bash_profile. | 
|  | # | 
|  | # The settings will take effect the next time you log in. | 
|  | # | 
|  | # Uninstalling | 
|  | # ============ | 
|  | # | 
|  | # To uninstall, just remove the file from the bash completion folder, or | 
|  | # remove the line from your .bash_profile and .bashrc. | 
|  | # ######################################################################### | 
|  |  | 
|  | _gerrit_sh() | 
|  | { | 
|  | local cur prev opts | 
|  | COMPREPLY=() | 
|  | cur="${COMP_WORDS[COMP_CWORD]}" | 
|  | prev="${COMP_WORDS[COMP_CWORD-1]}" | 
|  | opts="check restart run start status stop supervise threads" | 
|  |  | 
|  | COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | 
|  | } | 
|  | complete -F _gerrit_sh gerrit.sh | 
|  |  |