mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 04:19:41 -08:00
feat: add themes to scoop
This commit is contained in:
parent
eea21ac005
commit
0f30953212
6
.github/workflows/release.yml
vendored
6
.github/workflows/release.yml
vendored
|
@ -123,7 +123,7 @@ jobs:
|
|||
run: |
|
||||
$fileHash = Get-FileHash themes.zip -Algorithm SHA256
|
||||
$fileHash.Hash | Out-File -Encoding 'UTF8' themes.zip.sha256
|
||||
Write-Output "::set-output name=hash_${{ matrix.os }}::$($fileHash.Hash)"
|
||||
Write-Output "::set-output name=hash_themes::$($fileHash.Hash)"
|
||||
- name: Upload Themes
|
||||
id: upload-themes
|
||||
uses: actions/upload-release-asset@v1
|
||||
|
@ -160,7 +160,7 @@ jobs:
|
|||
- name: Pack and push
|
||||
run: ./deploy.ps1 -BinVersion ${{ needs.release.outputs.version }} -ModuleVersion ${{ needs.release.outputs.version }} -Repository PSGallery -RepositoryAPIKey $env:PSGALLERY_KEY
|
||||
scoop:
|
||||
needs: [release, artifacts]
|
||||
needs: [release, artifacts, themes]
|
||||
if: ${{ needs.release.outputs.skipped == 'false' }}
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
|
@ -171,7 +171,7 @@ jobs:
|
|||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: Update Template
|
||||
run: ./build.ps1 -Version ${{ needs.release.outputs.version }} -LinuxSHA ${{ needs.artifacts.outputs.hash_linux }} -WindowsSHA ${{ needs.artifacts.outputs.hash_windows }}
|
||||
run: ./build.ps1 -Version ${{ needs.release.outputs.version }} -LinuxSHA ${{ needs.artifacts.outputs.hash_linux }} -WindowsSHA ${{ needs.artifacts.outputs.hash_windows }} -ThemesSHA ${{ needs.themes.outputs.hash_themes }}
|
||||
- name: Upload Scoop JSON
|
||||
id: upload-scoop-json
|
||||
uses: actions/upload-release-asset@v1
|
||||
|
|
|
@ -8,7 +8,10 @@ Param
|
|||
$LinuxSHA,
|
||||
[parameter(Mandatory = $true)]
|
||||
[string]
|
||||
$WindowsSHA
|
||||
$WindowsSHA,
|
||||
[parameter(Mandatory = $true)]
|
||||
[string]
|
||||
$ThemesSHA
|
||||
)
|
||||
|
||||
$content = Get-Content '.\oh-my-posh.json' -Raw
|
||||
|
@ -17,4 +20,5 @@ $content = $content.Replace('<HASH_LINUX>', $LinuxSHA)
|
|||
$content = $content.Replace('<HASH_WINDOWS>', $WindowsSHA)
|
||||
$fileHash = Get-FileHash post-install.ps1 -Algorithm SHA256
|
||||
$content = $content.Replace('<HASH_INSTALL_SCRIPT>', $fileHash.Hash)
|
||||
$content = $content.Replace('<HASH_THEMES>', $ThemesSHA)
|
||||
$content | Out-File -Encoding 'UTF8' '.\oh-my-posh.json'
|
||||
|
|
|
@ -9,13 +9,15 @@
|
|||
"url": [
|
||||
"https://github.com/JanDeDobbeleer/oh-my-posh3/releases/download/v<VERSION>/posh-linux-amd64",
|
||||
"https://github.com/JanDeDobbeleer/oh-my-posh3/releases/download/v<VERSION>/posh-windows-amd64.exe",
|
||||
"https://github.com/JanDeDobbeleer/oh-my-posh3/releases/download/v<VERSION>/post-install.ps1"
|
||||
"https://github.com/JanDeDobbeleer/oh-my-posh3/releases/download/v<VERSION>/post-install.ps1",
|
||||
"https://github.com/JanDeDobbeleer/oh-my-posh3/releases/download/v<VERSION>/themes.zip"
|
||||
],
|
||||
"hash": [
|
||||
"<HASH_LINUX>",
|
||||
"<HASH_WINDOWS>",
|
||||
"<HASH_INSTALL_SCRIPT>"
|
||||
"<HASH_INSTALL_SCRIPT>",
|
||||
"<HASH_THEMES>"
|
||||
],
|
||||
"bin": ["posh-linux-amd64", "posh-windows-amd64.exe"],
|
||||
"post_install": "& \"$dir/post-install.ps1\""
|
||||
"extract_to": "themes",
|
||||
"bin": ["posh-linux-amd64", "posh-windows-amd64.exe"]
|
||||
}
|
||||
|
|
|
@ -1,79 +1,4 @@
|
|||
if (!(Test-Path $PROFILE)) {
|
||||
$profileDir = Split-Path $PROFILE
|
||||
if (!(Test-Path $profileDir)) {
|
||||
New-Item -Path $profileDir -ItemType Directory | Out-Null
|
||||
}
|
||||
'' > $PROFILE
|
||||
}
|
||||
|
||||
function Write-ExitIfNeeded {
|
||||
param (
|
||||
[parameter(Mandatory = $true)]
|
||||
[int]
|
||||
$Decision
|
||||
)
|
||||
if ($Decision -ne 0) {
|
||||
Write-Host 'Thanks for installing Oh my Posh.'
|
||||
Write-Host 'Have a look at https://ohmyposh.dev/docs/installation for instructions.'
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
|
||||
function Set-Prompt {
|
||||
param (
|
||||
[parameter(Mandatory = $true)]
|
||||
[string]
|
||||
$ProfilePath
|
||||
)
|
||||
|
||||
$promptOverride = @'
|
||||
function Get-PoshCommand {
|
||||
$poshCommand = "posh-windows-amd64.exe"
|
||||
if ($IsLinux) {
|
||||
$poshCommand = "posh-linux-amd64"
|
||||
}
|
||||
return $poshCommand
|
||||
}
|
||||
|
||||
[ScriptBlock]$Prompt = {
|
||||
$realLASTEXITCODE = $global:LASTEXITCODE
|
||||
if ($realLASTEXITCODE -isnot [int]) {
|
||||
$realLASTEXITCODE = 0
|
||||
}
|
||||
$startInfo = New-Object System.Diagnostics.ProcessStartInfo
|
||||
$startInfo.FileName = Get-PoshCommand
|
||||
$startInfo.Arguments = "-pwd ""$PWD"" -error $realLASTEXITCODE"
|
||||
$startInfo.Environment["TERM"] = "xterm-256color"
|
||||
$startInfo.CreateNoWindow = $true
|
||||
$startInfo.StandardOutputEncoding = [System.Text.Encoding]::UTF8
|
||||
$startInfo.RedirectStandardOutput = $true
|
||||
$startInfo.UseShellExecute = $false
|
||||
if ($PWD.Provider.Name -eq "FileSystem") {
|
||||
$startInfo.WorkingDirectory = "$PWD"
|
||||
}
|
||||
$process = New-Object System.Diagnostics.Process
|
||||
$process.StartInfo = $startInfo
|
||||
Set-PoshContext
|
||||
$process.Start() | Out-Null
|
||||
$standardOut = $process.StandardOutput.ReadToEnd()
|
||||
$process.WaitForExit()
|
||||
$standardOut
|
||||
$global:LASTEXITCODE = $realLASTEXITCODE
|
||||
Remove-Variable realLASTEXITCODE -Confirm:$false
|
||||
}
|
||||
Set-Item -Path Function:prompt -Value $Prompt -Force
|
||||
'@
|
||||
Add-Content -Path $ProfilePath -Value $promptOverride
|
||||
Write-Host 'Thanks for installing Oh my Posh.'
|
||||
Write-Host 'Have a look at the configuration posibilities at https://ohmyposh.dev'
|
||||
}
|
||||
|
||||
if (-not (Test-Path $PROFILE)) {
|
||||
Write-Host "The Powershell profile can't be found, have a look at https://ohmyposh.dev/docs/installation for instructions"
|
||||
exit 0
|
||||
}
|
||||
|
||||
$title = @'
|
||||
$logo = @'
|
||||
__ _____ _ ___ ___ ______ _ __
|
||||
/ / | _ | | | \/ | | ___ \ | | \ \
|
||||
/ / | | | | |__ | . . |_ _ | |_/ /__ ___| |__ \ \
|
||||
|
@ -83,25 +8,7 @@ $title = @'
|
|||
__/ |
|
||||
|___/
|
||||
'@
|
||||
$choices = '&Yes', '&No'
|
||||
$question = "Do you want to add Oh my Posh to $PROFILE ?"
|
||||
$decision = $Host.UI.PromptForChoice($title, $question, $choices, 1)
|
||||
Write-ExitIfNeeded -Decision $decision
|
||||
if (!(Get-Content $PROFILE)) {
|
||||
Set-Prompt -ProfilePath $PROFILE
|
||||
exit 0
|
||||
}
|
||||
$profileContent = (Get-Content $PROFILE).ToLower()
|
||||
if ($profileContent -match 'function:prompt' -or $profileContent -match 'function prompt') {
|
||||
$title = "$ProfilePath already contains a prompt function override."
|
||||
$question = "Do you want to override it with Oh my Posh?"
|
||||
$decision = $Host.UI.PromptForChoice($title, $question, $choices, 1)
|
||||
Write-ExitIfNeeded -Decision $decision
|
||||
}
|
||||
elseif ($profileContent -match 'oh-my-posh') {
|
||||
$title = "$ProfilePath already contains an Oh my Posh import statement."
|
||||
$question = "Do you want to override it?"
|
||||
$decision = $Host.UI.PromptForChoice($title, $question, $choices, 1)
|
||||
Write-ExitIfNeeded -Decision $decision
|
||||
}
|
||||
Set-Prompt -ProfilePath $PROFILE
|
||||
Write-Host $logo
|
||||
Write-Host ''
|
||||
Write-Host 'Thanks for installing Oh my Posh.'
|
||||
Write-Host 'Have a look at https://ohmyposh.dev/docs/installation for detailed instructions for your shell.'
|
||||
|
|
Loading…
Reference in a new issue