https://github.com/gerph/nano-colour
Colour files using nanorc syntax colouring
https://github.com/gerph/nano-colour
nanorc-rcfiles syntax-highlighting
Last synced: 21 days ago
JSON representation
Colour files using nanorc syntax colouring
- Host: GitHub
- URL: https://github.com/gerph/nano-colour
- Owner: gerph
- License: mit
- Created: 2026-04-21T23:43:25.000Z (2 months ago)
- Default Branch: master
- Last Pushed: 2026-05-07T23:57:13.000Z (about 2 months ago)
- Last Synced: 2026-05-08T01:32:39.247Z (about 2 months ago)
- Topics: nanorc-rcfiles, syntax-highlighting
- Language: Perl
- Homepage:
- Size: 99.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
- Agents: AGENTS.md
Awesome Lists containing this project
README
# nano-colour - colouring files using nanorc definitions
This repository provides a Perl-based syntax highlighter that leverages `nanorc` configuration files to provide ANSI-colored output in the terminal.
## Purpose
The primary tool in this repository is `nano-colour`. It was designed to bring `nano`-style syntax highlighting to the command line, allowing you to view highlighted source code directly in your terminal or pipe it to other tools.
## Features
- **Syntax Auto-discovery**: Automatically selects the correct highlighting rules based on the file extension.
- **Support for `nanorc` Syntax**: Parses standard `nanorc` files, supporting:
- Single-line regex rules (`color`, `icolor`).
- Multi-line rules (`start="..." end="..."`).
- Foreground and background color combinations.
- `bright` color modifiers.
- **Flexible Input**:
- Highlights files by name.
- Supports reading from `STDIN` (when syntax is specified).
- **Customizable Syntax Path**: Uses the `NANOCOLOUR_DIR` environment variable to locate highlighting definitions.
## Installation
The `nano-colour` script is a standalone Perl script. Ensure you have Perl installed on your system.
```bash
# Add the script to your path or run it directly
chmod +x nano-colour
```
## Usage
### Basic Usage
To highlight a file, provide the filename and the directory containing `.nanorc` files:
```bash
./nano-colour myfile.pl examples/
```
### Using Environment Variables
You can set `NANOCOLOUR_DIR` to avoid passing the directory every time:
```bash
export NANOCOLOUR_DIR=$(pwd)/examples
./nano-colour myfile.pl
```
### Specifying Syntax Manually
Use the `-s` or `--syntax` option to force a specific highlighting scheme:
```bash
./nano-colour -s perl myfile.txt
```
### Highlighting from STDIN
When a syntax is forced, `nano-colour` can read from standard input:
```bash
cat myfile.pl | ./nano-colour -s perl
```
## Examples
The `examples/` directory contains a variety of `nanorc` definitions for popular formats, including:
- Bash, C, HTML, JavaScript, JSON, Lua, Makefile, Markdown, Perl, Python, XML, YAML, and even `nanorc` itself.
## License
This project is licensed under the MIT License.