diff --git a/tree/.config/nushell/cargo-completions.nu b/tree/.config/nushell/cargo-completions.nu new file mode 100644 index 0000000..b65e368 --- /dev/null +++ b/tree/.config/nushell/cargo-completions.nu @@ -0,0 +1,587 @@ +## Written by lukexor, Improved by @Dan-Gamin + +def "nu-complete cargo targets" [type: string] { + ^cargo metadata --format-version=1 --offline --no-deps | from json | get packages.targets | flatten | where ($type in $it.kind) | get name +} +def "nu-complete cargo bins" [] { nu-complete cargo targets bin } +def "nu-complete cargo examples" [] { nu-complete cargo targets example } + +def "nu-complete cargo packages" [] { + let metadata = (^cargo metadata --format-version=1 --offline --no-deps) + if $metadata == '' { + [] + } else { + $metadata | from json | get workspace_members | split column ' ' | get column1 + } +} + +def "nu-complete cargo color" [] { + ['auto', 'always', 'never'] +} + +def "nu-complete cargo profiles" [] { + open Cargo.toml | get profile | transpose | get column0 +} + +def "nu-complete cargo features" [] { + open Cargo.toml | get features | transpose | get column0 +} + +# `cargo --list` is slow, `open` is faster. +# TODO: Add caching. +def "nu-complete cargo subcommands" [] { + ^cargo --list | lines | skip 1 | str join "\n" | from ssv --noheaders | get column1 +} +def "nu-complete cargo vcs" [] { + [ + 'git', + 'hg', + 'pijul', + 'fossil', + 'none' + ] +} + +#*> Core <*# + +# Disabled due to messing with undefined cargo-subcommands + +# # Rust's package manager +# export extern "cargo" [ +# --version(-V) # Print version info and exit +# --list # List installed commands +# --explain: number # Run `rustc --explain CODE` +# --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output +# --quiet(-q) # Do not print cargo log messages +# --color: string@"nu-complete cargo color" # Control when colored output is used +# --frozen # Require Cargo.lock and cache are up to date +# --locked # Require Cargo.lock is up to date +# --offline # Run without accessing the network +# --config: string # Override a configuration value +# -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details +# -h, --help # Print help information +# ...args: any +# ] + +#*> Common Commands (Sorted by order shown by running the `cargo` command) <*# + +# Compile the current package +export extern "cargo build" [ + --package(-p): string@"nu-complete cargo packages" # Build only the specified packages + --workspace # Build all members in the workspace + --exclude: string@"nu-complete cargo packages" # Exclude the specified packages + --lib # Build the package's library + --bin: string@"nu-complete cargo bins" # Build the specified binary + --bins # Build all binary targets + --example: string@"nu-complete cargo examples" # Build the specified example + --examples # Build all example targets + --test: string # Build the specified integration test + --tests # Build all targets in test mode that have the test = true manifest flag set + --bench: string # Build the specified benchmark + --benches # Build all targets in benchmark mode that have the bench = true manifest flag set + --all-targets # Build all targets + --features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate + --all-features # Activate all available features of all selected packages + --no-default-features # Do not activate the default feature of the selected packages + --target: string # Build for the given architecture. + --release(-r) # Build optimized artifacts with the release profile + --profile: string@"nu-complete cargo profiles" # Build with the given profile + --ignore-rust-version # Ignore `rust-version` specification in packages + --timings: string # Output information how long each compilation takes + --target-dir: path # Directory for all generated artifacts and intermediate files + --out-dir: path # Copy final artifacts to this directory + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --message-format: string # The output format for diagnostic messages + --build-plan # Outputs a series of JSON messages to stdout that indicate the commands to run the build + --manifest-path: path # Path to the Cargo.toml file + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help # Print help information + --jobs(-j): number # Number of parallel jobs to run + --future-incompat-report # Displays a future-incompat report for any future-incompatible warnings +] + +# Check the current package +export extern "cargo check" [ + --package(-p): string@"nu-complete cargo packages" #Check only the specified packages + --workspace # Check all members in the workspace + --all # Alias for --workspace (deprecated) + --exclude: string@"nu-complete cargo packages" # Exclude the specified packages + --lib # Check the package's library + --bin: string@"nu-complete cargo bins" # Check the specified binary + --example: string@"nu-complete cargo examples" # Check the specified example + --examples # Check all example targets + --test: string # Check the specified integration test + --tests # Check all targets in test mode that have the test = true manifest flag set + --bench: string # Check the specified benchmark + --benches # Check all targets in benchmark mode that have the bench = true manifest flag set + --all-targets # Check all targets + --features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate + --all-features # Activate all available features + --no-default-features # Do not activate the `default` feature + --target: string # Check for the given architecture + --release(-r) # Check optimized artifacts with the release profile + --profile: string@"nu-complete cargo profiles" # Check with the given profile + --ignore-rust-version # Ignore `rust-version` specification in packages + --timings: string # Output information how long each compilation takes + --target-dir: path # Directory for all generated artifacts and intermediate files + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --message-format: string # The output format for diagnostic messages + --manifest-path: path # Path to the Cargo.toml file + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help # Print help information + --jobs(-j): number # Number of parallel jobs to run + --keep-going # Build as many crates in the dependency graph as possible + --future-incompat-report # Displays a future-incompat report for any future-incompatible warnings +] + +# Remove the target directory +export extern "cargo clean" [ + --package(-p): string@"nu-complete cargo packages" # Clean only the specified packages + --doc # Remove only the doc directory in the target directory + --release # Remove all artifacts in the release directory + --profile # Remove all artifacts in the directory with the given profile name + --target-dir: path # Directory for all generated artifacts and intermediate files + --target: string # Clean for the given architecture + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --message-format: string # The output format for diagnostic messages + --manifest-path: path # Path to the Cargo.toml file + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help # Print help information +] + +# Build a package's documentation +export extern "cargo doc" [ + --open # Open the docs in a browser after building them + --no-deps # Do not build documentation for dependencie + --document-private-items # Include non-public items in the documentation + --package(-p): string@"nu-complete cargo packages" # Document only the specified packages + --workspace # Document all members in the workspace + --exclude: string@"nu-complete cargo packages" # Exclude the specified packages + --lib: string # Document the package's library + --bin: string@"nu-complete cargo bins" # Document the specified binary + --bins # Document all binary targets + --example: string@"nu-complete cargo examples" # Document the specified example + --examples # Document all example targets + --features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate + --all-features # Activate all available features of all selected packages + --no-default-features # Do not activate the default feature of the selected packages + --target: string # Document for the given architecture + --release(-r) # Document optimized artifacts with the release profile + --profile: string@"nu-complete cargo profiles" # Document with the given profile + --ignore-rust-version # Ignore `rust-version` specification in packages + --timings: string # Output information how long each compilation takes + --target-dir: path # Directory for all generated artifacts and intermediate files + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --message-format: string # The output format for diagnostic messages + --manifest-path: path # Path to the Cargo.toml file + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help # Print help information + --jobs(-j): number # Number of parallel jobs to run + --keep-going # Build as many crates in the dependency graph as possible +] + +# Create a new cargo package +export extern "cargo new" [ + path: path # The directory that will contain the project + --bin # Create a package with a binary target (src/main.rs) (default) + --lib # Create a package with a library target (src/lib.rs) + --edition: number # Specify the Rust edition to use (default: 2021) + --name: string # Set the package name. Defaults to the directory name. + --vcs: string@"nu-complete cargo vcs" # Initialize a new VCS repository for the given version control system + --registry: string # Name of the registry to use + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help # Print help information +] + +# Create a new cargo package in an existing directory +export extern "cargo init" [ + path: path # The directory that will contain the project + --bin # Create a package with a binary target (src/main.rs) (default) + --lib # Create a package with a library target (src/lib.rs) + --edition: number # Specify the Rust edition to use (default: 2021) + --name: string # Set the package name. Defaults to the directory name. + --vcs: string@"nu-complete cargo vcs" # Initialize a new VCS repository for the given version control system + --registry: string # Name of the registry to use + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help # Print help information +] + +# Run the current cargo package +export extern "cargo run" [ + ...args: any # Arguments to be passed to your program + --bin: string@"nu-complete cargo bins" # Name of the bin target to run + --example: string@"nu-complete cargo examples" # Name of the example target to run + --quiet(-q) # Do not print cargo log messages + --package(-p): string@"nu-complete cargo packages" # Package with the target to run + --jobs(-j): number # Number of parallel jobs, defaults to # of CPUs + --release # Build artifacts in release mode, with optimizations + --profile: string@"nu-complete cargo profiles" # Build artifacts with the specified profile + --features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate + --all-features # Activate all available features + --no-default-features # Do not activate the `default` feature + --target: string # Build for the target triple + --target-dir: path # Directory for all generated artifacts + --manifest-path: path # Path to Cargo.toml + --message-format: string # Error format + --unit-graph # Output build graph in JSON (unstable) + --ignore-rust-version # Ignore `rust-version` specification in packages + --verbose(-v) # Use verbose output (-vv very verbose/build.rs output) + --color: string@"nu-complete cargo color" # Control when colored output is used + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + --config: string # Override a configuration value (unstable) + -Z: string # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + --help(-h) # Prints help information +] + +# Run the tests +export extern "cargo test" [ + test_arg_separator?: string + ...args: any # Arguments to be passed to the tests + --no-run # Compile, but don't run tests + --no-fail-fast # Run all tests regardless of failure + --package(-p): string@"nu-complete cargo packages" # Test only the specified packages + --workspace # Test all members in the workspace + --exclude: string@"nu-complete cargo packages" # Exclude the specified packages + --lib # Test the package's library + --bin: string@"nu-complete cargo bins" # Test only the specified binary + --bins # Test all binaries + --example: string@"nu-complete cargo examples" # Test only the specified example + --examples # Test all examples + --test: string # Test the specified integration test + --tests # Test all targets in test mode that have the test = true manifest flag set + --bench: string # Test the specified benchmark + --benches # Test all targets in benchmark mode that have the bench = true manifest flag set + --all-targets # Test all targets + --doc # Test ONLY the library's documentation + --features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate + --all-features # Activate all available features of all selected packages + --no-default-features # Do not activate the default feature of the selected packages + --target: string # Test for the given architecture + --release(-r) # Test optimized artifacts with the release profile + --profile: string@"nu-complete cargo profiles" # Test with the given profile + --ignore-rust-version # Ignore `rust-version` specification in packages + --timings: string # Output information how long each compilation takes + --target-dir: path # Directory for all generated artifacts and intermediate files + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --message-format: string # The output format for diagnostic messages + --manifest-path: path # Path to the Cargo.toml file + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + --help(-h) # Prints help information + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + --jobs(-j): number # Number of parallel jobs to run + --keep-going # Build as many crates in the dependency graph as possible + --future-incompat-report # Displays a future-incompat report for any future-incompatible warnings +] + +# Execute benchmarks of a package +export extern "cargo bench" [ + bench_option_seperator?: string + ...options: any # Options to be passed to the benchmarks + --no-run # Compile, but don't run benchmarks + --no-fail-fast # Run all benchmarks regardless of failure + --package(-p): string@"nu-complete cargo packages" # Benchmark only the specified packages + --workspace # Benchmark all members in the workspace + --exclude: string@"nu-complete cargo packages" # Exclude the specified packages + --lib # Benchmark the package's library + --bin: string@"nu-complete cargo bins" # Benchmark only the specified binary + --bins # Benchmark all binary targets + --example: string@"nu-complete cargo examples" # Benchmark only the specified example + --examples # Benchmark all example targets + --test: string # Benchmark the specified integration test + --tests # Benchmark all targets in test mode that have the test = true + --bench: string # Benchmark the specified benchmark + --benches # Benchmark all targets in benchmark mode that have the bench = true manifest flag set + --all-targets # Benchmark all targets + --features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate + --all-features # Activate all available features of all selected packages + --no-default-features # Do not activate the default feature of the selected packages + --target: string # Benchmark for the given architecture + --profile: string@"nu-complete cargo profiles" # Build artifacts with the specified profile + --ignore-rust-version # Ignore `rust-version` specification in packages + --timings: string # Output information how long each compilation takes + --target-dir: path # Directory for all generated artifacts and intermediate files + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --message-format: string # The output format for diagnostic messages + --build-plan # Outputs a series of JSON messages to stdout that indicate the commands to run the build + --manifest-path: path # Path to the Cargo.toml file + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help # Print help information + --jobs(-j): number # Number of parallel jobs to run + --keep-going # Build as many crates in the dependency graph as possible +] + +# Update dependencies listed in Cargo.lock +export extern "cargo update" [ + --package(-p): string@"nu-complete cargo packages" # Update only the specified packages + --aggressive # Dependencies of the specified packages are forced to update as well + --precise: any # Allows you to specify a specific version number to set the package to + --workspace(-w) # Attempt to update only packages defined in the workspace + --dry-run # Displays what would be updated but doesn't write the lockfile + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --manifest-path: path # Path to the Cargo.toml file + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + --help(-h) # Prints help information + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details +] + +# Search packages in crates.io +export extern "cargo search" [ + query: string # The thing to search + --limit: number # Limit the number of results. (default: 10, max: 100) + --index: string # The URL of the registry index to use + --registry: string # Name of the registry to use + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --help(-h) # Prints help information + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details +] + +# Package and upload a package to the registry +export extern "cargo publish" [ + --dry-run # Perform all checks without uploading + --token: any # API token to use when authenticating + --no-verify # Don't verify the contents by building them + --allow-dirty # Allow working directories with uncommitted VCS changes to be packaged + --index: string # The URL of the registry index to use + --registry: string # Name of the registry to publish to + --package(-p): string@"nu-complete cargo packages" # The package to publish + --target: string # Publish for the given architecture + --target-dir: path # Directory for all generated artifacts and intermediate files + --features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate + --all-features # Activate all available features of all selected packages + --no-default-features # Do not activate the default feature of the selected packages + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --manifest-path: path # Path to the Cargo.toml file + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + --help(-h) # Prints help information + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + --jobs(-j): number # Number of parallel jobs to run + --keep-going # Build as many crates in the dependency graph as possible +] + +# Build and install a Rust binary +export extern "cargo install" [ + crate?: string # The crate to install + --version: string # Specify a version to install + --vers: string # Specify a version to install + --git: string # Git URL to install the specified crate from + --branch: string # Branch to use when installing from git + --tag: string # Tag to use when installing from git + --rev: string # Specific commit to use when installing from git + --path: path # Filesystem path to local crate to install + --list # List all installed packages and their versions + --force(-f) # Force overwriting existing crates or binaries + --no-track # Don't keep track of this package + --bin: string@"nu-complete cargo bins" # Install only the specified binary + --bins # Install all binaries + --example: string@"nu-complete cargo examples" # Install only the specified example + --examples # Install all examples + --root: path # Directory to install packages into + --registry: string # Name of the registry to use + --index: string # The URL of the registry index to use + --features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate + --all-features # Activate all available features of all selected packages + --no-default-features # Do not activate the default feature of the selected packages + --target: string # Install for the given architecture + --target-dir: path # Directory for all generated artifacts and intermediate files + --debug # Build with the dev profile instead the release profile + --profile: string@"nu-complete cargo profiles" # Build artifacts with the specified profile + --timings: string # Output information how long each compilation takes + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + --jobs(-j): number # Number of parallel jobs to run + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --message-format: string # The output format for diagnostic messages + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help # Print help information +] + +# Remove a Rust binary +export extern "cargo uninstall" [ + package?: string@"nu-complete cargo packages" # Package to uninstall + --package(-p): string@"nu-complete cargo packages" # Package to uninstall + --bin: string@"nu-complete cargo bins" # Only uninstall the binary name + --root: path # Directory to uninstall packages from + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help # Print help information +] + +#*> Other Commands <*# + +# Output the resolved dependencies of a package in machine-readable format +export extern "cargo metadata" [ + --no-deps # Output information only about the workspace members and don't fetch dependencies + --format-version: number # Specify the version of the output format to use. Currently 1 is the only possible value + --filter-platform: string # This filters the resolve output to only include dependencies for the iven target triple + --features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate + --all-features # Activate all available features of all selected packages + --no-default-features # Do not activate the default feature of the selected packages + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --manifest-path: path # Path to the Cargo.toml file + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + --help(-h) # Prints help information + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details +] + +# Get the help of the given cargo subcommand +export extern "cargo help" [ + subcommand: string@"nu-complete cargo subcommands" + --color: string@"nu-complete cargo color" # Control when colored output is used + --config: string # Override a configuration value + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details +] + +# A bunch of lints to catch common mistakes and improve your Rust code +export extern "cargo clippy" [ + --no-deps # Run Clippy only on the given crate, without linting the dependencies + --fix # Automatically apply lint suggestions. This flag implies `--no-deps + --version(-V) # Prints version information + --help(-h) # Prints help information + --warn(-W) # Set lint warnings + --allow(-A) # Set lint allowed + --deny(-D) # Set lint denied + --forbid(-F) # Set lint forbidden + --package(-p): string@"nu-complete cargo packages" #Check only the specified packages + --workspace # Check all members in the workspace + --all # Alias for --workspace (deprecated) + --exclude: string@"nu-complete cargo packages" # Exclude the specified packages + --lib # Check the package's library + --bin: string@"nu-complete cargo bins" # Check the specified binary + --example: string@"nu-complete cargo examples" # Check the specified example + --examples # Check all example targets + --test: string # Check the specified integration test + --tests # Check all targets in test mode that have the test = true manifest flag set + --bench: string # Check the specified benchmark + --benches # Check all targets in benchmark mode that have the bench = true manifest flag set + --all-targets # Check all targets + --features(-F): string@"nu-complete cargo features" # Space or comma separated list of features to activate + --all-features # Activate all available features + --no-default-features # Do not activate the `default` feature + --target: string # Check for the given architecture + --release(-r) # Check optimized artifacts with the release profile + --profile: string@"nu-complete cargo profiles" # Check with the given profile + --ignore-rust-version # Ignore `rust-version` specification in packages + --timings: string # Output information how long each compilation takes + --target-dir: path # Directory for all generated artifacts and intermediate files + --verbose(-v) # Use verbose output. May be specified twice for "very verbose" output + --quiet(-q) # Do not print cargo log messages + --color: string@"nu-complete cargo color" # Control when colored output is used + --message-format: string # The output format for diagnostic messages + --manifest-path: path # Path to the Cargo.toml file + --frozen # Require Cargo.lock and cache are up to date + --locked # Require Cargo.lock is up to date + --offline # Run without accessing the network + -Z: any # Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details + -h, --help # Print help information + --jobs(-j): number # Number of parallel jobs to run + --keep-going # Build as many crates in the dependency graph as possible + --future-incompat-report # Displays a future-incompat report for any future-incompatible warnings + -Z: any +] + +# Parameters from cargo update +export extern "cargo install-update" [ + --all(-a) # Update all packages + --allow-no-update(-i) # Allow for fresh-installing packages + --downdate(-d) # Downdate packages to match latest unyanked registry version + --force(-f) # Update all packages regardless if they need updating + --git(-g) # Also update git packages + --help(-h) # Prints help information + --list(-l) # Don't update packages, only list and check if they need an update (all packages by default) + --quiet(-q) # No output printed to stdout + --version(-V) # Prints version information + --cargo-dir(-c) # The cargo home directory. Default: $CARGO_HOME or $HOME/.cargo + --filter(-s) # Specify a filter a package must match to be considered + --install-cargo(-r) # Specify an alternative cargo to run for installations + --temp-dir(-t) # The temporary directory. Default: $TEMP/cargo-update +] + +# Parameters from cargo add +export extern "cargo add" [ + --no-default-features # Disable the default features + --default-features # Re-enable the default features + --features(-F) # Space or comma separated list of features to activate + --optional # Mark the dependency as optional + --verbose(-v) # Use verbose output (-vv very verbose/build.rs output) + --no-optional # Mark the dependency as required + --color: string@"nu-complete cargo color" # Coloring: auto, always, never + --rename # Rename the dependency + --locked # Require Cargo.lock is up to date + --package(-p) # Package to modify + --offline # Run without accessing the network + --quiet(-q) # Do not print cargo log messages + --config # Override a configuration value + --dry-run # Don't actually write the manifest + --help(-h) # Print help information + --path # Filesystem path to local crate to add + --git # Git repository location + --branch # Git branch to download the crate from + --tag # Git tag to download the crate from + --rev # Git reference to download the crate from + --registry # Package registry for this dependency + --dev # Add as development dependency + --build # Add as build dependency + --target # Add as dependency to the given target platform + ...args +] + diff --git a/tree/.config/nushell/config.nu b/tree/.config/nushell/config.nu index b858a5f..8ed9596 100644 --- a/tree/.config/nushell/config.nu +++ b/tree/.config/nushell/config.nu @@ -1,6 +1,6 @@ # Nushell Config File # -# version = 0.78.0 +# version = 0.83.1 # For more information on defining custom themes, see # https://www.nushell.sh/book/coloring_and_theming.html @@ -17,30 +17,30 @@ let dark_theme = { bool: {|| if $in { 'light_cyan' } else { 'light_gray' } } int: white filesize: {|e| - if $e == 0b { - 'white' - } else if $e < 1mb { - 'cyan' - } else { 'blue' } + if $e == 0b { + 'white' + } else if $e < 1mb { + 'cyan' + } else { 'blue' } } duration: white date: {|| (date now) - $in | - if $in < 1hr { - 'red3b' - } else if $in < 6hr { - 'orange3' - } else if $in < 1day { - 'yellow3b' - } else if $in < 3day { - 'chartreuse2b' - } else if $in < 1wk { - 'green3b' - } else if $in < 6wk { - 'darkturquoise' - } else if $in < 52wk { - 'deepskyblue3b' - } else { 'dark_gray' } - } + if $in < 1hr { + 'purple' + } else if $in < 6hr { + 'red' + } else if $in < 1day { + 'yellow' + } else if $in < 3day { + 'green' + } else if $in < 1wk { + 'light_green' + } else if $in < 6wk { + 'cyan' + } else if $in < 52wk { + 'blue' + } else { 'dark_gray' } + } range: white float: white string: white @@ -52,11 +52,12 @@ let dark_theme = { list: white block: white hints: dark_gray - + search_result: {bg: red fg: white} shape_and: purple_bold shape_binary: purple_bold shape_block: blue_bold shape_bool: light_cyan + shape_closure: green_bold shape_custom: green shape_datetime: cyan_bold shape_directory: cyan @@ -66,7 +67,7 @@ let dark_theme = { shape_flag: blue_bold shape_float: purple_bold # shapes are used to change the cli syntax highlighting - shape_garbage: { fg: "#FFFFFF" bg: "#FF0000" attr: b} + shape_garbage: { fg: white bg: red attr: b} shape_globpattern: cyan_bold shape_int: purple_bold shape_internalcall: cyan_bold @@ -86,6 +87,7 @@ let dark_theme = { shape_string_interpolation: cyan_bold shape_table: blue_bold shape_variable: purple + shape_vardecl: purple } let light_theme = { @@ -99,30 +101,30 @@ let light_theme = { bool: {|| if $in { 'dark_cyan' } else { 'dark_gray' } } int: dark_gray filesize: {|e| - if $e == 0b { - 'dark_gray' - } else if $e < 1mb { - 'cyan_bold' - } else { 'blue_bold' } + if $e == 0b { + 'dark_gray' + } else if $e < 1mb { + 'cyan_bold' + } else { 'blue_bold' } } duration: dark_gray - date: {|| (date now) - $in | - if $in < 1hr { - 'red3b' - } else if $in < 6hr { - 'orange3' - } else if $in < 1day { - 'yellow3b' - } else if $in < 3day { - 'chartreuse2b' - } else if $in < 1wk { - 'green3b' - } else if $in < 6wk { - 'darkturquoise' - } else if $in < 52wk { - 'deepskyblue3b' - } else { 'dark_gray' } - } + date: {|| (date now) - $in | + if $in < 1hr { + 'purple' + } else if $in < 6hr { + 'red' + } else if $in < 1day { + 'yellow' + } else if $in < 3day { + 'green' + } else if $in < 1wk { + 'light_green' + } else if $in < 6wk { + 'cyan' + } else if $in < 52wk { + 'blue' + } else { 'dark_gray' } + } range: dark_gray float: dark_gray string: dark_gray @@ -134,11 +136,12 @@ let light_theme = { list: white block: white hints: dark_gray - + search_result: {fg: white bg: red} shape_and: purple_bold shape_binary: purple_bold shape_block: blue_bold shape_bool: light_cyan + shape_closure: green_bold shape_custom: green shape_datetime: cyan_bold shape_directory: cyan @@ -148,7 +151,7 @@ let light_theme = { shape_flag: blue_bold shape_float: purple_bold # shapes are used to change the cli syntax highlighting - shape_garbage: { fg: "#FFFFFF" bg: "#FF0000" attr: b} + shape_garbage: { fg: white bg: red attr: b} shape_globpattern: cyan_bold shape_int: purple_bold shape_internalcall: cyan_bold @@ -168,6 +171,7 @@ let light_theme = { shape_string_interpolation: cyan_bold shape_table: blue_bold shape_variable: purple + shape_vardecl: purple } # External completer example @@ -177,365 +181,633 @@ let light_theme = { # The default config record. This is where much of your global configuration is setup. -let-env config = { - # true or false to enable or disable the welcome banner at startup - show_banner: true - ls: { - use_ls_colors: true # use the LS_COLORS environment variable to colorize output - clickable_links: true # enable or disable clickable links. Your terminal has to support links. - } - rm: { - always_trash: false # always act as if -t was given. Can be overridden with -p - } - cd: { - abbreviations: false # allows `cd s/o/f` to expand to `cd some/other/folder` - } - table: { - mode: rounded # basic, compact, compact_double, light, thin, with_love, rounded, reinforced, heavy, none, other - index_mode: always # "always" show indexes, "never" show indexes, "auto" = show indexes when a table has "index" column - show_empty: true # show 'empty list' and 'empty record' placeholders for command output - trim: { - methodology: wrapping # wrapping or truncating - wrapping_try_keep_words: true # A strategy used by the 'wrapping' methodology - truncating_suffix: "..." # A suffix used by the 'truncating' methodology - } - } +$env.config = { + show_banner: true # true or false to enable or disable the welcome banner at startup - explore: { - help_banner: true - exit_esc: true - - command_bar_text: '#C4C9C6' - # command_bar: {fg: '#C4C9C6' bg: '#223311' } - - status_bar_background: {fg: '#1D1F21' bg: '#C4C9C6' } - # status_bar_text: {fg: '#C4C9C6' bg: '#223311' } - - highlight: {bg: 'yellow' fg: 'black' } - - status: { - # warn: {bg: 'yellow', fg: 'blue'} - # error: {bg: 'yellow', fg: 'blue'} - # info: {bg: 'yellow', fg: 'blue'} + ls: { + use_ls_colors: true # use the LS_COLORS environment variable to colorize output + clickable_links: true # enable or disable clickable links. Your terminal has to support links. } - try: { - # border_color: 'red' - # highlighted_color: 'blue' + rm: { + always_trash: false # always act as if -t was given. Can be overridden with -p + } - # reactive: false + cd: { + abbreviations: false # allows `cd s/o/f` to expand to `cd some/other/folder` } table: { - split_line: '#404040' - - cursor: true - - line_index: true - line_shift: true - line_head_top: true - line_head_bottom: true - - show_head: true - show_index: true - - # selected_cell: {fg: 'white', bg: '#777777'} - # selected_row: {fg: 'yellow', bg: '#C1C2A3'} - # selected_column: blue - - # padding_column_right: 2 - # padding_column_left: 2 - - # padding_index_left: 2 - # padding_index_right: 1 + mode: rounded # basic, compact, compact_double, light, thin, with_love, rounded, reinforced, heavy, none, other + index_mode: always # "always" show indexes, "never" show indexes, "auto" = show indexes when a table has "index" column + show_empty: true # show 'empty list' and 'empty record' placeholders for command output + trim: { + methodology: wrapping # wrapping or truncating + wrapping_try_keep_words: true # A strategy used by the 'wrapping' methodology + truncating_suffix: "..." # A suffix used by the 'truncating' methodology + } } - config: { - cursor_color: {bg: 'yellow' fg: 'black' } + # datetime_format determines what a datetime rendered in the shell would look like. + # Behavior without this configuration point will be to "humanize" the datetime display, + # showing something like "a day ago." + datetime_format: { + # normal: '%a, %d %b %Y %H:%M:%S %z' # shows up in displays of variables or other datetime's outside of tables + # table: '%m/%d/%y %I:%M:%S%p' # generally shows up in tabular outputs such as ls. commenting this out will change it to the default human readable datetime format + } - # border_color: white - # list_color: green + explore: { + try: { + border_color: {fg: "white"} + }, + status_bar_background: {fg: "#1D1F21", bg: "#C4C9C6"}, + command_bar_text: {fg: "#C4C9C6"}, + highlight: {fg: "black", bg: "yellow"}, + status: { + error: {fg: "white", bg: "red"}, + warn: {} + info: {} + }, + table: { + split_line: {fg: "#404040"}, + selected_cell: {}, + selected_row: {}, + selected_column: {}, + cursor: true, + line_head_top: true, + line_head_bottom: true, + line_shift: true, + line_index: true, + }, + config: { + border_color: {fg: "white"} + cursor_color: {fg: "black", bg: "light_yellow"} + }, } - } - history: { - max_size: 10000 # Session has to be reloaded for this to take effect - sync_on_enter: true # Enable to share history between multiple sessions, else you have to close the session to write history to file - file_format: "plaintext" # "sqlite" or "plaintext" - } - completions: { - case_sensitive: false # set to true to enable case-sensitive completions - quick: true # set this to false to prevent auto-selecting completions when only one remains - partial: true # set this to false to prevent partial filling of the prompt - algorithm: "prefix" # prefix or fuzzy - external: { - enable: true # set to false to prevent nushell looking into $env.PATH to find more suggestions, `false` recommended for WSL users as this look up my be very slow - max_results: 100 # setting it lower can improve completion performance at the cost of omitting some options - completer: null # check 'carapace_completer' above as an example + history: { + max_size: 100_000 # Session has to be reloaded for this to take effect + sync_on_enter: true # Enable to share history between multiple sessions, else you have to close the session to write history to file + file_format: "plaintext" # "sqlite" or "plaintext" + isolation: false # only available with sqlite file_format. true enables history isolation, false disables it. true will allow the history to be isolated to the current session using up/down arrows. false will allow the history to be shared across all sessions. } - } - filesize: { - metric: true # true => KB, MB, GB (ISO standard), false => KiB, MiB, GiB (Windows standard) - format: "auto" # b, kb, kib, mb, mib, gb, gib, tb, tib, pb, pib, eb, eib, zb, zib, auto - } - cursor_shape: { - emacs: line # block, underscore, line (line is the default) - vi_insert: block # block, underscore, line (block is the default) - vi_normal: underscore # block, underscore, line (underscore is the default) - } - color_config: $dark_theme # if you want a light theme, replace `$dark_theme` to `$light_theme` - use_grid_icons: true - footer_mode: "25" # always, never, number_of_rows, auto - float_precision: 2 # the precision for displaying floats in tables - # buffer_editor: "emacs" # command that will be used to edit the current line buffer with ctrl+o, if unset fallback to $env.EDITOR and $env.VISUAL - use_ansi_coloring: true - edit_mode: vi # emacs, vi - shell_integration: true # enables terminal markers and a workaround to arrow keys stop working issue - render_right_prompt_on_last_line: false # true or false to enable or disable right prompt to be rendered on last line of the prompt. - hooks: { - pre_prompt: [{|| - null # replace with source code to run before the prompt is shown - }] - pre_execution: [{|| - null # replace with source code to run before the repl input is run - }] - env_change: { - PWD: [{|before, after| - null # replace with source code to run if the PWD environment is different since the last repl input - }] + completions: { + case_sensitive: false # set to true to enable case-sensitive completions + quick: true # set this to false to prevent auto-selecting completions when only one remains + partial: true # set this to false to prevent partial filling of the prompt + algorithm: "prefix" # prefix or fuzzy + external: { + enable: true # set to false to prevent nushell looking into $env.PATH to find more suggestions, `false` recommended for WSL users as this look up may be very slow + max_results: 100 # setting it lower can improve completion performance at the cost of omitting some options + completer: null # check 'carapace_completer' above as an example + } } - display_output: {|| - if (term size).columns >= 100 { table -e } else { table } + + filesize: { + metric: true # true => KB, MB, GB (ISO standard), false => KiB, MiB, GiB (Windows standard) + format: "auto" # b, kb, kib, mb, mib, gb, gib, tb, tib, pb, pib, eb, eib, auto } - command_not_found: {|| - null # replace with source code to return an error message when a command is not found + + cursor_shape: { + emacs: line # block, underscore, line, blink_block, blink_underscore, blink_line (line is the default) + vi_insert: block # block, underscore, line , blink_block, blink_underscore, blink_line (block is the default) + vi_normal: underscore # block, underscore, line, blink_block, blink_underscore, blink_line (underscore is the default) } - } - menus: [ - # Configuration for default nushell menus - # Note the lack of source parameter - { - name: completion_menu - only_buffer_difference: false - marker: "| " - type: { - layout: columnar - columns: 4 - col_width: 20 # Optional value. If missing all the screen width is used to calculate column width - col_padding: 2 + + color_config: {} # if you want a more interesting theme, you can replace the empty record with `$dark_theme`, `$light_theme` or another custom record + use_grid_icons: true + footer_mode: "25" # always, never, number_of_rows, auto + float_precision: 2 # the precision for displaying floats in tables + buffer_editor: "" # command that will be used to edit the current line buffer with ctrl+o, if unset fallback to $env.EDITOR and $env.VISUAL + use_ansi_coloring: true + bracketed_paste: true # enable bracketed paste, currently useless on windows + edit_mode: vi # emacs, vi + shell_integration: false # enables terminal shell integration. Off by default, as some terminals have issues with this. + render_right_prompt_on_last_line: false # true or false to enable or disable right prompt to be rendered on last line of the prompt. + + hooks: { + pre_prompt: [{ null }] # run before the prompt is shown + pre_execution: [{ null }] # run before the repl input is run + env_change: { + PWD: [{|before, after| null }] # run if the PWD environment is different since the last repl input } - style: { - text: green - selected_text: green_reverse - description_text: yellow - } - } - { - name: history_menu - only_buffer_difference: true - marker: "? " - type: { - layout: list - page_size: 10 - } - style: { - text: green - selected_text: green_reverse - description_text: yellow - } - } - { - name: help_menu - only_buffer_difference: true - marker: "? " - type: { - layout: description - columns: 4 - col_width: 20 # Optional value. If missing all the screen width is used to calculate column width - col_padding: 2 - selection_rows: 4 - description_rows: 10 - } - style: { - text: green - selected_text: green_reverse - description_text: yellow - } - } - # Example of extra menus created using a nushell source - # Use the source field to create a list of records that populates - # the menu - { - name: commands_menu - only_buffer_difference: false - marker: "# " - type: { - layout: columnar - columns: 4 - col_width: 20 - col_padding: 2 - } - style: { - text: green - selected_text: green_reverse - description_text: yellow - } - source: { |buffer, position| - $nu.scope.commands - | where name =~ $buffer - | each { |it| {value: $it.name description: $it.usage} } - } - } - { - name: vars_menu - only_buffer_difference: true - marker: "# " - type: { - layout: list - page_size: 10 - } - style: { - text: green - selected_text: green_reverse - description_text: yellow - } - source: { |buffer, position| - $nu.scope.vars - | where name =~ $buffer - | sort-by name - | each { |it| {value: $it.name description: $it.type} } - } - } - { - name: commands_with_description - only_buffer_difference: true - marker: "# " - type: { - layout: description - columns: 4 - col_width: 20 - col_padding: 2 - selection_rows: 4 - description_rows: 10 - } - style: { - text: green - selected_text: green_reverse - description_text: yellow - } - source: { |buffer, position| - $nu.scope.commands - | where name =~ $buffer - | each { |it| {value: $it.name description: $it.usage} } - } - } - ] - keybindings: [ - { - name: completion_menu - modifier: none - keycode: tab - mode: [emacs vi_normal vi_insert] - event: { - until: [ - { send: menu name: completion_menu } - { send: menunext } - ] - } + display_output: { table } # run before the output of a command is drawn, example: `{ if (term size).columns >= 100 { table -e } else { table } }` + command_not_found: { null } # return an error message when a command is not found } - { - name: completion_previous - modifier: shift - keycode: backtab - mode: [emacs, vi_normal, vi_insert] # Note: You can add the same keybinding to all modes by using a list - event: { send: menuprevious } - } - { - name: history_menu - modifier: control - keycode: char_r - mode: emacs - event: { send: menu name: history_menu } - } - { - name: next_page - modifier: control - keycode: char_x - mode: emacs - event: { send: menupagenext } - } - { - name: undo_or_previous_page - modifier: control - keycode: char_z - mode: emacs - event: { - until: [ - { send: menupageprevious } - { edit: undo } - ] - } - } - { - name: yank - modifier: control - keycode: char_y - mode: emacs - event: { - until: [ - {edit: pastecutbufferafter} - ] - } - } - { - name: unix-line-discard - modifier: control - keycode: char_u - mode: [emacs, vi_normal, vi_insert] - event: { - until: [ - {edit: cutfromlinestart} - ] - } - } - { - name: kill-line - modifier: control - keycode: char_k - mode: [emacs, vi_normal, vi_insert] - event: { - until: [ - {edit: cuttolineend} - ] - } - } - # Keybindings used to trigger the user defined menus - { - name: commands_menu - modifier: control - keycode: char_t - mode: [emacs, vi_normal, vi_insert] - event: { send: menu name: commands_menu } - } - { - name: vars_menu - modifier: alt - keycode: char_o - mode: [emacs, vi_normal, vi_insert] - event: { send: menu name: vars_menu } - } - { - name: commands_with_description - modifier: control - keycode: char_s - mode: [emacs, vi_normal, vi_insert] - event: { send: menu name: commands_with_description } - } - ] + + menus: [ + # Configuration for default nushell menus + # Note the lack of source parameter + { + name: completion_menu + only_buffer_difference: false + marker: "| " + type: { + layout: columnar + columns: 4 + col_width: 20 # Optional value. If missing all the screen width is used to calculate column width + col_padding: 2 + } + style: { + text: green + selected_text: green_reverse + description_text: yellow + } + } + { + name: history_menu + only_buffer_difference: true + marker: "? " + type: { + layout: list + page_size: 10 + } + style: { + text: green + selected_text: green_reverse + description_text: yellow + } + } + { + name: help_menu + only_buffer_difference: true + marker: "? " + type: { + layout: description + columns: 4 + col_width: 20 # Optional value. If missing all the screen width is used to calculate column width + col_padding: 2 + selection_rows: 4 + description_rows: 10 + } + style: { + text: green + selected_text: green_reverse + description_text: yellow + } + } + ] + + keybindings: [ + { + name: completion_menu + modifier: none + keycode: tab + mode: [emacs vi_normal vi_insert] + event: { + until: [ + { send: menu name: completion_menu } + { send: menunext } + ] + } + } + { + name: history_menu + modifier: control + keycode: char_r + mode: [emacs, vi_insert, vi_normal] + event: { send: menu name: history_menu } + } + { + name: help_menu + modifier: none + keycode: f1 + mode: [emacs, vi_insert, vi_normal] + event: { send: menu name: help_menu } + } + { + name: completion_previous_menu + modifier: shift + keycode: backtab + mode: [emacs, vi_normal, vi_insert] + event: { send: menuprevious } + } + { + name: next_page_menu + modifier: control + keycode: char_x + mode: emacs + event: { send: menupagenext } + } + { + name: undo_or_previous_page_menu + modifier: control + keycode: char_z + mode: emacs + event: { + until: [ + { send: menupageprevious } + { edit: undo } + ] + } + } + { + name: escape + modifier: none + keycode: escape + mode: [emacs, vi_normal, vi_insert] + event: { send: esc } # NOTE: does not appear to work + } + { + name: cancel_command + modifier: control + keycode: char_c + mode: [emacs, vi_normal, vi_insert] + event: { send: ctrlc } + } + { + name: quit_shell + modifier: control + keycode: char_d + mode: [emacs, vi_normal, vi_insert] + event: { send: ctrld } + } + { + name: clear_screen + modifier: control + keycode: char_l + mode: [emacs, vi_normal, vi_insert] + event: { send: clearscreen } + } + { + name: search_history + modifier: control + keycode: char_r + mode: [emacs, vi_normal, vi_insert] + event: { send: searchhistory } + } + { + name: open_command_editor + modifier: control + keycode: char_o + mode: [emacs, vi_normal, vi_insert] + event: { send: openeditor } + } + { + name: move_up + modifier: none + keycode: up + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: menuup} + {send: up} + ] + } + } + { + name: move_down + modifier: none + keycode: down + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: menudown} + {send: down} + ] + } + } + { + name: move_left + modifier: none + keycode: left + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: menuleft} + {send: left} + ] + } + } + { + name: move_right_or_take_history_hint + modifier: none + keycode: right + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: historyhintcomplete} + {send: menuright} + {send: right} + ] + } + } + { + name: move_one_word_left + modifier: control + keycode: left + mode: [emacs, vi_normal, vi_insert] + event: {edit: movewordleft} + } + { + name: move_one_word_right_or_take_history_hint + modifier: control + keycode: right + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: historyhintwordcomplete} + {edit: movewordright} + ] + } + } + { + name: move_to_line_start + modifier: none + keycode: home + mode: [emacs, vi_normal, vi_insert] + event: {edit: movetolinestart} + } + { + name: move_to_line_start + modifier: control + keycode: char_a + mode: [emacs, vi_normal, vi_insert] + event: {edit: movetolinestart} + } + { + name: move_to_line_end_or_take_history_hint + modifier: none + keycode: end + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: historyhintcomplete} + {edit: movetolineend} + ] + } + } + { + name: move_to_line_end_or_take_history_hint + modifier: control + keycode: char_e + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: historyhintcomplete} + {edit: movetolineend} + ] + } + } + { + name: move_to_line_start + modifier: control + keycode: home + mode: [emacs, vi_normal, vi_insert] + event: {edit: movetolinestart} + } + { + name: move_to_line_end + modifier: control + keycode: end + mode: [emacs, vi_normal, vi_insert] + event: {edit: movetolineend} + } + { + name: move_up + modifier: control + keycode: char_p + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: menuup} + {send: up} + ] + } + } + { + name: move_down + modifier: control + keycode: char_t + mode: [emacs, vi_normal, vi_insert] + event: { + until: [ + {send: menudown} + {send: down} + ] + } + } + { + name: delete_one_character_backward + modifier: none + keycode: backspace + mode: [emacs, vi_insert] + event: {edit: backspace} + } + { + name: delete_one_word_backward + modifier: control + keycode: backspace + mode: [emacs, vi_insert] + event: {edit: backspaceword} + } + { + name: delete_one_character_forward + modifier: none + keycode: delete + mode: [emacs, vi_insert] + event: {edit: delete} + } + { + name: delete_one_character_forward + modifier: control + keycode: delete + mode: [emacs, vi_insert] + event: {edit: delete} + } + { + name: delete_one_character_forward + modifier: control + keycode: char_h + mode: [emacs, vi_insert] + event: {edit: backspace} + } + { + name: delete_one_word_backward + modifier: control + keycode: char_w + mode: [emacs, vi_insert] + event: {edit: backspaceword} + } + { + name: move_left + modifier: none + keycode: backspace + mode: vi_normal + event: {edit: moveleft} + } + { + name: newline_or_run_command + modifier: none + keycode: enter + mode: emacs + event: {send: enter} + } + { + name: move_left + modifier: control + keycode: char_b + mode: emacs + event: { + until: [ + {send: menuleft} + {send: left} + ] + } + } + { + name: move_right_or_take_history_hint + modifier: control + keycode: char_f + mode: emacs + event: { + until: [ + {send: historyhintcomplete} + {send: menuright} + {send: right} + ] + } + } + { + name: redo_change + modifier: control + keycode: char_g + mode: emacs + event: {edit: redo} + } + { + name: undo_change + modifier: control + keycode: char_z + mode: emacs + event: {edit: undo} + } + { + name: paste_before + modifier: control + keycode: char_y + mode: emacs + event: {edit: pastecutbufferbefore} + } + { + name: cut_word_left + modifier: control + keycode: char_w + mode: emacs + event: {edit: cutwordleft} + } + { + name: cut_line_to_end + modifier: control + keycode: char_k + mode: emacs + event: {edit: cuttoend} + } + { + name: cut_line_from_start + modifier: control + keycode: char_u + mode: emacs + event: {edit: cutfromstart} + } + { + name: swap_graphemes + modifier: control + keycode: char_t + mode: emacs + event: {edit: swapgraphemes} + } + { + name: move_one_word_left + modifier: alt + keycode: left + mode: emacs + event: {edit: movewordleft} + } + { + name: move_one_word_right_or_take_history_hint + modifier: alt + keycode: right + mode: emacs + event: { + until: [ + {send: historyhintwordcomplete} + {edit: movewordright} + ] + } + } + { + name: move_one_word_left + modifier: alt + keycode: char_b + mode: emacs + event: {edit: movewordleft} + } + { + name: move_one_word_right_or_take_history_hint + modifier: alt + keycode: char_f + mode: emacs + event: { + until: [ + {send: historyhintwordcomplete} + {edit: movewordright} + ] + } + } + { + name: delete_one_word_forward + modifier: alt + keycode: delete + mode: emacs + event: {edit: deleteword} + } + { + name: delete_one_word_backward + modifier: alt + keycode: backspace + mode: emacs + event: {edit: backspaceword} + } + { + name: delete_one_word_backward + modifier: alt + keycode: char_m + mode: emacs + event: {edit: backspaceword} + } + { + name: cut_word_to_right + modifier: alt + keycode: char_d + mode: emacs + event: {edit: cutwordright} + } + { + name: upper_case_word + modifier: alt + keycode: char_u + mode: emacs + event: {edit: uppercaseword} + } + { + name: lower_case_word + modifier: alt + keycode: char_l + mode: emacs + event: {edit: lowercaseword} + } + { + name: capitalize_char + modifier: alt + keycode: char_c + mode: emacs + event: {edit: capitalizechar} + } + ] } -#alias ls = exa alias grep = rg alias find = fd alias cat = bat @@ -560,3 +832,7 @@ source ~/.cache/zoxide.nu # init starship prompt source ~/.cache/starship/init.nu + +# external completions +source ~/.config/nushell/git-completions.nu +source ~/.config/nushell/cargo-completions.nu diff --git a/tree/.config/nushell/env.nu b/tree/.config/nushell/env.nu index 915d70f..6e9cfc6 100644 --- a/tree/.config/nushell/env.nu +++ b/tree/.config/nushell/env.nu @@ -1,6 +1,6 @@ # Nushell Environment Config File # -# version = 0.78.0 +# version = 0.83.1 def create_left_prompt [] { mut home = "" @@ -13,75 +13,78 @@ def create_left_prompt [] { } let dir = ([ - ($env.PWD | str substring 0..($home | str length) | str replace -s $home "~"), + ($env.PWD | str substring 0..($home | str length) | str replace --string $home "~"), ($env.PWD | str substring ($home | str length)..) ] | str join) - let path_segment = if (is-admin) { - $"(ansi red_bold)($dir)" - } else { - $"(ansi green_bold)($dir)" - } + let path_color = (if (is-admin) { ansi red_bold } else { ansi green_bold }) + let separator_color = (if (is-admin) { ansi light_red_bold } else { ansi light_green_bold }) + let path_segment = $"($path_color)($dir)" - $path_segment + $path_segment | str replace --all --string (char path_sep) $"($separator_color)/($path_color)" } def create_right_prompt [] { + # create a right prompt in magenta with green separators and am/pm underlined let time_segment = ([ - (date now | date format '%m/%d/%Y %r') - ] | str join) + (ansi reset) + (ansi magenta) + (date now | date format '%Y/%m/%d %r') + ] | str join | str replace --all "([/:])" $"(ansi green)${1}(ansi magenta)" | + str replace --all "([AP]M)" $"(ansi magenta_underline)${1}") - $time_segment + let last_exit_code = if ($env.LAST_EXIT_CODE != 0) {([ + (ansi rb) + ($env.LAST_EXIT_CODE) + ] | str join) + } else { "" } + + ([$last_exit_code, (char space), $time_segment] | str join) } # Use nushell functions to define your right and left prompt -let-env PROMPT_COMMAND = {|| create_left_prompt } -let-env PROMPT_COMMAND_RIGHT = {|| create_right_prompt } +$env.PROMPT_COMMAND = {|| create_left_prompt } +# $env.PROMPT_COMMAND_RIGHT = {|| create_right_prompt } # The prompt indicators are environmental variables that represent # the state of the prompt -let-env PROMPT_INDICATOR = {|| "> " } -let-env PROMPT_INDICATOR_VI_INSERT = {|| ": " } -let-env PROMPT_INDICATOR_VI_NORMAL = {|| "> " } -let-env PROMPT_MULTILINE_INDICATOR = {|| "::: " } +$env.PROMPT_INDICATOR = {|| " > " } +$env.PROMPT_INDICATOR_VI_INSERT = {|| " : " } +$env.PROMPT_INDICATOR_VI_NORMAL = {|| " > " } +$env.PROMPT_MULTILINE_INDICATOR = {|| "::: " } # Specifies how environment variables are: # - converted from a string to a value on Nushell startup (from_string) # - converted from a value back to a string when running external commands (to_string) # Note: The conversions happen *after* config.nu is loaded -let-env ENV_CONVERSIONS = { - "PATH": { - from_string: { |s| $s | split row (char esep) | path expand -n } - to_string: { |v| $v | path expand -n | str join (char esep) } - } - "Path": { - from_string: { |s| $s | split row (char esep) | path expand -n } - to_string: { |v| $v | path expand -n | str join (char esep) } - } +$env.ENV_CONVERSIONS = { + "PATH": { + from_string: { |s| $s | split row (char esep) | path expand --no-symlink } + to_string: { |v| $v | path expand --no-symlink | str join (char esep) } + } + "Path": { + from_string: { |s| $s | split row (char esep) | path expand --no-symlink } + to_string: { |v| $v | path expand --no-symlink | str join (char esep) } + } } # Directories to search for scripts when calling source or use -# -# By default, /scripts is added -let-env NU_LIB_DIRS = [ - ($nu.config-path | path dirname | path join 'scripts') +$env.NU_LIB_DIRS = [ + # ($nu.default-config-dir | path join 'scripts') # add /scripts ] # Directories to search for plugin binaries when calling register -# -# By default, /plugins is added -let-env NU_PLUGIN_DIRS = [ - ($nu.config-path | path dirname | path join 'plugins') +$env.NU_PLUGIN_DIRS = [ + # ($nu.default-config-dir | path join 'plugins') # add /plugins ] -# To add entries to PATH (on Windows you might use Path), you can use the following pattern: -let-env PATH = ($env.PATH | split row (char esep) | prepend [($env.HOME + "/.local/bin"), ($env.HOME + "/.cargo/bin")]) +$env.PATH = ($env.PATH | split row (char esep) | prepend [($env.HOME + "/.local/bin"), ($env.HOME + "/.cargo/bin")]) -let-env GPG_TTY = (tty) -let-env BROWSER = "firefox" -let-env EDITOR = "nvim" -let-env DEFMT_LOG = "info" -let-env MOZ_ENABLE_WAYLAND = "1" +$env.GPG_TTY = (tty) +$env.BROWSER = "firefox" +$env.EDITOR = "nvim" +$env.DEFMT_LOG = "info" +$env.MOZ_ENABLE_WAYLAND = "1" mkdir ~/.cache/starship starship init nu | save -f ~/.cache/starship/init.nu diff --git a/tree/.config/nushell/git-completions.nu b/tree/.config/nushell/git-completions.nu new file mode 100644 index 0000000..daee4f9 --- /dev/null +++ b/tree/.config/nushell/git-completions.nu @@ -0,0 +1,419 @@ +def "nu-complete git available upstream" [] { + ^git branch -a | lines | each { |line| $line | str replace '\* ' "" | str trim } +} + +def "nu-complete git remotes" [] { + ^git remote | lines | each { |line| $line | str trim } +} + +def "nu-complete git log" [] { + ^git log --pretty=%h | lines | each { |line| $line | str trim } +} + +# Yield all existing commits in descending chronological order. +def "nu-complete git commits all" [] { + ^git rev-list --all --remotes --pretty=oneline | lines | parse "{value} {description}" +} + +# Yield commits of current branch only. This is useful for e.g. cut points in +# `git rebase`. +def "nu-complete git commits current branch" [] { + ^git log --pretty="%h %s" | lines | parse "{value} {description}" +} + +# Yield local branches like `main`, `feature/typo_fix` +def "nu-complete git local branches" [] { + ^git branch | lines | each { |line| $line | str replace '\* ' "" | str trim } +} + +# Yield remote branches like `origin/main`, `upstream/feature-a` +def "nu-complete git remote branches with prefix" [] { + ^git branch -r | lines | parse -r '^\*?(\s*|\s*\S* -> )(?P\S*$)' | get branch | uniq +} + +# Yield remote branches *without* prefix which do not have a local counterpart. +# E.g. `upstream/feature-a` as `feature-a` to checkout and track in one command +# with `git checkout` or `git switch`. +def "nu-complete git remote branches nonlocal without prefix" [] { + # Get regex to strip remotes prefixes. It will look like `(origin|upstream)` + # for the two remotes `origin` and `upstream`. + let remotes_regex = (["(", ((nu-complete git remotes | each {|r| [$r, '/'] | str join}) | str join "|"), ")"] | str join) + let local_branches = (nu-complete git local branches) + ^git branch -r | lines | parse -r (['^[\* ]+', $remotes_regex, '?(?P\S+)'] | flatten | str join) | get branch | uniq | where {|branch| $branch != "HEAD"} | where {|branch| $branch not-in $local_branches } +} + +def "nu-complete git switch" [] { + (nu-complete git local branches) + | parse "{value}" + | insert description "local branch" + | append (nu-complete git remote branches nonlocal without prefix + | parse "{value}" + | insert description "remote branch") +} + +def "nu-complete git checkout" [] { + (nu-complete git local branches) + | parse "{value}" + | insert description "local branch" + | append (nu-complete git remote branches nonlocal without prefix + | parse "{value}" + | insert description "remote branch") + | append (nu-complete git remote branches with prefix + | parse "{value}" + | insert description "remote branch") + | append (nu-complete git commits all) +} + +# Arguments to `git rebase --onto ` +def "nu-complete git rebase" [] { + (nu-complete git local branches) + | parse "{value}" + | insert description "local branch" + | append (nu-complete git remote branches with prefix + | parse "{value}" + | insert description "remote branch") + | append (nu-complete git commits all) +} + +def "nu-complete git stash-list" [] { + git stash list | lines | parse "{value}: {description}" +} + +def "nu-complete git tags" [] { + ^git tag | lines +} + +def "nu-complete git built-in-refs" [] { + [HEAD FETCH_HEAD ORIG_HEAD] +} + +def "nu-complete git refs" [] { + nu-complete git switchable branches + | parse "{value}" + | insert description Branch + | append (nu-complete git tags | parse "{value}" | insert description Tag) + | append (nu-complete git built-in-refs) +} + +def "nu-complete git subcommands" [] { + ^git help -a | lines | where $it starts-with " " | parse -r '\s*(?P[^ ]+) \s*(?P\w.*)' +} + +# Check out git branches and files +export extern "git checkout" [ + ...targets: string@"nu-complete git checkout" # name of the branch or files to checkout + --conflict: string # conflict style (merge or diff3) + --detach(-d) # detach HEAD at named commit + --force(-f) # force checkout (throw away local modifications) + --guess # second guess 'git checkout ' (default) + --ignore-other-worktrees # do not check if another worktree is holding the given ref + --ignore-skip-worktree-bits # do not limit pathspecs to sparse entries only + --merge(-m) # perform a 3-way merge with the new branch + --orphan: string # new unparented branch + --ours(-2) # checkout our version for unmerged files + --overlay # use overlay mode (default) + --overwrite-ignore # update ignored files (default) + --patch(-p) # select hunks interactively + --pathspec-from-file: string # read pathspec from file + --progress # force progress reporting + --quiet(-q) # suppress progress reporting + --recurse-submodules: string # control recursive updating of submodules + --theirs(-3) # checkout their version for unmerged files + --track(-t) # set upstream info for new branch + -b: string # create and checkout a new branch + -B: string # create/reset and checkout a branch + -l # create reflog for new branch +] + +# Download objects and refs from another repository +export extern "git fetch" [ + repository?: string@"nu-complete git remotes" # name of the branch to fetch + --all # Fetch all remotes + --append(-a) # Append ref names and object names to .git/FETCH_HEAD + --atomic # Use an atomic transaction to update local refs. + --depth: int # Limit fetching to n commits from the tip + --deepen: int # Limit fetching to n commits from the current shallow boundary + --shallow-since: string # Deepen or shorten the history by date + --shallow-exclude: string # Deepen or shorten the history by branch/tag + --unshallow # Fetch all available history + --update-shallow # Update .git/shallow to accept new refs + --negotiation-tip: string # Specify which commit/glob to report while fetching + --negotiate-only # Do not fetch, only print common ancestors + --dry-run # Show what would be done + --write-fetch-head # Write fetched refs in FETCH_HEAD (default) + --no-write-fetch-head # Do not write FETCH_HEAD + --force(-f) # Always update the local branch + --keep(-k) # Keep dowloaded pack + --multiple # Allow several arguments to be specified + --auto-maintenance # Run 'git maintenance run --auto' at the end (default) + --no-auto-maintenance # Don't run 'git maintenance' at the end + --auto-gc # Run 'git maintenance run --auto' at the end (default) + --no-auto-gc # Don't run 'git maintenance' at the end + --write-commit-graph # Write a commit-graph after fetching + --no-write-commit-graph # Don't write a commit-graph after fetching + --prefetch # Place all refs into the refs/prefetch/ namespace + --prune(-p) # Remove obsolete remote-tracking references + --prune-tags(-P) # Remove any local tags that do not exist on the remote + --no-tags(-n) # Disable automatic tag following + --refmap: string # Use this refspec to map the refs to remote-tracking branches + --tags(-t) # Fetch all tags + --recurse-submodules: string # Fetch new commits of populated submodules (yes/on-demand/no) + --jobs(-j): int # Number of parallel children + --no-recurse-submodules # Disable recursive fetching of submodules + --set-upstream # Add upstream (tracking) reference + --submodule-prefix: string # Prepend to paths printed in informative messages + --upload-pack: string # Non-default path for remote command + --quiet(-q) # Silence internally used git commands + --verbose(-v) # Be verbose + --progress # Report progress on stderr + --server-option(-o): string # Pass options for the server to handle + --show-forced-updates # Check if a branch is force-updated + --no-show-forced-updates # Don't check if a branch is force-updated + -4 # Use IPv4 addresses, ignore IPv6 addresses + -6 # Use IPv6 addresses, ignore IPv4 addresses +] + +# Push changes +export extern "git push" [ + remote?: string@"nu-complete git remotes", # the name of the remote + ...refs: string@"nu-complete git local branches" # the branch / refspec + --all # push all refs + --atomic # request atomic transaction on remote side + --delete(-d) # delete refs + --dry-run(-n) # dry run + --exec: string # receive pack program + --follow-tags # push missing but relevant tags + --force-with-lease # require old value of ref to be at this value + --force(-f) # force updates + --ipv4(-4) # use IPv4 addresses only + --ipv6(-6) # use IPv6 addresses only + --mirror # mirror all refs + --no-verify # bypass pre-push hook + --porcelain # machine-readable output + --progress # force progress reporting + --prune # prune locally removed refs + --push-option(-o): string # option to transmit + --quiet(-q) # be more quiet + --receive-pack: string # receive pack program + --recurse-submodules: string # control recursive pushing of submodules + --repo: string # repository + --set-upstream(-u) # set upstream for git pull/status + --signed: string # GPG sign the push + --tags # push tags (can't be used with --all or --mirror) + --thin # use thin pack + --verbose(-v) # be more verbose +] + +# Pull changes +export extern "git pull" [ + remote?: string@"nu-complete git remotes", # the name of the remote + ...refs: string@"nu-complete git local branches" # the branch / refspec + --rebase # rebase current branch on top of upstream after fetching +] + +# Switch between branches and commits +export extern "git switch" [ + switch?: string@"nu-complete git switch" # name of branch to switch to + --create(-c): string # create a new branch + --detach(-d): string@"nu-complete git log" # switch to a commit in a detatched state + --force-create(-C): string # forces creation of new branch, if it exists then the existing branch will be reset to starting point + --force(-f) # alias for --discard-changes + --guess # if there is no local branch which matches then name but there is a remote one then this is checked out + --ignore-other-worktrees # switch even if the ref is held by another worktree + --merge(-m) # attempts to merge changes when switching branches if there are local changes + --no-guess # do not attempt to match remote branch names + --no-progress # do not report progress + --no-recurse-submodules # do not update the contents of sub-modules + --no-track # do not set "upstream" configuration + --orphan: string # create a new orphaned branch + --progress # report progress status + --quiet(-q) # suppress feedback messages + --recurse-submodules # update the contents of sub-modules + --track(-t) # set "upstream" configuration +] + +# Apply the change introduced by an existing commit +export extern "git cherry-pick" [ + commit?: string@"nu-complete git commits all" # The commit ID to be cherry-picked + --edit(-e) # Edit the commit message prior to committing + --no-commit(-n) # Apply changes without making any commit + --signoff(-s) # Add Signed-off-by line to the commit message + --ff # Fast-forward if possible + --continue # Continue the operation in progress + --abort # Cancel the operation + --skip # Skip the current commit and continue with the rest of the sequence +] + +# Rebase the current branch +export extern "git rebase" [ + branch?: string@"nu-complete git rebase" # name of the branch to rebase onto + upstream?: string@"nu-complete git rebase" # upstream branch to compare against + --continue # restart rebasing process after editing/resolving a conflict + --abort # abort rebase and reset HEAD to original branch + --quit # abort rebase but do not reset HEAD + --interactive(-i) # rebase interactively with list of commits in editor + --onto?: string@"nu-complete git rebase" # starting point at which to create the new commits + --root # start rebase from root commit +] + +# List or change branches +export extern "git branch" [ + branch?: string@"nu-complete git local branches" # name of branch to operate on + --abbrev # use short commit hash prefixes + --edit-description # open editor to edit branch description + --merged # list reachable branches + --no-merged # list unreachable branches + --set-upstream-to: string@"nu-complete git available upstream" # set upstream for branch + --unset-upstream # remote upstream for branch + --all # list both remote and local branches + --copy # copy branch together with config and reflog + --format # specify format for listing branches + --move # rename branch + --points-at # list branches that point at an object + --show-current # print the name of the current branch + --verbose # show commit and upstream for each branch + --color # use color in output + --quiet # suppress messages except errors + --delete(-d) # delete branch + --list # list branches + --contains: string@"nu-complete git commits all" # show only branches that contain the specified commit + --no-contains # show only branches that don't contain specified commit + --track(-t) # when creating a branch, set upstream +] + +# List or change tracked repositories +export extern "git remote" [ + --verbose(-v) # Show URL for remotes +] + +# Add a new tracked repository +export extern "git remote add" [ +] + +# Rename a tracked repository +export extern "git remote rename" [ + remote: string@"nu-complete git remotes" # remote to rename + new_name: string # new name for remote +] + +# Remove a tracked repository +export extern "git remote remove" [ + remote: string@"nu-complete git remotes" # remote to remove +] + +# Get the URL for a tracked repository +export extern "git remote get-url" [ + remote: string@"nu-complete git remotes" # remote to get URL for +] + +# Set the URL for a tracked repository +export extern "git remote set-url" [ + remote: string@"nu-complete git remotes" # remote to set URL for + url: string # new URL for remote +] + +# Show changes between commits, working tree etc +export extern "git diff" [ + rev1?: string@"nu-complete git refs" + rev2?: string@"nu-complete git refs" + --cached # show staged changes + --name-only # only show names of changed files + --name-status # show changed files and kind of change + --no-color # disable color output +] + +# Commit changes +export extern "git commit" [ + --all(-a) # automatically stage all modified and deleted files + --amend # amend the previous commit rather than adding a new one + --message(-m): string # specify the commit message rather than opening an editor + --no-edit # don't edit the commit message (useful with --amend) +] + +# List commits +export extern "git log" [ + # Ideally we'd allow completion of revisions here, but that would make completion of filenames not work. + -U # show diffs + --follow # show history beyond renames (single file only) + --grep: string # show log entries matching supplied regular expression +] + +# Show or change the reflog +export extern "git reflog" [ +] + +# Stage files +export extern "git add" [ + --patch(-p) # interactively choose hunks to stage +] + +# Delete file from the working tree and the index +export extern "git rm" [ + -r # recursive +] + +# Show the working tree status +export extern "git status" [ + --verbose(-v) # verbose +] + +# Stash changes for later +export extern "git stash push" [ + --patch(-p) # interactively choose hunks to stash +] + +# Unstash previously stashed changes +export extern "git stash pop" [ +] + +# List stashed changes +export extern "git stash list" [ +] + +# Show a stashed change +export extern "git stash show" [ + stash: string@"nu-complete git stash-list" + -U # show diff +] + +# Drop a stashed change +export extern "git stash drop" [ + stash: string@"nu-complete git stash-list" +] + +# Create a new git repository +export extern "git init" [ + --initial-branch(-b) # initial branch name +] + +# List or manipulate tags +export extern "git tag" [ + --delete(-d): string@"nu-complete git tags" # delete a tag +] + +# Start a binary search to find the commit that introduced a bug +export extern "git bisect start" [ + bad?: string # a commit that has the bug + good?: string # a commit that doesn't have the bug +] + +# Mark the current (or specified) revision as bad +export extern "git bisect bad" [ +] + +# Mark the current (or specified) revision as good +export extern "git bisect good" [ +] + +# Skip the current (or specified) revision +export extern "git bisect skip" [ +] + +# End bisection +export extern "git bisect reset" [ +] + +# Show help for a git subcommand +export extern "git help" [ + command: string@"nu-complete git subcommands" # subcommand to show help for +]