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.19.0.tar.gz" sha256 "4d7ee0b621287e64ed450d187e5022d906aa378c5390d8c7c1f843417d2f3422" head "https://github.com/junegunn/fzf.git" bottle do cellar :any_skip_relocation sha256 "0be169ab230f6ff7b2322ee3d61fa0cd44e04300b688d207b67e910d948af442" => :catalina sha256 "5b5f429819576c27bab7bb658e3a99ae8043535e19d887fd9eaee954667ee715" => :mojave sha256 "19e9ba86b09129e06530b322f892ba89fb1db3173219ca0228cc0fe2d8281fbc" => :high_sierra end depends_on "go" => :build uses_from_macos "ncurses" def install ENV["GOPATH"] = HOMEBREW_CACHE/"go_cache" system "go", "build", "-o", bin/"fzf", "-ldflags", "-X main.revision=brew" prefix.install "install", "uninstall" (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 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($INPUT_RECORD_SEPARATOR) assert_equal "world", shell_output("cat #{testpath}/list | #{bin}/fzf -f wld").chomp end end