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

April 8, 2026
Retro flip-style airport departure board showing international flight destinations and times.
Photo by Bor Jinson on Pexels

What happened?

Adam Johnson highlighted a tiny but powerful Zsh trick for a common annoyance: chaining commands that produce PID-stamped files. He demonstrated using memray — a Python memory profiler — which emits profiles and HTML flamegraphs with the process ID embedded in the filename. It has been reported that those variable names make scripting awkward because you’d otherwise have to copy the freshly generated filename into the next command. Tiring, and easily avoidable.

How it works

The solution is Zsh glob qualifiers: append (om[1]) to a glob to sort matches by modification time (o + m) and pick the newest one ([1]). So instead of pasting a PID-filled filename, you can run: memray flamegraph memray-.bin(om[1]) and even chain the whole flow into a one-liner: memray run manage.py check && memray flamegraph memray-.bin(om[1]) && open -a Firefox memray-flamegraph-*.html(om[1]). Neat, huh? Relief in a single token.

Why it matters

This is a reminder that shells still hide productivity gold if you poke around. Zsh glob qualifiers are little time-savers that make everyday automation cleaner — a boon for people who live in terminals and tweak dotfiles for fun. Caveat: this is Zsh-specific; it won’t magically work in Bash without extra tooling. Still, for the Zsh crowd, it’s one of those tiny wins that feels disproportionately good. May your globs qualify as great.

Sources: adamj.eu, Lobsters