How to create your own Homebrew repo?

I this post I will show you in a Step-by-Step guide how cou can create your own Homebrew repository on GitHub.

What is Homebrew?

Homebrew is the missing package manager for macOS. It installs packages with a simple command like brew install curl. It can be used on Linux too. Homebrew taps are third-party repositories. You can create your own repository and host on GitHub.

In this article I will use tmux-cssh script as the program I will share by Homebrew.

Create Git repo

To host a Homebrew tap you just need to create a GitGub git repository with the naming convention homebrew-<name>. I called homebrew-devopstales.

git clone
cd homebrew-devopstales
echo "# homebrew-devopstales" >>                                  
git init
git add
git commit -m "first commit"
git branch -M main
git remote add origin
git push -u origin main

I will use this repo to host the tmux-cssh script too on another branch, but you can use It’s own repo.

git checkout -b tmux-cssh
cp /usr/local/sbin/tmux-cssh .
git add -A
git commit -m "tmux-cssh"
git push --set-upstream origin tmux-cssh
git tag tmux-cssh_1.0
git commit -m "tmux-cssh_1.0"
git push origin --tags

I cerated a teg to use It’s tar.gz in the release file of the package in Homebrew tap.

release tar.gzm

Right click on the tar.gz and sopy the link address. Now we go back the main branch and generate the release file for brew.

git checkout main
brew create

It will show the content of the created file in your default text editor. Save the file and move to this git repo.

cp /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/homebrew-devopstales.rb tmux-cssh.rb

Edit the tmux-cssh.rb file:

class TmuxCssh < Formula
  desc "tmux-css allow parallel execution of cmmands on remote servers"
  homepage ""
  url ""
  sha256 "ce761f21fa0fe7050f408e687f9a4964acf95736c85678e3cc27cee88bd6ceed"
  version "1.0"

  depends_on "tmux"

  def install
    bin.install "tmux-cssh"

  test do
    system "#{bin}/tmux-cssh", "--help"

If you have directories, you can use Dir["lib"] to install directories or use prefix.install to copy files:

def install    
    bin.install "tmux-cssh"    
    bin.install Dir["lib"]    
    bin.install Dir["files"]
    prefix.install ""
    prefix.install "LICENSE"  

Once it is ready, add the file, commit, and push.

git add -A
git commit -m "tmux-cssh_1.0"
git push

Now your tap is ready. Run the following commands to use it:

brew tap devopstales/devopstales
brew install tmux-cssh

For update you just generate a new rb file with brew create command and the new tar.gz archive. Then change the url and sha256 fields in tmux-cssh.rb.