From bf03194c9c6cb36357035fbd1dbbef6a7bec2bbc Mon Sep 17 00:00:00 2001 From: Simon Whitaker Date: Fri, 4 May 2012 22:01:13 +0100 Subject: [PATCH] Added bash completion script for enhanced gibo joy --- README.md | 16 ++++++++++++ gibo-completion.bash | 58 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 gibo-completion.bash diff --git a/README.md b/README.md index fa8dafc..ec5963f 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,22 @@ For additional usage instructions, run `gibo` without arguments. Copy or symlink `gibo` into your $PATH. Done. +## Bash tab completion + +Bash users can enjoy the deluxe gibo experience by enabling tab +completion of available boilerplate names. + +Copy `gibo-completion.bash` into a `bash_completion.d` folder: + +* `/etc/bash_completion.d` +* `/usr/local/etc/bash_completion.d` +* `~/bash_completion.d` + +or copy it somewhere (e.g. ~/.gibo-completion.sh) and put the +following in your .bashrc: + + source ~/.gibo-completion.sh + ## Credits gibo was written by Simon Whitaker ([@s1mn](http://twitter.com/s1mn)) diff --git a/gibo-completion.bash b/gibo-completion.bash new file mode 100644 index 0000000..9f11358 --- /dev/null +++ b/gibo-completion.bash @@ -0,0 +1,58 @@ +#!bash +# +# Bash completion for gibo +# +# This is free and unencumbered software released into the public domain. +# +# Anyone is free to copy, modify, publish, use, compile, sell, or +# distribute this software, either in source code form or as a compiled +# binary, for any purpose, commercial or non-commercial, and by any +# means. +# +# In jurisdictions that recognize copyright laws, the author or authors +# of this software dedicate any and all copyright interest in the +# software to the public domain. We make this dedication for the benefit +# of the public at large and to the detriment of our heirs and +# successors. We intend this dedication to be an overt act of +# relinquishment in perpetuity of all present and future rights to this +# software under copyright law. +# +# 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 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. +# +# For more information, please refer to +# +# INSTALLATION +# +# First install gibo from +# https://github.com/simonwhitaker/gitignore-boilerplates +# +# Then copy this file into a bash_completion.d folder: +# +# /etc/bash_completion.d +# /usr/local/etc/bash_completion.d +# ~/bash_completion.d +# +# or copy it somewhere (e.g. ~/.gibo-completion.sh) and put the +# following in your .bashrc: +# +# source ~/.gibo-completion.sh +# +# CREDITS +# +# Written by Simon Whitaker + +_gibo() +{ + local cur opts + opts=$( find $HOME/.gitignore-boilerplates -name "*.gitignore" -exec basename \{\} .gitignore \; ) + cur="${COMP_WORDS[COMP_CWORD]}" + + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) +} +complete -F _gibo gibo