mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 07:08:01 +00:00
Add View The Source For A Brew Formula as a Unix TIL
This commit is contained in:
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
|||||||
|
|
||||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||||
|
|
||||||
_1384 TILs and counting..._
|
_1385 TILs and counting..._
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -1410,6 +1410,7 @@ _1384 TILs and counting..._
|
|||||||
- [Use fzf To Change Directories](unix/use-fzf-to-change-directories.md)
|
- [Use fzf To Change Directories](unix/use-fzf-to-change-directories.md)
|
||||||
- [Use Regex Pattern Matching With Grep](unix/use-regex-pattern-matching-with-grep.md)
|
- [Use Regex Pattern Matching With Grep](unix/use-regex-pattern-matching-with-grep.md)
|
||||||
- [View A Web Page In The Terminal](unix/view-a-web-page-in-the-terminal.md)
|
- [View A Web Page In The Terminal](unix/view-a-web-page-in-the-terminal.md)
|
||||||
|
- [View The Source For A Brew Formula](unix/view-the-source-for-a-brew-formula.md)
|
||||||
- [Watch The Difference](unix/watch-the-difference.md)
|
- [Watch The Difference](unix/watch-the-difference.md)
|
||||||
- [Watch This Run Repeatedly](unix/watch-this-run-repeatedly.md)
|
- [Watch This Run Repeatedly](unix/watch-this-run-repeatedly.md)
|
||||||
- [Where Are The Binaries?](unix/where-are-the-binaries.md)
|
- [Where Are The Binaries?](unix/where-are-the-binaries.md)
|
||||||
|
|||||||
53
unix/view-the-source-for-a-brew-formula.md
Normal file
53
unix/view-the-source-for-a-brew-formula.md
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# View The Source For A Brew Formula
|
||||||
|
|
||||||
|
[Homebrew](https://brew.sh/) uses formulas to know how to install things. If
|
||||||
|
you want to see what a given thing's formula file (written in Ruby) looks like,
|
||||||
|
there are two ways to get at it.
|
||||||
|
|
||||||
|
If you already have the thing installed, the formula is available on your
|
||||||
|
machine. You can `cat` it to stdout with `brew cat`.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
❯ brew cat bat
|
||||||
|
```
|
||||||
|
|
||||||
|
Here is what `bat` looks like:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
class Bat < Formula
|
||||||
|
desc "Clone of cat(1) with syntax highlighting and Git integration"
|
||||||
|
homepage "https://github.com/sharkdp/bat"
|
||||||
|
url "https://github.com/sharkdp/bat/archive/v0.17.1.tar.gz"
|
||||||
|
sha256 "16d39414e8a3b80d890cfdbca6c0e6ff280058397f4a3066c37e0998985d87c4"
|
||||||
|
license "Apache-2.0"
|
||||||
|
|
||||||
|
depends_on "rust" => :build
|
||||||
|
|
||||||
|
uses_from_macos "zlib"
|
||||||
|
|
||||||
|
def install
|
||||||
|
ENV["SHELL_COMPLETIONS_DIR"] = buildpath
|
||||||
|
system "cargo", "install", *std_cargo_args
|
||||||
|
|
||||||
|
assets_dir = Dir["target/release/build/bat-*/out/assets"].first
|
||||||
|
man1.install "#{assets_dir}/manual/bat.1"
|
||||||
|
fish_completion.install "#{assets_dir}/completions/bat.fish"
|
||||||
|
zsh_completion.install "#{assets_dir}/completions/bat.zsh" => "_bat"
|
||||||
|
end
|
||||||
|
|
||||||
|
test do
|
||||||
|
pdf = test_fixtures("test.pdf")
|
||||||
|
output = shell_output("#{bin}/bat #{pdf} --color=never")
|
||||||
|
assert_match "Homebrew test", output
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
If you don't have the thing installed, you'll have to access the formula
|
||||||
|
remotely.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
❯ brew info --github bat
|
||||||
|
```
|
||||||
|
|
||||||
|
This will open up the formula on GitHub in your default browser.
|
||||||
Reference in New Issue
Block a user