Intro

So I was looking for some lightweight editor as alternative to VS Code, because I often need to quickly edit text files right from Windows Terminal. Luckily I knew nano from linux and in this post I’ll show you how to use it in Windows Terminal.

Editing inside Windows Terminal

In order to use nano in WT, we have to install it first. We have two options, either use nano trough wsl or install only nano separately using chocolatey.

nano in WSL

If you haven’t installed wsl, follow these instructions – https://docs.microsoft.com/en-us/windows/wsl/install-win10. First let’s make sure nano is installed in your linux distro. Run wsl nano, if you see message nano: command not found, run following code to install it(keep in mind that these steps may difer in your linux distro):

After you successfuly installed nano inside wsl, you can simply use it whenever you need:

Standalone nano

I personaly prefer using standalone nano. In order to install it, you need to have chocolatey. If you don’t, follow these install instructions – https://chocolatey.org/install. Then, to install nano itself, run following snipet as administrator:

Now you can use nano like in wsl:

file

To exit file press CTRL+X.

Viewing files inside Windows Terminal

Viewing files in PowerShell or Windows Terminal is simple, we can use Get-Content cmdlet or cat e.g. cat .\movies.txt.

Bonus – cat with syntax highlighting

file

First you need to install python and pip – https://phoenixnap.com/kb/install-pip-windows. Then you can run:

Then we need, to add function to PowerShell profile, as alias for pygmentize command, run nano $PROFILE, paste following function:

hit CTRL+X, Y and Enter. Finally run . $PROFILE to reload PS profile. Now you can enjoy syntax highlited cat using:

Congratulations, you’ve successfuly installed nano editor and you can enjoy editing in Windows Terminal. Happy coding!

Last modified: February 7, 2022
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments