Created
June 5, 2012 19:40
-
-
Save bobthecow/2877277 to your computer and use it in GitHub Desktop.
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
#!bash | |
# | |
# nanoc-completion | |
# ================ | |
# | |
# Bash completion support for nanoc | |
# | |
# | |
# Installation | |
# ------------ | |
# | |
# 1. Install this file. Either: | |
# | |
# a. Place it in a `bash-completion.d` folder: | |
# | |
# * /etc/bash-completion.d | |
# * /usr/local/etc/bash-completion.d | |
# * ~/bash-completion.d | |
# | |
# b. Or, copy it somewhere (e.g. ~/.nanoc-completion.sh) and put the following line in | |
# your .bashrc: | |
# | |
# source ~/.nanoc-completion.sh | |
# | |
# | |
# | |
# The Fine Print | |
# -------------- | |
# | |
# Copyright (c) 2012 [Justin Hileman](http://justinhileman.com) | |
# | |
# Distributed under the [MIT License](http://creativecommons.org/licenses/MIT/) | |
__nanoc () | |
{ | |
COMPREPLY=() | |
local cur="${COMP_WORDS[COMP_CWORD]}" | |
local prev="${COMP_WORDS[COMP_CWORD-1]}" | |
local subcommands="$(ruby -e 'require "nanoc" ; require "nanoc/cli" ; Nanoc::CLI.setup ; puts Nanoc::CLI.root_command.subcommands.map{|c|c.name}.join(" ")')" | |
[[ ${COMP_CWORD} -eq 1 ]] && { | |
COMPREPLY=( $(compgen -W "${subcommands}" -- ${cur}) ) | |
return | |
} | |
case "${prev}" in | |
help) | |
COMPREPLY=( $(compgen -W "${subcommands}" -- ${cur}) ) | |
return 0 | |
;; | |
*) | |
;; | |
esac | |
} | |
complete -F __nanoc nanoc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment