Crates.io | nu-completion-script |
lib.rs | nu-completion-script |
version | 0.1.3 |
source | src |
created_at | 2023-02-27 12:51:17.332991 |
updated_at | 2023-02-28 18:46:27.614709 |
description | A script for generating nu completions from Fish completions |
homepage | |
repository | https://github.com/dscottboggs/nu-completions |
max_upload_size | |
id | 795942 |
size | 31,227,690 |
This is a system for generating extern def
s (tab-completion) in
nu.
The fish shell project has a long, complicated script for parsing man pages to gather completions definitions. Fortunately for us, Fish completions are defined in simple command line arguments, which we parse here and use to generate completions for Nu.
Download and optionally install this script. For a prebuilt binary, use cargo-binstall...
cargo binstall nu-completion-script
...or if you don't have cargo-binstall
, download the release from the
releases page on Github.
You may also build from source using cargo install
, or cloning the
repository and building with cargo install
. See Development Process for instructions.
Have fish
installed.
From a fish
shell, run
fish_update_completions
Generate the nu
definitions.
nu-completions ~/.local/share/fish/generated_completions/*.fish
Source the definitions
nu-completions --install
If an error occurs, please run your command again with -vvvv
, save the logs,
and include them when submitting a Github
Issue. For example,
if an error occurs while running the above command to generate the definitions,
run this command instead:
nu-completions -vvvv ~/.local/share/fish/generated_completions/*.fish | save log.json
And include the contents of log.json
within a preformatted block, like this:
```json
{"level":30,"time":1677171831187,"msg":"beginning translation phase"}
{"level":30,"time":1677171831187,"msg":"processing file or directory","file":"../../../.local/share/fish/generated_completions/7z.fish"}
{"level":30,"time":1677171831187,"msg":"processing file","file":"../../../.local/share/fish/generated_completions/7z.fish"}
{"level":10,"time":1677171831187,"msg":"opened file for processing","file":"\"../../../.local/share/fish/generated_completions/7z.fish\""}
...
{"level":10,"time":1677171833182,"msg":"opened file for processing","file":"\"../../../.local/share/fish/generated_completions/java-openjdk8.fish\""}
{"level":50,"time":1677171833182,"msg":"error parsing shell words","line":"complete -c java-openjdk8 -o 'disablesystemassertions"}
{"level":50,"time":1677171833182,"msg":"failed to process completions at \"../../../.local/share/fish/generated_completions/java-openjdk8.fish\": missing closing quote"}
```
Since these definitions are auto-generated and incomplete, we need to modify the auto-generated output to provide additional application-specific functions to each definition. In order to provide a consistent workflow which smoothly (we hope) handles upstream man-page updates, these application-specific modifications take the form of a set of patches which are a part of this repository.
Note: These directions assume you're using Linux, and have
git
andcargo
installed)
git clone https://github.com/YOUR-GITHUB-USER/nu-completions.git
cd nu-completions
cargo build --release
Alternatively, install the latest release's prebuilt binary (requires
cargo-binstall)...
cargo binstall nu-completion-script
...or if you don't have cargo-binstall
, download the release from the
releases page on Github.fish
installed.fish
shell, run
fish_update_completions
nu
definitions.
nu-completions ~/.local/share/fish/generated_completions/*.fish
nu-completions --patch-dir=./patches patches generate ~/.local/share/fish/generated_completions/*.fish