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.13.4.tar.gz" sha256 "ba561de9393c7f5604f3463c0d48960b86690afe8396f2c9672d3c4777960c7c" head "https://github.com/junegunn/fzf.git" bottle do cellar :any_skip_relocation sha256 "a8ef2f7a95a4f99825283b86ae6aecafa3665b21e42eb383dfb919a86a4f4458" => :el_capitan sha256 "74e925272f58a3302747da2cde972dfce9123f915649868ac2fdda05d554c1da" => :yosemite sha256 "e9cb6ae57255e5d97d0e242a55657d89e476906fbdfdbecd66ed5019057e7e3e" => :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", "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