
Windows11 cmd/Powershell/vscode终端美化
如果打开是这种终端则进行更改设置再次打开cmd终端修改终端背景找到defaults设置背景图路径和透明度重新打开cmd终端。
更改终端样式
如果打开是这种终端
则进行更改设置
再次打开cmd终端
修改终端背景
找到defaults
设置背景图路径和透明度
{
"backgroundImage": "D:\\image\\liuyifei.jpg", //图片路径
"backgroundImageOpacity": 0.5, //透明度50%
},
重新打开cmd终端
安装oh-my-posh
下载地址:Releases · JanDeDobbeleer/oh-my-posh · GitHub
安装完后重新打开终端
输入oh-my-posh,如果出现不是内部命令则没安装成功
安装Clink实现智能补全代码
下载链接:Overview | Clink (chrisant996.github.io)
安装成功后重新打开终端
clink中配置oh-my-posh
通过bat脚本获取oh-my-posh下的主题名字
@echo off
setlocal enabledelayedexpansion
:: 设置目录路径
set "themeDir=D:\oh-my-posh\oh-my-posh\themes\"
:: 使用dir命令查找所有.json文件并打印它们的路径
for /f "delims=" %%a in ('dir /b /s /a-d "%themeDir%*.json"') do (
echo Found: %%a
)
endlocal
pause
将内容复制并替换调整一下
找到这个目录,在这个目录下创建一个lua脚本oh-my-posh.lua
每次打开终端随机主题
local array1 = {"1_shell","agnoster.minimal","agnoster","agnosterplus","aliens","amro","atomic","atomicBit","avit","blue-owl","blueish","bubbles","bubblesextra","bubblesline","capr4n","catppuccin","catppuccin_frappe","catppuccin_latte","catppuccin_macchiato","catppuccin_mocha","cert","chips","cinnamon","clean-detailed","cloud-context","cloud-native-azure","cobalt2","craver","darkblood","di4am0nd","dracula","easy-term","emodipt-extend","emodipt","fish","free-ukraine","froczh","gmay","grandpa-style","gruvbox","half-life","honukai","hotstick.minimal","hul10","hunk","huvix","if_tea","illusi0n","iterm2","jandedobbeleer","jblab_2021","jonnychipz","json","jtracey93","jv_sitecorian","kali","kushal","lambda","lambdageneration","larserikfinholt","lightgreen","M365Princess","marcduiker","markbull","material","microverse-power","mojada","montys","mt","multiverse-neon","negligible","neko","night-owl","nordtron","nu4a","onehalf.minimal","paradox","pararussel","patriksvensson","peru","pixelrobots","plague","poshmon","powerlevel10k_classic","powerlevel10k_lean","powerlevel10k_modern","powerlevel10k_rainbow","powerline","probua.minimal","pure","quick-term","remk","robbyrussell","rudolfs-dark","rudolfs-light","schema.json","sim-web","slim","slimfat","smoothie","sonicboom_dark","sonicboom_light","sorin","space","spaceship","star","stelbent-compact.minimal","stelbent.minimal","takuya","the-unnamed","thecyberden","tiwahu","tokyo","tokyonight_storm","tonybaloney","uew","unicorn","velvet","wholespace","wopian","xtoys","ys","zash"}
math.randomseed(os.time())
local num = math.floor(math.random(1,124))
load(io.popen('oh-my-posh prompt init cmd --config D:/oh-my-posh/oh-my-posh/themes/'..array1[num]..'.omp.json'):read("*a"))()
--以上脚本是极客-root老师提供的,每次打开随机切换主题脚本,如果要指定主题用以下脚本内容并注释上方内容
--[[
这是多行注释
--]]
--[[
load(io.popen('oh-my-posh init cmd --config D:/oh-my-posh/oh-my-posh/themes/wholespace.omp.json'):read("*a"))()
]]--
再次重新打开终端出现乱码吗
安装字体解决乱码
下载nerd字体
Nerd Fonts - Iconic font aggregator, glyphs/icons collection, & fonts patcher
找一款自己喜欢的download
将tty文件解压出来复制到 C:\Windows\Fonts下
重新打开cmd终端
修改powrshell终端
输入 notepad $PROFILE
如果没有这个文件存在,就先用下边的命令创建默认的配置文件出来
New-Item –Path $Profile –Type File –Force
再次执行notepad $PROFILE
编辑脚本实现每次打开终端随机主题
$theme=Get-Random("1_shell","agnoster.minimal","agnoster","agnosterplus","aliens","amro","atomic","atomicBit","avit","blue-owl","blueish","bubbles","bubblesextra","bubblesline","capr4n","catppuccin","catppuccin_frappe","catppuccin_latte","catppuccin_macchiato","catppuccin_mocha","cert","chips","cinnamon","clean-detailed","cloud-context","cloud-native-azure","cobalt2","craver","darkblood","di4am0nd","dracula","easy-term","emodipt-extend","emodipt","fish","free-ukraine","froczh","gmay","grandpa-style","gruvbox","half-life","honukai","hotstick.minimal","hul10","hunk","huvix","if_tea","illusi0n","iterm2","jandedobbeleer","jblab_2021","jonnychipz","json","jtracey93","jv_sitecorian","kali","kushal","lambda","lambdageneration","larserikfinholt","lightgreen","M365Princess","marcduiker","markbull","material","microverse-power","mojada","montys","mt","multiverse-neon","negligible","neko","night-owl","nordtron","nu4a","onehalf.minimal","paradox","pararussel","patriksvensson","peru","pixelrobots","plague","poshmon","powerlevel10k_classic","powerlevel10k_lean","powerlevel10k_modern","powerlevel10k_rainbow","powerline","probua.minimal","pure","quick-term","remk","robbyrussell","rudolfs-dark","rudolfs-light","schema.json","sim-web","slim","slimfat","smoothie","sonicboom_dark","sonicboom_light","sorin","space","spaceship","star","stelbent-compact.minimal","stelbent.minimal","takuya","the-unnamed","thecyberden","tiwahu","tokyo","tokyonight_storm","tonybaloney","uew","unicorn","velvet","wholespace","wopian","xtoys","ys","zash")
oh-my-posh init pwsh --config $env:POSH_THEMES_PATH\$theme.omp.json | Invoke-Expression
#脚本来自极客-root老师
重新打开powershell终端
首次加载txt里面的脚本不被允许,这里需要用管理员权限释放一次,之后就不用了
set-ExecutionPolicy RemoteSigned
重新打开
出现乱码,重复之前修改字体即可
修改vs code终端
设置cmd终端为默认
更改字体
搜索Font Famil 》终端 》设置monospace
更多推荐
所有评论(0)