65

I am looking for software similar to nano for linux bash but for windows powershell. Is there any built in so I do not have to install something?

EDIT Nano is a text editor that runs within the bash. You can open a text like document (.txt, .c etc) in the bash to edit it on the fly or just view it and close it again.

ᄂ ᄀ
  • 4,187

9 Answers9

51

Nano is available for powershell. If you have the Chocolatey package manager installed in your system you can install nano with:

choco install nano

You can install Chocolatey through the command line with:

Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

My personal experience is that it nano performs great in Windows 10 but it's really slow to start up the first time in Windows 7.

38

Just install Windows Subsystem for Linux (WSL). Then, type.

wsl nano

or

wsl nano textfilenametoedit.txt

Quotes are not needed.

Daan
  • 481
28

There is now a way to use nano and vim with powershell by installing "Bash on Windows". More information on Scott Hanselman blog

From command line you can run

bash -c "vi filename.txt"
bash -c "nano filename.txt"

you can also add those functions to your powershell profile

function vi ($File){
    bash -c "vi $File"
}

function nano ($File){
    bash -c "nano $File"
}

The blog source where I got the information from

phuclv
  • 30,396
  • 15
  • 136
  • 260
12

The only built-in editor in Windows is Notepad. It should already be in your path, so you can just type notepad something.txt in the PowerShell console.

If you want console-based editors, there are some here: https://stackoverflow.com/questions/11045077/edit-a-text-file-on-the-console-in-64-bit-windows

A useful thing to do is to make an alias called "edit" (for example) for your favorite text editor. Put something like this in your profile:

set-alias edit "${env:ProgramFiles}\Sublime Text 3\sublime_text.exe"
dangph
  • 5,093
5

Git for Windows (choco pkg) has nano, vim (and prob'ly others) built in. Setting a PowerShell alias/function will make them easier to launch. E.g.:

function nano { C:\Progra~1\Git\usr\bin\nano.exe --ignorercfiles $args }

Place this command in your shell startup script by:

  1. Copying the command above
  2. Paste into powershell console
  3. Run "nano $profile"
  4. Paste again into the script file
  5. Ctl-X to save,exit

EDIT: Changed command to ignore syntax highlighting files (which doesn't work by default). Original command:

set-alias nano C:\Progra~1\Git\usr\bin\nano.exe
Peter L
  • 181
  • 1
  • 3
2

Nano editor has a win32 version, you can download it from here https://nano-editor.org/dist/win32-support/

You can download "nano-git-0d9a7347243.exe" file, rename it to "nano.exe", and add the folder you saved the file in to the environment variable "Path".

1

To add to the answers you've already received, you can have a shell editor in Windows, by installing Vim for windows, from Vim's official page.

https://www.vim.org/download.php

0

Using MSYS and MinGW

Copy the produced binary nano.exe to your environment. You can get this:

From source

I installed MYSYS with MinGW and was able to:

$ pacman -S tar gcc ncurses ncurses-devel
$ f='nano-5.8'  # Change this line for a different v5 version
$ curl --proto '=https' --tlsv1.2 -sSf 'https://www.nano-editor.org/dist/v5/'"$f"'.tar.xz'
$ tar xf "$f"'.tar.xz' && cd "$f"
$ ./configure
$ make  # See './src/nano.exe'

From pre-compiled package

$ pacman -S nano

to get it working in that environment:

From source (patched for Windows)

In case you keep getting Error opening terminal: xterm-256color. errors:

$ pacman -S git
$ git clone https://github.com/lhmouse/nano-win
$ cd nano-win  # tested on `38790067`
$ ./build_nano-win.sh

From archive

Or just download the package directly and add it to your PATH:

https://mirror.msys2.org/msys/x86_64/nano-5.8-1-x86_64.pkg.tar.zst (extract with Modern 7-zip + 7-zip, or unzstd) and exes from nano-5.8-1-x86_64.pkg.tar.zst\nano-5.8-1-x86_64.pkg.tar\usr\bin\ to your PATH, along with (from msys64\usr\bin\ or the archives): msys-ncursesw6.dll, msys-2.0.dll, msys-magic-1.dll, msys-intl-8.dll, msys-iconv-2.dll, msys-bz2-1.dll, msys-z.dll


Test, on cmd.exe (Windows Command Prompt)

> nano --version
 GNU nano, version 5.8
 (C) 1999-2011, 2013-2021 Free Software Foundation, Inc.
 (C) 2014-2021 the contributors to nano
 Compiled options: --enable-utf8

If it works, invocation of nano will look like:

  GNU nano 5.8                        New Buffer
           [ Welcome to nano.  For basic help, type Ctrl+G. ]

^G Help ^O Write Out ^W Where Is ^K Cut ^T Execute ^C Location ^X Exit ^R Read File ^\ Replace ^U Paste ^J Justify ^_ Go To Line

A T
  • 821
  • 1
  • 12
  • 26
0

GNU nano is available for Windows and can easily be installed using WinGet (run as Administrator):

winget install -e --id GNU.Nano

It's quite dated build though (2.7.5). If you don't want to bloat your system and install Git, MSYS or WSL only to get a simple text editor, consider micro:

winget install -e --id zyedidia.micro
ᄂ ᄀ
  • 4,187