homebrew-core/Formula/fzf.rb
2015-10-18 17:23:19 +08:00

61 lines
2 KiB
Ruby

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.10.8.tar.gz"
sha256 "95ba7d39a311609f69d63bc2272f97aec92c974fe5a9560a4a0730b95828e4f4"
head "https://github.com/junegunn/fzf.git"
bottle do
cellar :any_skip_relocation
sha256 "144be5b8543cc4d47a5fb3b26d78b2fe2b74ef7cafd8e09e50d2a13caf073f0b" => :el_capitan
sha256 "9e8eab253bd1c68d44696d8fc90199095a5fba812def68b18918ea909a7de7f8" => :yosemite
sha256 "67396cdcbc633f70230ebd47ec92a807d3c6a914e29eaea2a5e3aaed0f62b9b6" => :mavericks
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:
#{opt_prefix}/install
To use fzf in Vim, add the following line to your .vimrc:
set rtp+=#{opt_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