program.search

Synopsis

program.search <query> [name: value]...

Description

program.search ranks the cards of the program index against a query and emits the best program_card records with their score, highest first. It starts a pipeline and accepts no input.

The index merges the programs in PATH, the package databases (dpkg, rpm, pacman, Homebrew, winget, Scoop, Chocolatey), registered applications (desktop entries, Windows uninstall entries and application paths, macOS application bundles), the NAME lines of manual pages and the external catalogs of programs.catalogs. It works without configuration on the programs of the computer. The first call of a process builds the index; later calls reuse it while the files of every provider are unchanged. With programs.index_dir set, each provider is also kept in a cache file and a new process starts from it.

Query words are compared after folding: lower case, compatibility decomposition and no diacritics, so a query typed without diacritics matches a text with them. Common conjunctions and prepositions are ignored when other words remain. Each word scores 100 when it equals the program name, 40 when the name starts with it, 20 when the name contains it, 8 in the situations of use, 5 in the summary, 5 in the category and 3 in the guide description; a query whose every word is found somewhere gains 15. A word without any match is retried at half weight through the built-in table of synonyms, the synonyms of catalogs and a prefix stem of words of six characters or more. A program whose not_for entry covers every word of the query loses 30 points and gets the field instead with the program to use. Equal scores are ordered by provider priority and then by name. Results with no points are dropped.

A list of queries gives one ranked list per query; each record then has the field query.

kind keeps only programs, applications or standalone guides of the catalogs; the default all keeps every kind. installed: true keeps the programs that exist on this computer and installed: false the entries that do not; without it both are listed.

Parameters

Parameter Type Default Description
query text | list<text> required Task, topic or program name, or several queries with one result list each.
category text none Only programs in this category.
source list<enum(path|package|app|catalog)> [path, package, app, catalog] Sources searched.
limit int 15 Maximum number of programs, best match first.
kind enum(all|programs|apps|guides) all Kind of results.
installed bool none Only installed programs (true) or only catalog entries (false).

Input and output

Form Input Output
default none program_card

Each record carries the fields of program_card and the additional fields score, kind (program, app or guide), has_guide, category_source and, when they apply, query, instead, guide_name, guide_shared_with, overview, alternatives, catalog_path, manager, app_id and language.

Effect

Property Value
Category source
Effect read
Reversibility read
Implementation builtin

Providers that cannot be read, and providers cut by the time budget of the index, are reported as warnings (source_unavailable, index_partial); the command still returns the results of the other providers.

Examples

Find programs for a task.

program.search "convert video" limit: 5
name     category  summary
ffmpeg   video     Converts and streams audio and video.
handbrake video    Transcodes video files.

Search only the installed packages and the search path.

program.search "pdf merge" source: [path, package] |> select name path score

Run two queries at once and keep the best match of each.

program.search ["compress files", "edit images"] limit: 1 |> select query name

Errors

Code Meaning Typical fix
E_MISSING_PARAM No query was given. Pass a query.
E_ARG A query is shorter than 2 or longer than 200 characters. Shorten or extend the query.
E_INVALID_VALUE limit is outside 1 to 60, more than 8 queries were given, or the category is unknown; candidates lists the nearest categories. Correct the value, or list the categories with program.catalog.
E_CATALOG source names a program catalog that is not configured or cannot be read. Check programs.catalogs.

program.describe, program.catalog, program.find.

Source file on GitHub: docs/commands/program.search.md