gerrit/contrib/bash_completion
David Pursehouse 3c08243c50 Add bash completion script for gerrit.sh
The script provides tab-completion in the bash shell for the gerrit.sh
script.

It can be invoked on a per-shell basis, or included in the user's bash
profile to be made available on every login.

Change-Id: I7f8afb8885d42c30df909a0520a0c736b8735fb4
2013-08-22 16:18:42 +09:00

68 lines
2.4 KiB
Bash

# 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, point to 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 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"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
}
complete -F _gerrit_sh gerrit.sh