Skip to content

Instantly share code, notes, and snippets.

@eggplants
Last active July 8, 2024 09:54
Show Gist options
  • Save eggplants/d8ab847ddc5c433d5a09cba5d009b93f to your computer and use it in GitHub Desktop.
Save eggplants/d8ab847ddc5c433d5a09cba5d009b93f to your computer and use it in GitHub Desktop.
Enabling nano-win as `nano` command on Powershell

My nano-win configuration on Powershell

Please replace <name> with your username.

  1. Download an archive and extract it

  2. Add below code to $profile:

function LaunchNano {
    "Microsoft.PowerShell.Core\FileSystem::C:\Users\${env:USERNAME}\nano\nano.exe ${args}" | invoke-expression
}
Set-Alias -Name nano -Value LaunchNano
  1. Move nano-win\bin\nano.exe into C:\Users\<name>\nano\

  2. Move nano-win\share\nano\*.nanorc into C:\Users\<name>\nanorc\

  3. Add below code to C:\Users\<name>\.nanorc:

include "C:/Users/<name>/nanorc/*.nanorc"

set autoindent
set constantshow
set linenumbers
set tabsize 4

# Color
set titlecolor white,red
set numbercolor white,blue
set selectedcolor white,green
set statuscolor white,green
  1. To highlight more language codes, copy *.nanorc from scopatz/nanorc serialhex/nano-highlight to C:\Users\<name>\nanorc\

cd
mkdir -Path nano-win,nano,nanorc
cd nano-win

$targetHost = "https://files.lhmouse.com/nano-win/"
$content = (Invoke-WebRequest $targetHost).Content.Split([Environment]::NewLine) | Select-String 'nano-win' -List -SimpleMatch |  Select-Object -First 1
$targetUrl = $content.ToString() | ForEach-Object { $targetHost + $_.split('"')[3] }
Invoke-WebRequest $targetUrl -OutFile nano-win.7z

tar.exe -xf .\nano-win.7z -v
mv .\pkg_x86_64-w64-mingw32\bin\nano.exe ~\nano
mv .\pkg_x86_64-w64-mingw32\share\nano\*.nanorc ~\nanorc

@'
include "~/nanorc/*.nanorc"

set autoindent
set constantshow
set linenumbers
set tabsize 4

# Color
set titlecolor white,red
set numbercolor white,blue
set selectedcolor white,green
set statuscolor white,green
'@ | Out-File -FilePath ~\.nanorc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment