Installing LilyPond

LilyPond is a command-line tool for engraving music. Although their application bundles are not supported on newer versions of macOS, you can install the latest LilyPond binary via MacPorts or Homebrew.

Install LilyPond using Homebrew.

$ brew install lilypond

Editing LilyPond files

If you enjoy using BBEdit to work with plain text, you can use the language module which I built for LilyPond for syntax highlighting. You can install the language module using Homebrew.

LilyPond syntax highlighting

Use Homebrew to install BBEdit.

$ brew install bbedit

The Saguaro Space BBEdit utilities contain the LilyPond language module and an engraving script.

$ brew tap saguarospace/saguarospace
$ brew install saguarospace-bbedit-utils

You will be prompted to run additional commands.

You can run the engraving script from within BBEdit by choosing “Engraving with LilyPond” from the scripts menu in the menu bar.

Using make

Makefiles are an easy way to document the steps necessary to build artifacts from source files (such as PDFs from LilyPond files).

Create a file named Makefile with the following contents in the same directory as your LilyPond files.

.PHONY: all clean

objects:= $(wildcard *.ly)
artifacts:= $(wildcard *.pdf)

# The build command
command = lilypond $(1).ly 2>&1 | tee -a $(1).log

# Generate all PDFs
all:  $(subst .ly,.pdf,$(objects))

# Generate a specific PDF
%.pdf: %.ly
	@$(call command,$(subst .pdf,,$@))

# Remove all PDFs
clean:
	rm -f $(artifacts)

Makefiles should use tabs - not spaces.

Build all the LilyPond files (in the directory with the Makefile).

$ make all

Build an individual file.

$ make <name-of-file>.pdf

Delete all PDFs in the directory.

$ make clean

Helpful Makefile documentation.

Watching LilyPond files for changes

entr is a command-line tool which can watch files and run arbitrary commands when they change.

Install entr with Homebrew.

$ brew install entr

You can use entr to run make whenever a LilyPond file changes. In the directory with your LilyPond files and Makefile, run:

$ find . *.ly | entr make all

You can create an alias to that command in your shell profile.

$ echo "alias watchly='find . *.ly | entr make all'" >> $HOME/.zshrc

Now when you enter a directory with LilyPond files and a Makefile, you can run watchly and the source files will be built automatically upon changes.

Live preview

Skim is a PDF reader which supports live reloading, meaning that if the currently open PDF is updated, Skim will automatically show you the new version. It can be installed with Homebrew.

$ brew install skim

To enable live reloading, go to Skim > Preferences… > Sync and select “Check file for changes” and “Reload automatically”.

Skim reload automatically

Further reading

This is the LilyPond setup which we use with macOS 12.0.1 at Happystring Music.