GIT美化及增强(oh-my-posh)

安装windows terminal,打开windows store安装

GIT美化及增强(oh-my-posh)

windows terminal

安装powershell7

下载地址 :https://github.com/PowerShell/PowerShell/releases

安装oh-my-posh

winget install JanDeDobbeleer.OhMyPosh -s winget
GIT美化及增强(oh-my-posh)

oh-my-posh install

  • 此时关闭windows terminal ,查看环境变量
  • 安装完成后会自动添加环境变量
GIT美化及增强(oh-my-posh)

环境变量

安装字体,否则会出现图标乱码情况 ,必须管理员权限安装,否则会提示安装失败

安装字体

oh-my-posh font install

Oh My Posh was designed to use Nerd Fonts. Nerd Fonts are popular fonts that are patched to include icons. We recommend Meslo LGM NF, but any Nerd Font should be compatible with the standard themes.

根据文档提示:选择Meslo字体安装

设置字体

GIT美化及增强(oh-my-posh)

windows terminal设置字体

将powershell7设置为默认window terminal启动项


GIT美化及增强(oh-my-posh)

启动项设置

设置powershell7默认启动主题

输入:notepad $profile

如果出现以下提示:

GIT美化及增强(oh-my-posh)

路径不存在

echo $profile

根据提示路径,创建同名文件

C:\Users\42159\Documents\PowerShell\Microsoft.PowerShell_profile.ps1

GIT美化及增强(oh-my-posh)

Microsoft.PowerShell_profile.ps1

再次编辑 notepad $profile

将下面代码贴入Microsoft.PowerShell_profile.ps1文件

oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\aliens.omp.json" | Invoke-Expression

重新启动windows terminal,设置自己喜欢的主题

通过下面命令获取所有主题,选择自己喜欢的主题,notepad $profile

Get-PoshThemes


GIT美化及增强(oh-my-posh)

more theme

设置git alias,提高开发效率

notepad $profile

oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\aliens.omp.json" | Invoke-Expression

function Get-GitStatus { & git status  $args }
New-Alias -Name gs -Value Get-GitStatus -Force -Option AllScope
function Get-GitCommit { & git commit -m $args }
New-Alias -Name gcm -Value Get-GitCommit -Force -Option AllScope
function Get-GitAdd { & git add . $args }
New-Alias -Name ga -Value Get-GitAdd -Force -Option AllScope
function Get-GitTree { & git log --graph --decorate $args }
New-Alias -Name gt -Value Get-GitTree -Force -Option AllScope
function Get-GitPush { & git push $args }
New-Alias -Name gp -Value Get-GitPush -Force -Option AllScope
function Get-GitPull { & git pull $args }
New-Alias -Name gl -Value Get-GitPull -Force -Option AllScope
function Get-GitCheckout { & git checkout $args }
New-Alias -Name gc -Value Get-GitCheckout -Force -Option AllScope
function Get-GitBranch { & git branch $args }
New-Alias -Name gb -Value Get-GitBranch -Force -Option AllScope
function Get-GitRemote { & git remote -v $args }
New-Alias -Name gr -Value Get-GitRemote -Force -Option AllScope

初始化一个git项目,看看效果吧,git init

GIT美化及增强(oh-my-posh)

git alias

参考文档

https://docs.microsoft.com/zh-cn/windows/terminal/tutorials/custom-prompt-setup

https://ohmyposh.dev/docs/installation/windows

GIT   oh
发表评论
留言与评论(共有 0 条评论) “”
   
验证码:

相关文章

推荐文章