Jesús Pérez d9ef2f0d5b
Some checks failed
Build and Test / Validate Setup (push) Has been cancelled
Build and Test / Build (darwin-amd64) (push) Has been cancelled
Build and Test / Build (darwin-arm64) (push) Has been cancelled
Build and Test / Build (linux-amd64) (push) Has been cancelled
Build and Test / Build (windows-amd64) (push) Has been cancelled
Build and Test / Build (linux-arm64) (push) Has been cancelled
Build and Test / Security Audit (push) Has been cancelled
Build and Test / Package Results (push) Has been cancelled
Build and Test / Quality Gate (push) Has been cancelled
Nightly Build / Check for Changes (push) Has been cancelled
Nightly Build / Validate Setup (push) Has been cancelled
Nightly Build / Nightly Build (darwin-amd64) (push) Has been cancelled
Nightly Build / Nightly Build (darwin-arm64) (push) Has been cancelled
Nightly Build / Nightly Build (linux-amd64) (push) Has been cancelled
Nightly Build / Nightly Build (windows-amd64) (push) Has been cancelled
Nightly Build / Nightly Build (linux-arm64) (push) Has been cancelled
Nightly Build / Create Nightly Pre-release (push) Has been cancelled
Nightly Build / Notify Build Status (push) Has been cancelled
Nightly Build / Nightly Maintenance (push) Has been cancelled
chore: update all plugins to Nushell 0.111.0
- Bump all 18 plugins from 0.110.0 to 0.111.0
  - Update rust-toolchain.toml channel to 1.93.1 (nu 0.111.0 requires ≥1.91.1)

  Fixes:
  - interprocess pin =2.2.x → ^2.3.1 in nu_plugin_mcp, nu_plugin_nats, nu_plugin_typedialog
    (required by nu-plugin-core 0.111.0)
  - nu_plugin_typedialog: BackendType::Web initializer — add open_browser: false field
  - nu_plugin_auth: implement missing user_info_to_value helper referenced in tests

  Scripts:
  - update_all_plugins.nu: fix [package].version update on minor bumps; add [dev-dependencies]
    pass; add nu-plugin-test-support to managed crates
  - download_nushell.nu: rustup override unset before rm -rf on nushell dir replace;
    fix unclosed ) in string interpolation
2026-03-11 03:22:42 +00:00

4.4 KiB

nu-plugin-highlight

A nushell plugin for syntax highlighting.


Version License

About

nu-plugin-highlight is a plugin for Nushell that provides syntax highlighting for source code. It uses the syntect library for syntax highlighting and the bat library for easy access to its ready-to-use assets. Custom themes can be loaded too.

Usage

The highlight command can be used for syntax highlighting source code. Here are a few examples:

nushell
# Highlight a Markdown file by guessing the type from the pipeline metadata
open README.md | highlight

# Highlight a TOML file by its file extension
open Cargo.toml -r | echo $in | highlight toml

# Highlight a Rust file by programming language name
open src/main.rs | echo $in | highlight Rust

# Highlight a bash script by inferring the language (the file should start with a shebang)
open example.sh | echo $in | highlight

# Highlight a TOML file with a different theme
open Cargo.toml -r | highlight -t ansi

# List all available themes
highlight --list-themes

Parameters

  • language <string>: This is an optional parameter that can be used to specify the language or file extension to aid language detection.

Flags

  • -h, --help: Display the help message for the highlight command.

  • -t, --theme <string>: The theme used for highlighting.

  • --list-themes: List all possible themes.

Configuration

The plugin can be configured using the $env.config.plugins.highlight variable.

true_colors

Enable or disable true colors (24-bit). By default, this is enabled.

nushell
$env.config.plugins.highlight.true_colors = true

theme

Set a theme to use. The default theme depends on the operating system. Use highlight --list-themes | where default == true to see your default theme. Setting this environment variable should allow highlight --list-themes | where id == $env.config.plugins.highlight.theme to result in a single row with your selected theme. If you get no results, you have set an invalid theme.

nushell
$env.config.plugins.highlight.theme = ansi

custom_themes

Set a directory to load custom themes from. Using synctects theme loader, you can load custom themes in the .tmtheme format from a directory that is passed as this configuration value.

nushell
$env.config.plugins.highlight.custom_themes = ~/.nu/highlight/themes

Plugin Installation

Installing and registering the nu-plugin-highlight is a straightforward process. Follow these steps:

  1. Install the plugin from crates.io using cargo:

    cargo install nu_plugin_highlight
    
  2. Restart your terminal session to ensure the newly installed plugin is recognized.

  3. Find path of your installation:

    which nu_plugin_highlight
    
  4. Register the plugin with Nushell:

    If you are using a version lower than 0.93.0, use register instead of plugin add.

    plugin add path/to/the/plugin/binary
    
  5. Make the plugin available for use:

    Tip: You can simply restart the shell or terminal. When nushell starts, it loads all plugins.

    If you are using a version lower than 0.93.0, you do not need to do this.

    plugin use highlight
    

After registering, the plugin is available as part of your set of commands:

nushell
help commands | where command_type == "plugin"

Version Numbering

Starting with version v1.1.0, the version number of nu-plugin-highlight incorporates the version number of its dependency, nu-plugin. This is denoted in the format v1.1.0+0.90.1, where v1.1.0 refers to the version of nu-plugin-highlight and 0.90.1 refers to the version of the nu-plugin dependency.

License

nu_plugin_highlight is licensed under the MIT License. See LICENSE for more information.