Windows 在命令列安裝 nano 指令

進 Windows CMD 命令列/命令提示符
cmd
進入 PS
powershell
確認是否有安裝 choco
Get-ChildItem C:\ProgramData\Chocolatey
有的話,會顯示該資料夾

目錄: C:\ProgramData\Chocolatey


Mode                 LastWriteTime         Length Name                                                               
----                 -------------         ------ ----                                                               
d-----        2025/2/5  下午 03:41                bin                                                                 
d-----        2025/2/5  下午 03:39                config                                                               
d-----        2025/2/5  下午 03:39                helpers                                                             
d-----        2025/2/5  下午 03:41                lib                                                                 
d-----        2025/2/5  下午 03:39                logs                                                                 
d-----        2025/2/5  下午 03:39                redirects                                                           
d-----        2025/2/5  下午 03:39                tools                                                               
-a----       2025/1/29  上午 11:17       11596840 choco.exe                                                           
-a----       2025/1/29  上午 11:17              0 choco.exe.ignore                                                     
-a----       2025/1/29  上午 11:17           2997 choco.exe.manifest                                                   
-a----       2025/1/29  上午 11:17          56057 CREDITS.txt                                                         
-a----       2025/1/29  上午 11:17            670 LICENSE.txt      
沒有以上文件的話,刪除該資料夾
Remove-Item -Recurse -Force C:\ProgramData\Chocolatey
安裝 chocolatey

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
結尾應該要看到這些

Installing Chocolatey on the local machine
Creating ChocolateyInstall as an environment variable (targeting 'Machine') 
  Setting ChocolateyInstall to 'C:\ProgramData\chocolatey'
WARNING: It's very likely you will need to close and reopen your shell
  before you can use choco.
Restricting write permissions to Administrators
We are setting up the Chocolatey package repository.
The packages themselves go to 'C:\ProgramData\chocolatey\lib'
  (i.e. C:\ProgramData\chocolatey\lib\yourPackageName).
A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin'
  and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'.

Creating Chocolatey CLI folders if they do not already exist.

chocolatey.nupkg file not installed in lib.
 Attempting to locate it from bootstrapper.
PATH environment variable does not have C:\ProgramData\chocolatey\bin in it. Adding...
WARNING: Not setting tab completion: Profile file does not exist at 'C:\Users\SkysentryTSMC\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'.
Chocolatey CLI (choco.exe) is now ready.
You can call choco from anywhere, command line or powershell by typing choco.
Run choco /? for a list of functions.
You may need to shut down and restart powershell and/or consoles
 first prior to using choco.
Ensuring Chocolatey commands are on the path
Ensuring chocolatey.nupkg is in the lib folder
確認已安裝 choco,有出現版本就ok
choco -v
安裝 nano
choco install nano
成功的話,應該會有以下內容

Chocolatey v2.4.2
Installing the following packages:
nano
By installing, you accept licenses for the packages.
Downloading package from source 'https://community.chocolatey.org/api/v2/'
Progress: Downloading nano-win 7.2.36.20230412... 100%

nano-win v7.2.36.20230412 [Approved]
nano-win package files install completed. Performing other installation steps.
The package nano-win wants to run 'chocolateyInstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider:
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?([Y]es/[A]ll - yes to all/[N]o/[P]rint): Y

Downloading nano-win 64 bit
  from 'https://github.com/okibcn/nano-for-windows/releases/download/v7.2-22.1/nano-for-windows_win64_v7.2-22.1.zip'    Progress: 100% - Completed download of C:\Users\SkysentryTSMC\AppData\Local\Temp\chocolatey\nano-win\7.2.36.20230412\nano-for-windows_win64_v7.2-22.1.zip (278.97 KB).
Download of nano-for-windows_win64_v7.2-22.1.zip (278.97 KB) completed.
Hashes match.
Extracting C:\Users\SkysentryTSMC\AppData\Local\Temp\chocolatey\nano-win\7.2.36.20230412\nano-for-windows_win64_v7.2-22.1.zip to C:\ProgramData\chocolatey\lib\nano-win\tools...
C:\ProgramData\chocolatey\lib\nano-win\tools
 ShimGen has successfully created a shim for nano.exe
 The install of nano-win was successful.
  Deployed to 'C:\ProgramData\chocolatey\lib\nano-win\tools'
Downloading package from source 'https://community.chocolatey.org/api/v2/'
Progress: Downloading nano 7.2.36.20230412... 100%

nano v7.2.36.20230412 [Approved]
nano package files install completed. Performing other installation steps.
 The install of nano was successful.
  Deployed to 'C:\ProgramData\chocolatey\lib\nano'

Chocolatey installed 2/2 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
這樣在 cmd 裡也可以用 nano。 done。

// TODO 待確認權限問題

留言

這個網誌中的熱門文章

電話線四芯或二芯(4C或2C)的差別

開機自動執行 Google Chrome App on Mac OS X

RPi 作業系統的 ntp service 相關