Nano is the text editor I use most from the terminal, on both Mac OS X and Raspberry Pi, and syntax highlighting is a great help when editing files.
Recently, while editing some HAP-NodeJS files, I immediately noticed that this feature was not being activated, because these files have a “.ts” extension instead of “.js”.
To enable JavaScript syntax highlighting for these files, I did the following:
sudo cp /usr/share/nano/javascript.nanorc /usr/share/nano/typescript.nanorc
then I edited this file
sudo nano /usr/share/nano/typescript.nanorc
and change the extension in the line containing syntax javascript "\.js$" to syntax javascript "\.ts$"
Save the file with CTRL+O, press ENTER to confirm, close the file with CTRL+X and you’re done!
Enjoy!
