Last active
August 29, 2015 14:20
-
-
Save alxscms/db078ead07ff483bfa80 to your computer and use it in GitHub Desktop.
Bash script for gitignore.io with autocompletion, to paste in .bash_profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gitignore function working with gitignore.io | |
function gitignore() { | |
local IFS=","; | |
if [[ "$#" -eq 0 ]]; then | |
echo "gitignore: try 'gitignore --help' for more information" | |
elif [[ "$1" == "--help" || "$1" == "-h" ]]; then | |
echo "Usage: gitignore [options] <arguments separated by spaces>" | |
echo " -h, --help: show help" | |
echo " -l, --list: list all possible arguments" | |
echo " -s, --save: save the output to a .gitignore file" | |
elif [[ "$1" == "--list" || "$1" == "-l" ]]; then | |
curl -L -s https://www.gitignore.io/api/list; | |
elif [[ "$1" == "--save" || "$1" == "-s" ]]; then | |
if [[ "$#" -eq 1 ]]; then | |
echo "gitignore: try 'gitignore --help' for more information" | |
else | |
curl -L -s https://www.gitignore.io/api/"$*" >> .gitignore; | |
fi | |
else | |
curl -L -s https://www.gitignore.io/api/"$*"; | |
fi | |
} | |
# autocomplete | |
function _gitignore() { | |
local cur=${COMP_WORDS[COMP_CWORD]} | |
COMPREPLY=( $(compgen -W "actionscript ada agda android anjuta appceleratortitanium appcode appengine archives archlinuxpackages autotools basercms bluej bower bricxcc c c++ cakephp carthage cfwheels chefcookbook clojure cloud9 cmake codeigniter codeio codekit commonlisp composer concrete5 coq craftcms crashlytics cuda cvs dart darteditor delphi django dm dotsettings dreamweaver drupal eagle eclipse eiffelstudio elasticbeanstalk elisp elixir emacs ensime episerver erlang espresso expressionengine extjs fancy finale flexbuilder forcedotcom fortran freepascal fuelphp gcov gitbook go gradle grails greenfoot grunt gwt haskell idris igorpro intellij ipythonnotebook jabref java jboss jdeveloper jekyll jetbrains joe joomla jspm justcode jython kate kdevelop4 kirby2 kohana komodoedit labview laravel latex lazarus leiningen lemonstand liberosoc librarian-chef libreoffice lilypond linux lithium lua lyx m2e magento matlab maven mercurial mercury metaprogrammingsystem meteor microsoftoffice modelsim momentics monodevelop nanoc netbeans nette nim ninja node notepadpp objective-c ocaml opa opencart openfoam oracleforms osx packer perl ph7cms phalcon phpstorm pinegrow playframework plone premake-gmake prestashop processing puppet-librarian pycharm python qooxdoo qt r rails redcar redis rhodesrhomobile ros ruby rubymine rust sass sbt scala scons scrivener sdcc seamgen senchatouch silverstripe sketchup slickedit stella stellar sublimetext sugarcrm svn swift symfony symphonycms synopsysvcs tags tarmainstallmate tex textmate textpattern tortoisegit tower turbogears2 typo3 umbraco unity vagrant vim virtualenv visualstudio vvvv waf wakanda webmethods webstorm windows wintersmith wordpress xamarinstudio xcode xilinxise xojo yeoman yii zendframework zephir" -- $cur) ) | |
} | |
complete -F _gitignore gitignore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment