Map

Zsh: select generated files with `(om[1])` glob qualifiers

Zsh: select generated files with (om[1]) glob qualifiers

Author: Adam Johnson Date: 2026-01-27 Source: https://adamj.eu/tech/2026/01/27/zsh-om1-glob-qualifiers/

The Problem

When using memray (a Python memory profiler), the workflow requires three separate commands:

  1. Run the profiler: memray run manage.py check
  2. Generate a flame graph: memray flamegraph memray-manage.py.60450.bin
  3. Open the result: open -a Firefox memray-flamegraph-manage.py.60450.html

Commands 1 and 2 generate files whose names need copying to the next one. The naming pattern is predictable, but the process ID changes with each run.

The Solution

Zsh glob qualifiers allow you to add filtering syntax to filename patterns. The specific qualifiers om[1] mean:

  • o: sort the matches
  • m: by modification time (most recent first)
  • [1]: select only the first result

Implementation

Instead of manually copying filenames:

$ memray flamegraph memray-*.bin(om[1])

Collapsing the entire workflow into one command:

$ memray run manage.py check && memray flamegraph memray-*.bin(om[1]) && open -a Firefox memray-flamegraph-*.html(om[1])