Skip to content

Instantly share code, notes, and snippets.

@JosephKu
Created January 30, 2012 05:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JosephKu/1702715 to your computer and use it in GitHub Desktop.
Save JosephKu/1702715 to your computer and use it in GitHub Desktop.
Bash-completion formula for HomeBrew
require 'formula'
class BashCompletion < Formula
url 'http://pkgs.fedoraproject.org/repo/pkgs/bash-completion/bash-completion-1.3.tar.bz2/a1262659b4bbf44dc9e59d034de505ec/bash-completion-1.3.tar.bz2'
homepage 'http://bash-completion.alioth.debian.org/'
md5 'a1262659b4bbf44dc9e59d034de505ec'
head 'git://git.debian.org/git/bash-completion/bash-completion.git'
def install
inreplace "bash_completion" do |s|
s.gsub! '/etc/bash_completion', "#{etc}/bash_completion"
s.gsub! 'readlink -f', "readlink"
end
if ARGV.build_head?
system "aclocal"
system "autoconf"
system "automake --add-missing"
system "./configure", "--prefix=#{prefix}"
inreplace 'Makefile' do |s|
s.change_make_var! "pkgconfigdir", "#{lib}/pkgconfig"
end
else
system "./configure", "--prefix=#{prefix}"
end
system "make install"
# Cause the build to fails if you haven't already installed git or something else that
# creates a bash_completion.d
# ln_s "#{HOMEBREW_PREFIX}/Library/Contributions/brew_bash_completion.sh", "#{etc}/bash_completion.d" unless
# File.exists? "#{etc}/bash_completion.d/brew_bash_completion.sh" or File.symlink? "#{etc}/bash_completion.d/brew_bash_completion.sh"
end
def caveats
if ARGV.build_head?
<<-EOS.undent
Add the following lines to your ~/.bash_profile file:
if [ -f `brew --prefix`/share/bash-completion/bash_completion ]; then
. `brew --prefix`/share/bash-completion/bash_completion
fi
Some formula install their own completion scripts. To use them with the
HEAD version of bash-completion, link them into
#{HOMEBREW_PREFIX}/share/bash-completion/completions
To install Homebrew's own completion script:
ln -s "#{HOMEBREW_PREFIX}/Library/Contributions/brew_bash_completion.sh" "#{HOMEBREW_PREFIX}/share/bash-completion/completions"
EOS
else
<<-EOS.undent
Add the following lines to your ~/.bash_profile file:
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
To install Homebrew's own completion script:
ln -s "#{HOMEBREW_PREFIX}/Library/Contributions/brew_bash_completion.sh" "#{etc}/bash_completion.d"
EOS
end
end
end
@JosephKu
Copy link
Author

To install this formula, right-click 'raw' at the top-right corner of the text area, copy URL, and run the following command:

$ brew install <paste-URL-here>

If you want to download this formula to /usr/local/Library/Formula/, and install it locally, run the following command:

$ curl <paste-URL-here> -o /usr/local/Library/Formula/bash-completion.rb
$ brew install bash-completion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment