A nushell plugin for syntax highlighting.
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.
The highlight
command can be used for syntax highlighting source code.
Here are a few examples:
```nushell
open Cargo.toml -r | highlight toml
open src/main.rs | highlight Rust
open example.sh | highlight
open Cargo.toml -r | highlight toml -t ansi
highlight --list-themes ```
language <string>
:
This is an optional parameter that can be used to specify the language or file
extension to aid language detection.-h, --help
:
Display the help message for the highlight command.
-t, --theme <string>
:
The theme used for highlighting.
--list-themes
:
List all possible themes.
The plugin can be configured using environment variables:
Enable or disable true colors (24-bit).
By default, this is enabled.
nushell
let-env NU_PLUGIN_HIGHLIGHT_TRUE_COLORS = true
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.NU_PLUGIN_HIGHLIGHT_THEME
to result
in a single row with your selected theme.
If you get no results, you have set an invalid theme.
nushell
let-env NU_PLUGIN_HIGHLIGHT_THEME = ansi
Installing and registering the nu-plugin-highlight
is a straightforward
process.
Follow these steps:
Install the plugin from crates.io using cargo:
nushell
cargo install nu-plugin-highlight
Restart your terminal session to ensure the newly installed plugin is recognized.
Register the plugin with Nushell:
nushell
register (which nu_plugin_highlight).path
After registering, the plugin is available as part of your set of commands:
nushell
help commands | where command_type == "plugin"
nu_plugin_highlight
is licensed under the MIT License.
See LICENSE for more information.