45

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.

3
  • I don't know if this works but maybe it's possible to get edit.com off an XP machine and use it in powershell on windows 7. I don't know if Win7 32bit has edit.com but win7 64bit doesn't have edit.com
    – barlop
    Jul 8 '15 at 22:14
  • 1
    Assume someone knows everything about PowerShell and could help you, but doesn't know much about Linux or what Nano may be. Maybe you should describe what you want to do. Jul 9 '15 at 2:45
  • 1
    @PeterHahndorf You were right, I edited it Jul 9 '15 at 6:25
22

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

wsl nano

or

wsl nano textfilenametoedit.txt

Quotes are not needed.

2
  • 7
    This may be obvious to some people, but it tripped me up for a bit: if you're supplying a full path to the file, make sure you pass the path that you would use in WSL, not in Windows. For example, if you want to edit C:\text.txt, instead of using wsl nano C:\text.txt, use wsl nano /mnt/c/text.txt
    – Matt
    Apr 12 '19 at 18:30
  • to see the content, wsl cat filename. To see top content: wsl head filename . To see tail content> wsl tail filename May 24 at 15:39
36

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.

2
  • This is the best answer Feb 12 '20 at 13:14
  • 1
    choco has an old version of nano though (2.x atm). Git for Windows comes with a newer version (4.9.x atm).
    – tolache
    Sep 10 '20 at 10:26
22

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

2
  • Those smart quotes in your post will become stupid to the shells and cause problems. I've fixed them for you this time
    – phuclv
    Oct 17 '17 at 3:25
  • Yes. Since powershell has been updated. Thank you for the updated answer, I swapped the accepted one to yours Oct 17 '17 at 8:25
10

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"
6
  • 1
    Newer versions of Windows also have powershell_ise.exe built-in and in the path. A pretty good editor for PowerShell scripts. Jul 9 '15 at 7:24
  • so no built in powershell editor inside the shell? only external programs that run outside of powershell? Jul 9 '15 at 7:30
  • 1
    @John Demetriou, I'm not sure what you mean by "built in" now. There are two stock text editors that come with Windows: Notepad and PowerShell ISE (thanks Peter). If you want a console-based editor, then the link above has some. There is no stock, console-based editor in recent versions of Windows.
    – dangph
    Jul 9 '15 at 7:43
  • that's what I meant, stock console based editor. ok thanks. I will look in the link you provide and choose. thanks Jul 9 '15 at 7:58
  • 1
    To use the ISE editor: psEdit \path\to\file.txt ... To switch back and forth between the editor and powershell ctrl + s and ctrl + d Jan 17 '17 at 23:54
4

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

set-alias nano C:\Progra~1\Git\usr\bin\nano.exe

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
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

1

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".

2
  • 1
    how is this different from the other answers?
    – Lee_Dailey
    Mar 9 at 19:32
  • FYI: This version is from 2017
    – A T
    Jul 6 at 2:27
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

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