| David Pursehouse | 3c08243 | 2013-08-22 15:28:49 +0900 | [diff] [blame] | 1 | # The MIT License | 
|  | 2 | # | 
|  | 3 | # Copyright (C) 2013 Sony Mobile Communications. All rights reserved. | 
|  | 4 | # | 
|  | 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy | 
|  | 6 | # of this software and associated documentation files (the "Software"), to deal | 
|  | 7 | # in the Software without restriction, including without limitation the rights | 
|  | 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 
|  | 9 | # copies of the Software, and to permit persons to whom the Software is | 
|  | 10 | # furnished to do so, subject to the following conditions: | 
|  | 11 | # | 
|  | 12 | # The above copyright notice and this permission notice shall be included in | 
|  | 13 | # all copies or substantial portions of the Software. | 
|  | 14 | # | 
|  | 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 
|  | 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
|  | 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 
|  | 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 
|  | 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 
|  | 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | 
|  | 21 | # THE SOFTWARE. | 
|  | 22 | # | 
|  | 23 | # ######################################################################### | 
|  | 24 | # This bash script adds tab-completion to the gerrit.sh script. | 
|  | 25 | # | 
|  | 26 | # Testing it out without installing | 
|  | 27 | # ================================= | 
|  | 28 | # | 
|  | 29 | # To test out the completion without "installing" this, just run this file | 
|  | 30 | # directly, like so: | 
|  | 31 | # | 
|  | 32 | # . ~/path/to/bash_completion | 
|  | 33 | # | 
|  | 34 | # Note: There's a dot ('.') at the beginning of that command. | 
|  | 35 | # | 
|  | 36 | # After you do that, tab completion will immediately be made available in your | 
|  | 37 | # current Bash shell. It will not, however, be available next time you log in. | 
|  | 38 | # | 
|  | 39 | # Installing | 
|  | 40 | # ========== | 
|  | 41 | # | 
| David Pursehouse | 9d62c20 | 2013-09-27 10:18:30 +0900 | [diff] [blame] | 42 | # To install the completion, copy this file to the appropriate folder for | 
|  | 43 | # your distribution, for example: | 
|  | 44 | # | 
|  | 45 | # cp ~/path/to/bash_completion /etc/bash_completion.d/gerrit_sh | 
|  | 46 | # | 
|  | 47 | # Alternatively you can invoke this file from your .bash_profile, like so: | 
| David Pursehouse | 3c08243 | 2013-08-22 15:28:49 +0900 | [diff] [blame] | 48 | # | 
|  | 49 | # . ~/path/to/bash_completion | 
|  | 50 | # | 
|  | 51 | # Do the same in your .bashrc if .bashrc doesn't invoke .bash_profile. | 
|  | 52 | # | 
|  | 53 | # The settings will take effect the next time you log in. | 
|  | 54 | # | 
|  | 55 | # Uninstalling | 
|  | 56 | # ============ | 
|  | 57 | # | 
| David Pursehouse | 9d62c20 | 2013-09-27 10:18:30 +0900 | [diff] [blame] | 58 | # To uninstall, just remove the file from the bash completion folder, or | 
|  | 59 | # remove the line from your .bash_profile and .bashrc. | 
| David Pursehouse | 3c08243 | 2013-08-22 15:28:49 +0900 | [diff] [blame] | 60 | # ######################################################################### | 
|  | 61 |  | 
|  | 62 | _gerrit_sh() | 
|  | 63 | { | 
|  | 64 | local cur prev opts | 
|  | 65 | COMPREPLY=() | 
|  | 66 | cur="${COMP_WORDS[COMP_CWORD]}" | 
|  | 67 | prev="${COMP_WORDS[COMP_CWORD-1]}" | 
| Richard Fearn | 626327c | 2016-03-23 17:04:56 +0000 | [diff] [blame] | 68 | opts="check restart run start status stop supervise threads" | 
| David Pursehouse | 3c08243 | 2013-08-22 15:28:49 +0900 | [diff] [blame] | 69 |  | 
|  | 70 | COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | 
|  | 71 | } | 
|  | 72 | complete -F _gerrit_sh gerrit.sh | 
|  | 73 |  |