homebrew-core/Formula/fzf.rb
2016-09-29 00:39:42 -07:00

61 lines
2 KiB
Ruby

require "language/go"
class Fzf < Formula
desc "Command-line fuzzy finder written in Go"
homepage "https://github.com/junegunn/fzf"
url "https://github.com/junegunn/fzf/archive/0.15.3.tar.gz"
sha256 "aac1675bd4665b10addf2782fea7043bb6849e04d985360fb13db17264d03035"
head "https://github.com/junegunn/fzf.git"
bottle do
cellar :any_skip_relocation
sha256 "aa4bc2143a8928fb56f3a9710084fa93285ca9c6ae8f5e98caa3fe3a07b41589" => :sierra
sha256 "fb2d2495fd3b15dc0679cdb97b68920d775cc25cd49f5884b8bfd7c6ae103a0f" => :el_capitan
sha256 "fa0d203d6ca48abe2ee2aa47f3e7c53ff3e8eea93efcc346ef114a7f30f701aa" => :yosemite
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", "man/man1/fzf-tmux.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