# Search workspaces

Source: https://libtmux.org/en/py/stable/workspace/cli/search/

> Search the fields of discovered workspace documents.

Search discovered workspace fields with regular expressions or literal strings.
Query terms combine with AND unless `--any` selects OR.

## Find a session name

```console
$ tmuxp search \
    --json \
    --fixed-strings \
    --field session \
    workspace
```

Field prefixes and repeated `--field` restrictions select name, session (`s`),
path ([`p`](<https://docs.python.org/3/library/pdb.html#pdbcommand-p>)), window (`w`) or pane data. `--ignore-case` ignores case;
`--smart-case` does so only when a pattern has no uppercase. `--word-regexp`
requires whole words and `--invert-match` selects nonmatches.

## Empty and invalid queries

The documented implementation emits no bytes for an empty search result,
including with `--json`. With no query, machine search can print human help and
return normally. An invalid regular expression can also produce no machine
output. Account for these outcomes before parsing stdout as JSON.

[Command source](https://github.com/tmux-python/tmuxp/blob/618b398acc05506d3c682906c36cdeb29dcfa1ff/src/tmuxp/cli/search.py).
