Version: @46af18b · History · Edit

Ripgrep Configuration for Font Development

Ripgrep is a command line file search tool known for its speed on large codebases. Here’s an approach to defining custom filtered ripgrep search types on Adobe feature, designspace, glyphs, glyphspackage, and UFO font development source files.

Create ripgrep Configuration File#

Create a ripgrep configuration file on the path ~/.ripgreprc and enter the following definitions:

# Custom types

This configuration creates six new search types, automatically filtering ripgrep searches on the defined file extensions. Our new types are:

  • dspace - *.designspace files
  • fea - *.fea files
  • glyphs - *.glyphs files
  • gpack - glyphspackage file types: *.plist, *.glyph
  • plist - *.plist files
  • ufo - UFO file types: *.designspace, *.fea, *.glyf, & *.plist files

If you prefer a different set of type names, modify the name after the equal sign and before the colon on each line of the ripgrep configuration file.

Export ripgrep Configuration Path Environment Variable#

Export the configuration file path in an environment variable. Add the following line to your shell configuration rc file:

export RIPGREP_CONFIG_PATH=~/.ripgreprc

and run source on the shell configuration file. My zsh shell configuration file is on the path ~/.zshrc, and I run it like this:

source ~/.zshrc

Modify the shell configuration file path with other shells (e.g., bash). Refer to your shell documentation for details.

The above source step is not necessary with new terminal launches. You should only need to use it if your terminal is open at the time that you edit your shell configuration file.

Use the Custom Filtered Search Types#

Ripgrep searches recursively by default. Navigate to the root level of your source repository before you run the commands below. Use the custom search types with the -t or --type command line option. I’ll use the short option in the examples below. Replace it with --type=[TYPE] syntax if you prefer the long option.

Search Adobe feature files#

rg -t fea [SEARCH TERM]

Search designspace files#

rg -t dspace [SEARCH TERM]

Search Glyphs files#

rg -t glyphs [SEARCH TERM]

Search glyphspackage files#

rg -t gpack [SEARCH TERM]

Search plist files#

rg -t plist [SEARCH TERM]

Search UFO files#

rg -t ufo [SEARCH TERM]

You may use these custom types with other ripgrep command line options. Refer to the ripgrep documentation, command line help (rg --help), and man page (man rg) documentation for the complete set of search features to customize the simple examples above.

⚡ Free Software Powered ⚡

Crunch · Fira Sans · Git · Hugo · JetBrains Mono · Kiss · Lato · Poppins · Space Mono · VS Code