homebrew-core/Formula/fzf.rb
2015-06-05 14:47:57 +01:00

61 lines
2 KiB
Ruby

require "formula"
require "language/go"
class Fzf < Formula
desc "Fuzzy finder for your shell"
homepage "https://github.com/junegunn/fzf"
url "https://github.com/junegunn/fzf/archive/0.9.12.tar.gz"
sha256 "644f741530120856c4bd8e63b95174af172c85a2c378eaf87db9e8e4717aabb3"
head 'https://github.com/junegunn/fzf.git'
bottle do
sha256 "285db0bacd6a94a1451fea10aede60d0ed279a4a5f33e0acc6183b2856682bd9" => :yosemite
sha256 "a86b5e5b95cef5e8a7f641c7aff666683ba45d322f5728ad2366bcdcc2545173" => :mavericks
sha256 "cbcb6535430eb6b404f023448705591d3a9767d20b973855e80fac73a80972c2" => :mountain_lion
end
depends_on "go" => :build
go_resource "github.com/junegunn/go-shellwords" do
url "https://github.com/junegunn/go-shellwords.git",
:revision => "35d512af75e283aae4ca1fc3d44b159ed66189a4"
end
go_resource "github.com/junegunn/go-runewidth" do
url "https://github.com/junegunn/go-runewidth.git",
:revision => "63c378b851290989b19ca955468386485f118c65"
end
def install
ENV["GOPATH"] = buildpath
mkdir_p buildpath/"src/github.com/junegunn"
ln_s buildpath, buildpath/"src/github.com/junegunn/fzf"
Language::Go.stage_deps resources, buildpath/"src"
cd buildpath/"src/fzf" do
system "go", "build"
bin.install "fzf"
end
prefix.install %w[install uninstall LICENSE]
(prefix/"shell").install %w[bash zsh fish].map { |s| "shell/key-bindings.#{s}" }
(prefix/"shell").install %w[bash zsh].map { |s| "shell/completion.#{s}" }
(prefix/"plugin").install "plugin/fzf.vim"
man1.install "man/man1/fzf.1"
bin.install "bin/fzf-tmux"
end
def caveats; <<-EOS.undent
To install useful keybindings and fuzzy completion:
#{prefix}/install
To use fzf in Vim, add the following line to your .vimrc:
set rtp+=#{prefix}
EOS
end
test do
(testpath/"list").write %w[hello world].join($/)
assert_equal "world", shell_output("cat #{testpath}/list | #{bin}/fzf -f wld").chomp
end
end