PowerShell安装scoop和oh-my-posh

一、安装PowerShell

1、Github下载地址

GitHub - PowerShell/PowerShell: PowerShell for every system!

建议下载TLS或者stable版本

2、查看PowerShell版本

输入 $PSVersionTable.PSVersion 命令

PS C:\Program Files\PowerShell\7> $PSVersionTable.PSVersion

Major Minor Patch PreReleaseLabel BuildLabel


7 2 17

二、安装scoop

Windows命令行包管理工具 Scoop,类似linux的yum、apt

1、更改脚本执行策略(必须)

Set-ExecutionPolicy RemoteSigned -scope CurrentUser;

PS C:\Program Files\PowerShell\7> Set-ExecutionPolicy RemoteSigned -scope CurrentUser;

2、设置scoop环境变量

$env:SCOOP='D:\Scoop'

Environment\]::SetEnvironmentVariable('SCOOP',$env:SCOOP,'User') # 全局安装 # $env:SCOOP_GLOBAL='D:\\Scoop' # \[environment\]::setEnvironmentVariable('SCOOP_GLOBAL',$env:SCOOP_GLOBAL,'Machine') > PS C:\\Program Files\\PowerShell\\7\> $env:SCOOP='D:\\Scoop' > > PS C:\\Program Files\\PowerShell\\7\>\[Environment\]::SetEnvironmentVariable('SCOOP',$env:SCOOP,'User') > > PS C:\\Program Files\\PowerShell\\7\> $env:SCOOP_GLOBAL='D:\\Scoop' > > PS C:\\Program Files\\PowerShell\\7\>\[environment\]::setEnvironmentVariable('SCOOP_GLOBAL',$env:SCOOP_GLOBAL,'Machine') ### 3、安装命令scoop iex "\& {$(iwr -useb get.scoop.sh)} -RunAsAdmin" > PS C:\\Users\\Administrator\> iex "\& {$(iwr -useb get.scoop.sh)} -RunAsAdmin" > > Initializing... > > Downloading ... > > fatal: unable to access 'https://github.com/ScoopInstaller/Main.git/': HTTP/2 stream 1 was not closed cleanly before end of the underlying stream > > WARNING: Cloning failed. Falling back to downloading zip files. > > Extracting... > > Creating shim... > > Adding D:\\scoop\\shims to your path. > > Scoop was installed successfully! > > Type 'scoop help' for instructions. ## 三、安装oh-my-posh ### 1、安装oh-my-posh scoop install https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/oh-my-posh.json > PS C:\\Users\\Administrator\> scoop install https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/oh-my-posh.json > Installing 'oh-my-posh' (18.25.1) \[64bit

install-amd64.exe (6.2 MB) [=================================================================] 100%
Checking hash of install-amd64.exe ... ok.
Running installer... done.
Linking D:\scoop\apps\oh-my-posh\current => D:\scoop\apps\oh-my-posh\18.25.1
Running post_install script...
Thanks for installing Oh My Posh.
Have a look at https://ohmyposh.dev for detailed instructions for your shell.
'oh-my-posh' (18.25.1) was installed successfully!

2、安装vim编辑器

PS C:\Users\Administrator> scoop install vim
Installing '7zip' (23.01) [64bit] from main bucket
7z2301-x64.msi (1.8 MB) [==============================] 100%
Checking hash of 7z2301-x64.msi ... ok.
Extracting 7z2301-x64.msi ... done.
Linking D:\scoop\apps\7zip\current => D:\scoop\apps\7zip\23.01
Creating shim for '7z'.
Creating shim for '7zFM'.
Creating shim for '7zG'.
Creating shortcut for 7-Zip (7zFM.exe)
Persisting Codecs
Persisting Formats
Running post_install script...
'7zip' (23.01) was installed successfully!
Notes

Add 7-Zip as a context menu option by running: "D:\scoop\apps\7zip\current\install-context.reg"
Installing 'vim' (9.0) [64bit] from main bucket
gvim90.exe (9.7 MB) [=================================================================] 100%
Checking hash of gvim90.exe ... ok.
Extracting dl.7z ... done.
Running pre_install script..
Linking D:\scoop\apps\vim\current => D:\scoop\apps\vim\9.0
Creating shim for 'vim'.
Creating shim for 'vi'.
Creating shim for 'ex'.
Creating shim for 'view'.
Creating shim for 'rvim'.
Creating shim for 'rview'.
Creating shim for 'vimdiff'.
Creating shim for 'gvim'.
Creating shim for 'gview'.
Creating shim for 'evim'.
Creating shim for 'eview'.
Creating shim for 'rgvim'.
Creating shim for 'rgview'.
Creating shim for 'gvimdiff'.
Creating shim for 'xxd'.
Creating shortcut for gVim (gvim.exe)
Running post_install script...
'vim' (9.0) was installed successfully!
Notes

Add gVim as a context menu option by running: "D:\scoop\apps\vim\current\install-context.reg"
'vim' suggests installing 'vimtutor'.

3、选择oh-my-posh主题

https://ohmyposh.dev/docs/themes下载对应的主题json文件

4、为powershell添加oh-my-posh使用:

vim $PROFILE

oh-my-posh init pwsh --config "C:\Users\Administrator\Documents\PowerShell\probua.minimal.omp.json" | Invoke-Expression

更换主题修改$PROFILE中对应的json主题文件即可

5、其他

添加国内镜像

scoop config SCOOP_REPO https://gitee.com/scoop-bucket/scoop

切回官方镜像

scoop config SCOOP_REPO https://github.com/ScoopInstaller/Scoop

查看有哪些repo

scoop bucket known

添加bucklet

scoop bucket rm main

scoop bucket add main

scoop bucket add main https://mirror.nju.edu.cn/git/scoop-main.git
scoop bucket add extras https://mirror.nju.edu.cn/git/scoop-extras.git
scoop bucket add dorado https://gitee.com/scoop-bucket/dorado.git

更新-每次添加完仓库记得更新

scoop update

相关推荐
海天胜景9 小时前
编译器错误消息: CS0016: 未能写入输出文件“c:\Windows\Microsoft.NET... 拒绝访问
c语言·windows
搏博18 小时前
基于Python3.10.6与jieba库的中文分词模型接口在Windows Server 2022上的实现与部署教程
windows·python·自然语言处理·flask·中文分词
有梦想的攻城狮1 天前
Java 11中的Collections类详解
java·windows·python·java11·collections
忒可君1 天前
C# winform FTP功能
开发语言·windows·c#
十五年专注C++开发1 天前
CMake进阶: CMake Modules---简化CMake配置的利器
linux·c++·windows·cmake·自动化构建
degree5201 天前
全平台轻量浏览器推荐|支持Win/macOS/Linux,极速加载+隐私保护+扩展插件,告别广告与数据追踪!
windows·macos·电脑
许泽宇的技术分享2 天前
Windows桌面自动化的革命性突破:深度解析Windows-MCP.Net Desktop模块的技术奥秘
windows·自动化·.net
七仔的博客2 天前
【摸鱼办公神器】七仔的桌面工具超进化 -> 灵卡面板 v1.1.9
windows·神器·摸鱼
码农阿豪2 天前
Windows从零到一安装KingbaseES数据库及使用ksql工具连接全指南
数据库·windows
CC__xy3 天前
demo 通讯录 + 城市选择器 (字母索引左右联动 ListItemGroup+AlphabetIndexer)笔记
windows