1

After new Ubuntu server installations sometimes Nano is highlighting text and sometimes it doesn't.

I pay for a hosting provider that let me install new VPSs in a few clicks. I usually Install Ubuntu 16.04 VPSs and then tunnel into them from local Ubuntu.

My question:

I usually create a file in nano, paste in a ready script, and execute.

Why does sometime the syntax of the script is highlight and sometimes it doesn't?

For example, say I created 2 VPSs:

In one the script content is highlighted only in White and in another different parts have different colors like in the picture below:

I ask why, why it's like that only in some installations but not in all of them?

enter image description here

1

Nano 2.5.3 cannot "guess" what is the language I code in. If I just execute nano and then paste in a script content, it will all be white (or the default general text color for the editor).

If I paste this command:

nano ~/ses.sh && chmod +x ~/ses.sh && bash ~/ses.sh && rm ~/ses.sh

Then the syntax will be highlighted accordingly to the file extension (in this case .sh).

Until a few minutes I didn't know that actually doing nano filename.extension (like nano ses.sh) is what making nano to use the specific styling. I didn't know it's associated but now I've learned that.

Note: If you used a similar script creation process and still didn't have the color it might be due to a bug or partial stuckage of your TTY (that is, in simple words, terminal window) and starting a new session should fix that.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.