1. 安装gsudo
可以直接在 powershell 中执行以下命令进行安装:
winget install gerardog.gsudo
winget install gerardog.gsudo
设置别名
Set-Alias 'sudo' 'gsudo'
Set-Alias 'sudo' 'gsudo'
如:以管理员身份运行
sudo powershell.exe
sudo powershell.exe
2. 升级powershell
bash
winget install --id Microsoft.Powershell --source winget
winget install --id Microsoft.Powershell --source winget
3. 安装 oh-my-posh
在powershell下执行
bash
winget install JanDeDobbeleer.OhMyPosh
#安装图标
Install-Module -Name Terminal-Icons -Repository PSGallery
winget install JanDeDobbeleer.OhMyPosh
#安装图标
Install-Module -Name Terminal-Icons -Repository PSGallery
4. 配置
- powershell
bash
# 安装oh-my-posh
winget install JanDeDobbeleer.OhMyPosh -s winget
# 使用的是哪个 shell
oh-my-posh get shell
# 直接加载:
& ([ScriptBlock]::Create((oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json" --print) -join "`n"))
# 编辑PowerShell 配置文件脚本,每次启动之后自动加载
notepad $PROFILE
# 当上述命令出错时,请确保先创建配置文件
New-Item -Path $PROFILE -Type File -Force
# 在配置文件里添加以下行:
& ([ScriptBlock]::Create((oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json" --print) -join "`n"))
或者添加这行:
oh-my-posh init pwsh --config '$env:POSH_THEMES_PATH\jandedobbeleer.omp.json' | Invoke-Expression
# 重新加载配置文件以使更改生效
. $PROFILE
# 查看所有themes:
Get-PoshThemes
#运行上面命令后,最后3行显示如下:
# ---theme存放的位置:
Themes location: C:\Users\admin\AppData\Local\Programs\oh-my-posh\themes
# --- 如果输入$profile, 得出的路径跟以下是一致的:
To change your theme, adjust the init script in C:\Users\admin\Documents\PowerShell\Microsoft.PowerShell_profile.ps1.
# --- 之前$profile配置文件,也可以改成以下这句(之前这句,向防病毒软件添加例外)
Example:
oh-my-posh init pwsh --config 'C:\Users\admin\AppData\Local\Programs\oh-my-posh\themes\jandedobbeleer.omp.json' | Invoke-Expression
# 安装文件图标库
Install-Module -Name Terminal-Icons -Repository PSGallery
#使用图标,可以把以下这条命令加到$PROFILE里(保存,.$profile使生效),单独运行就是一次性:
Import-Module -Name Terminal-Icons
#BONUS:
# 设置随机主题:
# 在powershell输入code $profile,输入下面的脚本命令:
$theme = Get-ChildItem $env:UserProfile\\AppData\\Local\\Programs\\oh-my-posh\\themes\\ | Get-Random
echo "hello! today's lucky theme is: $theme :)"
oh-my-posh --init --shell pwsh --config $theme.FullName | Invoke-Expression
# 安装oh-my-posh
winget install JanDeDobbeleer.OhMyPosh -s winget
# 使用的是哪个 shell
oh-my-posh get shell
# 直接加载:
& ([ScriptBlock]::Create((oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json" --print) -join "`n"))
# 编辑PowerShell 配置文件脚本,每次启动之后自动加载
notepad $PROFILE
# 当上述命令出错时,请确保先创建配置文件
New-Item -Path $PROFILE -Type File -Force
# 在配置文件里添加以下行:
& ([ScriptBlock]::Create((oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json" --print) -join "`n"))
或者添加这行:
oh-my-posh init pwsh --config '$env:POSH_THEMES_PATH\jandedobbeleer.omp.json' | Invoke-Expression
# 重新加载配置文件以使更改生效
. $PROFILE
# 查看所有themes:
Get-PoshThemes
#运行上面命令后,最后3行显示如下:
# ---theme存放的位置:
Themes location: C:\Users\admin\AppData\Local\Programs\oh-my-posh\themes
# --- 如果输入$profile, 得出的路径跟以下是一致的:
To change your theme, adjust the init script in C:\Users\admin\Documents\PowerShell\Microsoft.PowerShell_profile.ps1.
# --- 之前$profile配置文件,也可以改成以下这句(之前这句,向防病毒软件添加例外)
Example:
oh-my-posh init pwsh --config 'C:\Users\admin\AppData\Local\Programs\oh-my-posh\themes\jandedobbeleer.omp.json' | Invoke-Expression
# 安装文件图标库
Install-Module -Name Terminal-Icons -Repository PSGallery
#使用图标,可以把以下这条命令加到$PROFILE里(保存,.$profile使生效),单独运行就是一次性:
Import-Module -Name Terminal-Icons
#BONUS:
# 设置随机主题:
# 在powershell输入code $profile,输入下面的脚本命令:
$theme = Get-ChildItem $env:UserProfile\\AppData\\Local\\Programs\\oh-my-posh\\themes\\ | Get-Random
echo "hello! today's lucky theme is: $theme :)"
oh-my-posh --init --shell pwsh --config $theme.FullName | Invoke-Expression
bash
cat .bashrc
#eval "$(starship init bash)"
eval "$(oh-my-posh --init --shell bash --config ~/illusi0n.omp.json)"
cat .bashrc
#eval "$(starship init bash)"
eval "$(oh-my-posh --init --shell bash --config ~/illusi0n.omp.json)"
图标乱码,安装字体
https://ohmyposh.dev/docs/installation/fonts
5. WinGet 换国内源
winget不能用的时候切换
bash
winget source remove winget
winget source add winget https://mirrors.ustc.edu.cn/winget-source
winget source remove winget
winget source add winget https://mirrors.ustc.edu.cn/winget-source
- 重置为官方
winget source reset winget
winget source reset winget
6.win11-ISO
https://www.microsoft.com/zh-cn/software-download/windows11
密钥
bash
slmgr -ipk xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
slmgr -skms kms.03k.org
slmgr -ato
slmgr -xpr
slmgr -ipk xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
slmgr -skms kms.03k.org
slmgr -ato
slmgr -xpr
7. win11优化
7.1 资源管理器变成win10
touch 1.reg ,保存字体格式为utf-8
bash
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\CLSID\{2aa9162e-c906-4dd9-ad0b-3d24a8eef5a0}]
@="CLSID_ItemsViewAdapter"
[HKEY_CURRENT_USER\Software\Classes\CLSID\{2aa9162e-c906-4dd9-ad0b-3d24a8eef5a0}\InProcServer32]
@="C:\\Windows\\System32\\Windows.UI.FileExplorer.dll_"
"ThreadingModel"="Apartment"
[HKEY_CURRENT_USER\Software\Classes\CLSID\{6480100b-5a83-4d1e-9f69-8ae5a88e9a33}]
@="File Explorer Xaml Island View Adapter"
[HKEY_CURRENT_USER\Software\Classes\CLSID\{6480100b-5a83-4d1e-9f69-8ae5a88e9a33}\InProcServer32]
@="C:\\Windows\\System32\\Windows.UI.FileExplorer.dll_"
"ThreadingModel"="Apartment"
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Toolbar\ShellBrowser]
"ITBar7Layout"=hex:13,00,00,00,00,00,00,00,00,00,00,00,20,00,00,00,10,00,01,00,\
00,00,00,00,01,00,00,00,01,07,00,00,5e,01,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\CLSID\{2aa9162e-c906-4dd9-ad0b-3d24a8eef5a0}]
@="CLSID_ItemsViewAdapter"
[HKEY_CURRENT_USER\Software\Classes\CLSID\{2aa9162e-c906-4dd9-ad0b-3d24a8eef5a0}\InProcServer32]
@="C:\\Windows\\System32\\Windows.UI.FileExplorer.dll_"
"ThreadingModel"="Apartment"
[HKEY_CURRENT_USER\Software\Classes\CLSID\{6480100b-5a83-4d1e-9f69-8ae5a88e9a33}]
@="File Explorer Xaml Island View Adapter"
[HKEY_CURRENT_USER\Software\Classes\CLSID\{6480100b-5a83-4d1e-9f69-8ae5a88e9a33}\InProcServer32]
@="C:\\Windows\\System32\\Windows.UI.FileExplorer.dll_"
"ThreadingModel"="Apartment"
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Toolbar\ShellBrowser]
"ITBar7Layout"=hex:13,00,00,00,00,00,00,00,00,00,00,00,20,00,00,00,10,00,01,00,\
00,00,00,00,01,00,00,00,01,07,00,00,5e,01,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
- 关闭
bash
Windows Registry Editor Version 5.00
[-HKEY_CURRENT_USER\Software\Classes\CLSID\{2aa9162e-c906-4dd9-ad0b-3d24a8eef5a0}]
[-HKEY_CURRENT_USER\Software\Classes\CLSID\{6480100b-5a83-4d1e-9f69-8ae5a88e9a33}]
Windows Registry Editor Version 5.00
[-HKEY_CURRENT_USER\Software\Classes\CLSID\{2aa9162e-c906-4dd9-ad0b-3d24a8eef5a0}]
[-HKEY_CURRENT_USER\Software\Classes\CLSID\{6480100b-5a83-4d1e-9f69-8ae5a88e9a33}]