Wednesday, February 12, 2020

Tutorial: Cisco/Juniper syntax highlight via SSH

Hello,

I found a quite easy way to get Cisco, Juniper and more or less any vendor syntax highlight while working via SSH on a node. Example below with show run on a Cisco router:

http://image.noelshack.com/fichiers/2020/07/3/1581517429-screenshot-2020-02-12-at-15-21-52.png

This work by running a terminal inside Neovim. For Neovim, your terminal is a file, so neovim can apply file syntax highlighting. I know this sound tricky, but it works super well, and you can use it in your favorite terminal emulator for any language supported by neovim (I tested with Junos and IOS).

Installation:

  1. Install Neovim. This does not work with regular VIM with my tests.
  2. Install a plugin manager for Neovim, suck as Vim plug: https://github.com/junegunn/vim-plug.
  3. Create the file ~/.config/nvim/init.vim with the following content: https://pastebin.com/BQcq9P2P

You're all set. Now you just need to SSH to a device doing the following steps.

  1. In a terminal, start neovim: nvim
  2. Create a shell inside neovim with the command :term
  3. You're are now in a terminal inside a neovim buffer. You can use i and Esc to switch between terminal mode (where you can write like in a normal terminal) and normal mode (used to run Neovim command). From here, SSH to a router/switch/...
  4. Use the command :set ft=cisco to activate syntax highlighting. Replace cisco by junos for Juniper nodes.


No comments:

Post a Comment