A custom keybinding that triggers completions from your entire command history—suggesting arguments, paths, and values you've used before, regardless of which command they were used with.
Unlike Carapace which shows all possible flags, this system only suggests options I've actually used. More importantly, it intelligently shares values across commands:
- Paths and values are command-agnostic and suggested everywhere
- Flags and named parameters are command-specific to avoid invalid suggestions
The keybinding distinguishes between:
- Universal values (paths, IPs, URLs, strings) - suggested across all commands
- Command-specific syntax (flags, named parameters) - only suggested for their original command
This prevents suggesting --verbose
from ls
when typing git
, while still allowing /home/user/project
to be suggested anywhere.
- Hook on each command execution parses and stores components
- Separate SQLite table stores arguments with context:
history_item_id
(foreign key to existing history)command_name
(used for filtering flags/params, ignored for values)flag
(switches) (e.g., "--all", "-v")parameter_name
(named parameters) (e.g., "--output", "--age")parameter_value
(values for named parameters) (e.g., "filename", "25")positional_arg
(positional arguments) (e.g., "arg1", "arg2")arg_position
(1, 2, 3...)arg_type
(leverages Nushell's type system: path, int, string, etc.)
The system can leverage Nushell's command signatures:
- Query command signatures to understand expected types at each position
- Match historical values by type (only suggest paths where paths are expected)
- Validate suggestions against command signatures before displaying
- Custom keybinding triggers intelligent queries:
- For flags/parameters: filters by current command
- For values: searches across entire history
- Integrates with Nushell's type system for smart filtering
- Prioritizes based on:
- Type compatibility (from command signatures)
- Recency of use
- Frequency of use
- Position in command
- All paths ever typed (from
cp
,mv
,ls
,cd
, etc.) - All flags and their values across all commands
- All positional arguments from any command
- Common values like IP addresses, URLs, file patterns
The main power: reuse arguments from ANY previous command:
cp ~/documents/report.pdf ~/backup/
# Later with a different command:
mv ~/<keybinding> # Suggests: ~/documents/report.pdf
rm ~/<keybinding> # Also suggests: ~/backup/
Values used anywhere become available everywhere:
ssh [email protected]
# Later:
ping <keybinding> # Suggests: 192.168.1.100
curl http://<keybinding> # Suggests: 192.168.1.100
git checkout feature/new-api
# Later:
git branch -d <keybinding> # Suggests: feature/new-api
# But also:
echo "Working on <keybinding>" # Also suggests: feature/new-api
The system doesn't limit suggestions to command-specific history—it treats your entire command history as a pool of reusable values.
This directory contains test commands and their corresponding AST outputs for developing the command parser:
- Complex pipeline example:
complex_pipeline.nu
demonstrates a sophisticated command with variable assignment, subexpressions, flags, closures, and pipelines - AST outputs: Both regular and flattened AST formats are provided
complex_pipeline_ast.json
- Standard nested AST structurecomplex_pipeline_ast_flattened.json
- Simplified linear token array (preferred for parsing)
- Generation command:
ast --flatten --json (open <test_name>.nu) | save <test_name>_ast_flattened.json --force --raw
The flattened AST format provides clean token arrays with content
, shape
, and span
fields, making it easier to extract:
- Commands (
shape_internalcall
) - Flags (
shape_flag
) - String/numeric values (
shape_string
,shape_int
) - Variables (
shape_variable
) - Pipeline structure (
shape_pipe
)
Documentation and examples of Nushell's history database structure:
- SQLite schema: Complete field descriptions for the history table
- Sample data:
history_structure.json
with real history entries - Access patterns: How to query the history database for parsing
Key fields for completion system:
command_line
: Raw command text to parse with ASTstart_timestamp
: For recency-based rankingexit_status
: Filter successful vs failed commandscwd
: Context for path-based suggestions