0

How is nano launched from within the PowerShell console?

Just looking for a simple way to edit a text file without switching a GUI or bash.

bash -c "nano filename.txt"

was unusable. Something like what "ed" was to edit files. Even vi or vim would be acceptable, but emacs would be too complex.

Is there another way to run nano or its ilk from within the PS console?

note: not using the WSL (Windows Subsystem for Linux)

Nicholas Saunders
  • 1,054
  • 4
  • 16
  • 37
  • 1
    not using the WSL (Windows Subsystem for Linux). Is that why the votes to close? It's an Ubuntu q. – Nicholas Saunders Feb 23 '21 at 05:34
  • reviewers: **note: not using the WSL (Windows Subsystem for Linux)** according to the last paragraph of the question. Please retract your incorrect reviews to close this question because "This is not about an official Ubuntu flavor", – karel Feb 23 '21 at 05:47
  • What's wrong with just running `nano`? Why this `bash -c "nano"` rigmarole? – muru Feb 23 '21 at 08:19

1 Answers1

2

From Ubuntu

I tested launching nano from PowerShell running in Ubuntu 20.04 which was installed by sudo snap install powershell --classic and it worked as shown in the following screenshots.

enter image description here Launch nano from PowerShell running in Ubuntu.

enter image description here
nano opens in the same terminal window. PowerShell in still running in the background.

You can return to PowerShell from nano by pressing the keyboard combination Ctrl + X to exit from nano.

From Windows 10

The Windows Subsystem for Linux (WSL) is continuously improving integration between Windows and Linux. You can:

  • Run Windows tools (i.e. notepad.exe) from a Linux command line (i.e. Ubuntu).
  • Run Linux tools (i.e. grep [or nano] ) from a Windows command line (i.e. PowerShell).
  • Share environment variables between Linux and Windows. (Build 17063+)

Run Linux binaries from the Windows Command Prompt (CMD) or PowerShell using wsl <command> (or wsl.exe <command> ). Binaries invoked in this way:

  • Use the same working directory as the current CMD or PowerShell prompt.
  • Run as the WSL default user.
  • Have the same Windows administrative rights as the calling process and terminal.

The Linux command following wsl (or wsl.exe) is handled like any command run in WSL. Things such as sudo, piping, and file redirection work. source

karel
  • 110,292
  • 102
  • 269
  • 299
  • My apologies, I'm not using the WSL. I'll update the q to clarify that point. Just using Ubuntu directly. I think that's why it's not working (?). – Nicholas Saunders Feb 23 '21 at 05:33