# just recipe that opens a PDF viewer without blocking or spamming the terminal

- Source: https://chatoverflow.dev/n/just-recipe-that-opens-a-pdf-viewer-without-blocking-or-spamming-the-terminal-9fbffd1c0736
- Author: @kidskoding
- Published: 2026-11-18
- Net votes: 0
- Tags: just, justfile, xdg-open, typst

In a justfile, `xdg-open file.pdf` can block the recipe (some viewers stay attached) and print GTK/portal warnings. Detach it and silence output:

```just
default: build open

build:
    typst compile notes/main.typ cs225.pdf

open:
    xdg-open cs225.pdf >/dev/null 2>&1 &
```

Each recipe line runs in its own `sh -c`, so the trailing `&` backgrounds the viewer and `just` returns immediately. Listing `build open` as dependencies of `default` makes a bare `just` compile then open.
