TLDR: Add syntax highlighting to your SSH sessions with live network devices (Juniper/Cisco/Arista).
- Overview
- Examples
- Benefits
- Prerequisites
- Installation
- Usage
- Supported Platforms
- Limitations
- Troubleshooting
- Acknowledgments
If you've ever used the CLI on network devices, you've probably struggled to make sense of long configuration outputs. While editors like vim, VSCode, or Sublime provide syntax highlighting, reading config files or command outputs directly on live devices remains challenging.
Here's a Juniper SRX firewall policy without highlighting:
This rule contains source/destination/application/actions components. Reading one rule is manageable, but parsing through 10+ rules makes it difficult to differentiate each component.
With syntax highlighting:
This repo demonstrates how to add real-time syntax highlighting to your SSH sessions with network devices. It's not a comprehensive solution, but a starting point you can customize to your needs.
Note: The default color scheme is optimized for dark terminal backgrounds.
- Faster troubleshooting - Quickly identify misconfigurations or issues like downed interfaces
- Customizable colors - Adapt color schemes to your preference using HTML color codes
- Flexible patterns - Modify regex patterns to match your specific Network OS (NOS) and version
- Python 3.7 or higher
- SSH access to network devices (Juniper/Cisco/Arista)
- A terminal with color support
-
Clone this repository:
git clone [email protected]:danielmacuare/netcli-highlight.git cd netcli-highlight/
-
Install ChromaTerm using one of these methods:
# Via pip pip install chromaterm # Via uv (global tool) uv tool install chromaterm # Via uv (virtual environment) uv pip install chromaterm
-
Copy the configuration file to your home directory:
cp .chromaterm.yml ~/.chromaterm.yml -
Configure your shell to pipe SSH through ChromaTerm:
For bash:
echo 'ssh() { /usr/bin/ssh "$@" | ct; }' >> ~/.bash_profile
For zsh:
echo 'ssh() { /usr/bin/ssh "$@" | ct; }' >> ~/.zshrc
-
Reload your shell configuration or open a new terminal window.
Test the highlighting with the provided examples:
cat tests/arista_pref_list.txt | ctConnect to your network device via SSH and run any show command:
ssh user@device
show interfaces
show ip bgp summary
show configurationThe output will automatically be highlighted based on the patterns in ~/.chromaterm.yml.
Edit ~/.chromaterm.yml to:
- Add new regex patterns for your specific commands
- Modify colors (use HTML color codes)
- Adjust patterns for different NOS versions
Refer to the ChromaTerm documentation for configuration options.
- Network OS: Juniper JunOS, Cisco IOS/IOS-XE/NX-OS, Arista EOS
- Operating Systems: Linux, macOS, WSL on Windows
- Shells: bash, zsh, and other POSIX-compatible shells
- The included configuration has been tested with a limited set of Juniper, Cisco, and Arista devices
- Different NOS versions may require pattern adjustments in
.chromaterm.yml - Some commands or output formats may not be covered by the default patterns
- Highlighting patterns are regex-based and may need tuning for edge cases
Highlighting not working:
- Verify ChromaTerm is installed:
ct --version - Check that
~/.chromaterm.ymlexists and is readable - Ensure your shell function is loaded (restart terminal or source your profile)
- Test with local files first:
cat tests/arista_pref_list.txt | ct
Colors look wrong:
- The default config is optimized for dark backgrounds
- Adjust colors in
~/.chromaterm.ymlfor your terminal theme - Verify your terminal supports 256 colors
SSH function conflicts:
- If you have existing SSH aliases or functions, they may conflict
- Rename the function or adjust the wrapper accordingly
This project is built on ChromaTerm by hSaria. ChromaTerm is a powerful tool that enables syntax highlighting for interactive applications like SSH. Thank you for creating such a versatile solution!





