Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
dacce6a
feat(ack): declare completions in the completion language
philocalyst Nov 30, 2026
44c16ce
feat(adb): declare completions in the completion language
philocalyst Nov 30, 2026
cf5618f
feat(aerospace): declare completions in the completion language
philocalyst Nov 30, 2026
4fd585c
feat(ani-cli): declare completions in the completion language
philocalyst Nov 30, 2026
16b6400
feat(as): declare completions in the completion language
philocalyst Nov 30, 2026
dc71920
feat(aws): declare completions in the completion language
philocalyst Nov 30, 2026
6f79c3d
feat(bat): declare completions in the completion language
philocalyst Nov 30, 2026
0bce610
feat(bend): declare completions in the completion language
philocalyst Nov 30, 2026
f607352
feat(bitwarden-cli): declare completions in the completion language
philocalyst Nov 30, 2026
325396d
feat(bmc): declare completions in the completion language
philocalyst Nov 30, 2026
0018f4c
feat(btm): declare completions in the completion language
philocalyst Nov 30, 2026
25ae398
feat(cargo): declare completions in the completion language
philocalyst Nov 30, 2026
7e67ef0
feat(cargo-loco): declare completions in the completion language
philocalyst Nov 30, 2026
3b5d3c3
feat(cargo-make): declare completions in the completion language
philocalyst Nov 30, 2026
2263ab5
feat(claude): declare completions in the completion language
philocalyst Nov 30, 2026
e83fb05
feat(codex): declare completions in the completion language
philocalyst Nov 30, 2026
1fc776e
feat(composer): declare completions in the completion language
philocalyst Nov 30, 2026
7b629e3
feat(croc): declare completions in the completion language
philocalyst Nov 30, 2026
9d6b778
feat(curl): declare completions in the completion language
philocalyst Nov 30, 2026
b1544fc
feat(dart): declare completions in the completion language
philocalyst Nov 30, 2026
0bc976e
feat(docker): declare completions in the completion language
philocalyst Nov 30, 2026
4f25345
feat(dotnet): declare completions in the completion language
philocalyst Nov 30, 2026
30abd62
feat(eza): declare completions in the completion language
philocalyst Nov 30, 2026
7131b0c
feat(fastboot): declare completions in the completion language
philocalyst Nov 30, 2026
106f8e4
feat(flutter): declare completions in the completion language
philocalyst Nov 30, 2026
c43a267
feat(fsharpc): declare completions in the completion language
philocalyst Nov 30, 2026
fc8181f
feat(fsharpi): declare completions in the completion language
philocalyst Nov 30, 2026
223bd17
feat(gh): declare completions in the completion language
philocalyst Nov 30, 2026
749bba0
feat(git): declare completions in the completion language
philocalyst Nov 30, 2026
930aa71
feat(glow): declare completions in the completion language
philocalyst Nov 30, 2026
a6e2b6e
feat(godoc): declare completions in the completion language
philocalyst Nov 30, 2026
4db215e
feat(gradlew): declare completions in the completion language
philocalyst Nov 30, 2026
82e208c
feat(jj): declare completions in the completion language
philocalyst Nov 30, 2026
f70670b
feat(just): declare completions in the completion language
philocalyst Nov 30, 2026
dddc070
feat(komorebi): declare completions in the completion language
philocalyst Nov 30, 2026
7c04a8b
feat(kw): declare completions in the completion language
philocalyst Nov 30, 2026
5c83a57
feat(less): declare completions in the completion language
philocalyst Nov 30, 2026
a0c01f5
feat(lftp): declare completions in the completion language
philocalyst Nov 30, 2026
73c29cb
feat(loco): declare completions in the completion language
philocalyst Nov 30, 2026
d89e720
feat(lsd): declare completions in the completion language
philocalyst Nov 30, 2026
06308c0
feat(make): declare completions in the completion language
philocalyst Nov 30, 2026
310d006
feat(man): declare completions in the completion language
philocalyst Nov 30, 2026
76011ab
feat(mask): declare completions in the completion language
philocalyst Nov 30, 2026
5448da3
feat(md-to-clip): declare completions in the completion language
philocalyst Nov 30, 2026
a5775db
feat(mix): declare completions in the completion language
philocalyst Nov 30, 2026
531b912
feat(mvn): declare completions in the completion language
philocalyst Nov 30, 2026
00c8b08
feat(mysql): declare completions in the completion language
philocalyst Nov 30, 2026
e69683e
feat(nano): declare completions in the completion language
philocalyst Nov 30, 2026
b5fc73a
feat(nix): declare completions in the completion language
philocalyst Nov 30, 2026
23fc373
feat(npm): declare completions in the completion language
philocalyst Nov 30, 2026
8c01c8f
feat(op): declare completions in the completion language
philocalyst Nov 30, 2026
ba70203
feat(pass): declare completions in the completion language
philocalyst Nov 30, 2026
1fbcf55
feat(pdm): declare completions in the completion language
philocalyst Nov 30, 2026
ae4e35e
feat(pnpm): declare completions in the completion language
philocalyst Nov 30, 2026
7d6d101
feat(podman): declare completions in the completion language
philocalyst Nov 30, 2026
2a1a5f8
feat(poetry): declare completions in the completion language
philocalyst Nov 30, 2026
291280c
feat(pre-commit): declare completions in the completion language
philocalyst Nov 30, 2026
3d80d3f
feat(pytest): declare completions in the completion language
philocalyst Nov 30, 2026
3269c7a
feat(reflector): declare completions in the completion language
philocalyst Nov 30, 2026
83d0786
feat(rg): declare completions in the completion language
philocalyst Nov 30, 2026
4bfc415
feat(rustup): declare completions in the completion language
philocalyst Nov 30, 2026
8f5ca88
feat(rye): declare completions in the completion language
philocalyst Nov 30, 2026
33141a6
feat(scoop): declare completions in the completion language
philocalyst Nov 30, 2026
e730da4
feat(ssh): declare completions and share host lookup in ssh-hosts.nu
philocalyst Nov 30, 2026
db7c5dd
feat(scp): add scp and sftp completions
philocalyst Nov 30, 2026
3d6ebbf
feat(rsync): add completions
philocalyst Nov 30, 2026
d34a5e5
feat(swift-bundler): declare completions in the completion language
philocalyst Nov 30, 2026
d461570
feat(system): add completions for account and process tools
philocalyst Nov 30, 2026
ef6076a
feat(tar): declare completions in the completion language
philocalyst Nov 30, 2026
668f1c7
feat(tcpdump): declare completions in the completion language
philocalyst Nov 30, 2026
f697f30
feat(television): declare completions in the completion language
philocalyst Nov 30, 2026
25fca99
feat(tldr): declare completions in the completion language
philocalyst Nov 30, 2026
c60641c
feat(toipe): declare completions in the completion language
philocalyst Nov 30, 2026
f8ca18f
feat(ttyper): declare completions in the completion language
philocalyst Nov 30, 2026
18dee72
feat(typst): declare completions in the completion language
philocalyst Nov 30, 2026
4316534
feat(uv): declare completions in the completion language
philocalyst Nov 30, 2026
289c3d1
feat(virsh): declare completions in the completion language
philocalyst Nov 30, 2026
e4b8316
feat(vscode): declare completions in the completion language
philocalyst Nov 30, 2026
72f5ff1
feat(windows): declare procdump's completions in the completion language
philocalyst Nov 30, 2026
b0d7f4d
feat(winget): declare completions in the completion language
philocalyst Nov 30, 2026
e6b8c63
feat(xgettext): declare completions in the completion language
philocalyst Nov 30, 2026
40debf0
feat(yarn): declare completions in the completion language
philocalyst Nov 30, 2026
dd0c9c6
feat(zef): declare completions in the completion language
philocalyst Nov 30, 2026
5248f9d
feat(zellij): declare completions in the completion language
philocalyst Nov 30, 2026
6dc9154
feat(zig): declare completions in the completion language
philocalyst Nov 30, 2026
8deda7c
feat(zmx): declare completions in the completion language
philocalyst Nov 30, 2026
041ccf0
feat(zoxide): declare completions in the completion language
philocalyst Nov 30, 2026
6beac04
feat(ffmpeg): add completions
philocalyst Nov 30, 2026
7ac9783
feat(find): add completions
philocalyst Nov 30, 2026
d553fe7
feat(kubectl): add completions
philocalyst Nov 30, 2026
a1b3011
feat(rex): add completions
philocalyst Nov 30, 2026
6eae560
feat(tmux): add completions
philocalyst Nov 30, 2026
b7fabd6
docs(completions): document @non-destructive, @interactive and @example
philocalyst Nov 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions custom-completions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,74 @@ custom-completions/<tool>/
```

Pin a git revision and path into that folder (or the whole tree). Prefer stable directory names; renames break links and package ids. This repo does not host release zip/tar assets for these trees.

## Writing completers for the completion engine

Recent nushell versions run custom commands for completion, show examples as help and give
completers the token under the cursor. Three attributes take advantage of that; each is optional
and an older file keeps working without them.

### `@non-destructive`: listing helpers that completion may run

Typing `git-branches | where name == ` offers the branch names, because completion runs the part of
the line before the cursor to see what it gives. A custom command runs for that only if its body
calls nothing but builtin commands that read, or if its author promises it is harmless:

```nu
# The remotes, one row each: `name` and the fetch `url`.
@non-destructive
@example "The URL of origin" { git-remotes | where name == origin | get url.0 }
export def git-remotes []: nothing -> table<name: string, url: string> {
^git remote --verbose
| lines
| parse --regex '^(?<name>\S+)\s+(?<url>.+) \((?<direction>fetch|push)\)$'
| where direction == fetch
| select name url
}
```

Mark only commands that have no lasting effect when run on every keystroke: they write no file,
change no environment (`def --env` is refused whatever it carries), send nothing and install
nothing. `git for-each-ref` and `docker ps` qualify; `git fetch`, `gh api` or anything that fills a
cache file does not. Prefer `git --no-optional-locks status`, `jj --ignore-working-copy` and
`RUSTUP_AUTO_INSTALL=0 cargo metadata` over their plain forms, which can refresh an index, take a
snapshot or fetch a toolchain. A static list needs no attribute.

Return a table with a `name` column and typed columns (`size: filesize`, `updated: datetime`,
`installed: bool`) so that `where name ==`, `where size >` and `where installed` complete their
values. A completer used as `arg: string@name` returns `value` and `description` columns instead;
build it from the helper (`git-remotes | rename value description`) so the two stay in step.

### `@interactive`: a completer that owns the terminal

A completer that drives a picker (`fzf`, `input list`) needs stdin and the TTY, so it must run on
the line-editor thread rather than on the completion worker. Say so with `@interactive`, and take
the `token` record the engine passes:

```nu
@interactive
def pick-file [token: record] {
ls | get name | to text | ^fzf --query $token.text | lines
}

def open-file [path: string@pick-file] { open $path }
```

An interactive completer is never run in the background, so it cannot also be `@non-destructive`.
Use it only where a picker really is the better answer, since the other completers stay cached and
never block the line editor. `commandline complete --input` shows the record a completer is given
at the cursor, which is how to try one by hand; `commandline complete --explain` shows which
completer produced each candidate.

### `@example`: help where it is typed

`@example` works on `def` and on `extern`. For an extern give the code as a string with
`<placeholders>` for the words to replace; completion ranks the examples by how well they fit the
line and puts the chosen one on the command line, ready to have its first placeholder completed.
`--for` ties an example to the flags or parameters it is about, so it is shown where they are typed:

```nu
@example "Run an example of a package" "cargo run --example <example> -- <args>" --for [--example]
@example "Build with optimizations" "cargo build --release"
export extern "cargo run" [ ... ]
```
146 changes: 81 additions & 65 deletions custom-completions/ack/ack-completions.nu
Original file line number Diff line number Diff line change
@@ -1,66 +1,82 @@
# copied from auto-generated completions
# Declarative completions for ack, the grep-like source search tool.

export extern "ack" [
--ignore-case(-i) # Ignore case
--smart-case # Ignore case when pattern contains no uppercase
--no-smart-case # Dont ignore case
--invert-match(-v) # Invert match
--word-regexp(-w) # Match only whole words
--literal(-Q) # Quote all metacharacters
--lines # Only print line(s) NUM of each file
--files-with-matches(-l) # Only print filenames containing matches
--files-without-matches(-L) # Only print filenames with no matches
--output # Output the evaluation of Perl expression for each line
--passthru # Print all lines
--match # Specify pattern explicitly
--max-count(-m) # Stop searching in each file after NUM matches
--with-filename(-H) # Print the filename for each match
--no-filename(-h) # Suppress the prefixing filename on output
--count(-c) # Show number of lines matching per file
--column # Show column number of first match
--no-column # Dont show column number of first match
--print0 # Print null byte as separator between filenames
--pager # Pipes all ack output through command
--no-pager # Do not send output through a pager
--heading # Prints a filename heading above files results
--no-heading # Dont print a filename heading above files results
--break # Print a break between results
--no-break # Dont print a break between results
--group # Filename heading and line break between results
--no-group # No filename heading and no line breaks between results
--color # Highlight the matching text
--no-colour # Dont highlight the matching text
--color-filename # Set the color for filenames
--color-match # Set the color for matches
--color-lineno # Set the color for line numbers
--flush # Flush output immediately
--sort-files # Sort the found files lexically
--show-types # Show which types each file has
--files-from # Read the list of files to search from file
--ignore-directory # Ignore directory
--no-ignore-directory # Dont ignore directory
--ignore-file # Add filter for ignoring files
--recurse(-R) # Recurse into subdirectories
--no-recurse(-n) # No descending into subdirectories
--follow # Follow symlinks
--no-follow # Dont follow symlinks
--known-types(-k) # Include only recognized files
--type # Include only X files
--type-set # Replaces definition of type
--type-add # Specify definition of type
--type-del # Removes all filters associated with type
--no-env # Ignores environment variables and ackrc files
--ackrc # Specifies location of ackrc file
--ignore-ack-defaults # Ignore default definitions ack includes
--create-ackrc # Outputs default ackrc
--help(-?) # Shows help
--help-types # Shows all known types
--dump # Dump information on which options are loaded
--filter # Forces ack to treat input as a pipe
--no-filter # Forces ack to treat input as tty
--man # Shows man page
--version # Displays version and copyright
--thpppt # Bill the Cat
--bar # The warning admiral
...args
]
export complete [ack] [
--ignore-case(-i) # Ignore case
--smart-case # Ignore case unless the pattern has uppercase
--no-smart-case # Always respect case
--invert-match(-v) # Select non-matching lines
--word-regexp(-w) # Match only whole words
--literal(-Q) # Quote all metacharacters
--lines: text # Only print the given line(s) of each file
--files-with-matches(-l) # Only print filenames containing matches
--files-without-matches(-L) # Only print filenames with no matches
--output: text # Perl expression evaluated for each matching line
--passthru # Print every line, highlighting matches
--match: text # Specify the pattern explicitly
--max-count(-m): text # Stop searching each file after this many matches
--with-filename(-H) # Print the filename for each match
--no-filename(-h) # Suppress the prefixing filename on output
--count(-c) # Show the number of matching lines per file
--column # Show the column number of the first match
--no-column # Do not show the column number
--print0 # Separate filenames with a null byte
--pager: command # Pipe output through a pager
--no-pager # Do not send output through a pager
--heading # Print a filename heading above file results
--no-heading # Do not print a filename heading
--break # Print a break between results
--no-break # Do not print a break between results
--group # Filename heading and line break between results
--no-group # No filename heading and no line breaks
--color # Highlight the matching text
--no-color # Do not highlight the matching text
--color-filename: text # Colour used for filenames
--color-match: text # Colour used for matches
--color-lineno: text # Colour used for line numbers
--flush # Flush output immediately
--sort-files # Sort the found files lexically
--show-types # Show which types each file has
--files-from: path # Read the list of files to search from a file
--ignore-directory: dir # Ignore this directory
--no-ignore-directory # Do not ignore this directory
--ignore-file: text # Add a filter for ignoring files
--recurse(-R) # Recurse into subdirectories
--no-recurse(-n) # Do not descend into subdirectories
--follow # Follow symlinks
--no-follow # Do not follow symlinks
--known-types(-k) # Include only recognized files
--type: text # Include only files of this type
--type-set: text # Replace the definition of a type
--type-add: text # Add a definition of a type
--type-del: text # Remove all filters associated with a type
--noenv # Ignore environment variables and ackrc files
--ackrc: path # Use this ackrc file
--ignore-ack-defaults # Ignore the default definitions ack includes
--create-ackrc # Output a default ackrc
--help # Show help
--help-types # Show all known types
--dump # Dump which options are loaded
--filter # Treat input as a pipe
--no-filter # Treat input as a tty
--man # Show the man page
--version # Show version and copyright
--thpppt # Bill the Cat
--bar # The warning admiral
pattern?: text # Pattern to search for
...files: path # Files or directories to search
] where {
excludes --smart-case --no-smart-case
excludes --with-filename --no-filename
at-most-one [--files-with-matches --files-without-matches]
excludes --column --no-column
excludes --pager --no-pager
excludes --heading --no-heading
excludes --break --no-break
excludes --group --no-group
excludes --color --no-color
excludes --recurse --no-recurse
excludes --follow --no-follow
excludes --filter --no-filter
excludes --noenv --ackrc
terminal [--help --help-types --man --version --create-ackrc]
}
Loading
Loading