Skip to content

Commit

Permalink
Final changes for 1.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
codyduong committed Jun 8, 2024
1 parent 25bd1b0 commit 00700bb
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 49 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/windows-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ jobs:
uses: microsoft/psscriptanalyzer-action@v1.0
with:
path: .\
recurse: true
recurse: true
excludeRule: '"AvoidUsingWriteHost"'
output: results.sarif
- name: Upload SARIF results file
uses: github/codeql-action/upload-sarif@v2
Expand Down
2 changes: 1 addition & 1 deletion windows/.files/%LOCALAPPDATA%/nvim
Submodule nvim updated 1 files
+3 −0 init.lua
39 changes: 39 additions & 0 deletions windows/.files/%USERPROFILE%/.gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[include]
path = ~/.gitconfig_private

[filter "lfs"]
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
clean = git-lfs clean -- %f

[core]
autocrlf = false
eol = lf
pager = delta

[interactive]
diffFilter = delta --color-only

[delta]
navigate = true
dark = true

[merge]
conflictstyle = diff3

[diff]
colorMoved = default

[user]
name = Cody Duong
email = duongcody507@gmail.com

[credential]
helper = C:/Users/duong/AppData/Local/Programs/Git\\ Credential\\ Manager/git-credential-manager.exe

[credential "https://dev.azure.com"]
useHttpPath = true

[credential "github.com"]
useHttpPath = true
12 changes: 12 additions & 0 deletions windows/aliases/yazi.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# https://yazi-rs.github.io/docs/quick-start
function yy
{
$tmp = [System.IO.Path]::GetTempFileName()
yazi $args --cwd-file="$tmp"
$cwd = Get-Content -Path $tmp
if (-not [String]::IsNullOrEmpty($cwd) -and $cwd -ne $PWD.Path)
{
Set-Location -Path $cwd
}
Remove-Item -Path $tmp
}
5 changes: 3 additions & 2 deletions windows/exports.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ $script:mingwPath = "C:\msys64\ucrt64\bin"
Update-EnvPathIfNot (Join-Path -Path $Env:USERPROFILE -ChildPath '.pyenv\pyenv-win\bin')
Update-EnvPathIfNot (Join-Path -Path $Env:USERPROFILE -ChildPath '.pyenv\pyenv-win\shims')
Update-EnvPathIfNot (Join-Path -Path $env:APPDATA -ChildPath 'Python\Scripts')
# Update-EnvPathIfNot "C:\pkg-config-lite-0.28-1\bin"
Update-EnvPathIfNot $msys2Path
Update-EnvPathIfNot $mingwPath
Update-EnvPathIfNot (Join-Path $env:LOCALAPPDATA "Programs\ILSpy")
Update-EnvPathIfNot (Join-Path ([System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::ProgramFiles)) "PowerShell\7")
Update-EnvPathIfNot (Join-Path $env:LOCALAPPDATA "Programs\oh-my-posh\bin")
Update-EnvPathIfNot (Join-Path $env:ProgramFiles "\Neovim\bin")
Update-EnvPathIfNot "C:\Qt\6.6.1\msvc2019_64\bin"
# Update-EnvPathIfNot "C:\Qt\6.6.1\msvc2019_64\bin"
# https://stackoverflow.com/a/57403956/17954209
Update-EnvPathIfNot "C:\Qt\6.6.1\msvc2019_64\include"
# Update-EnvPathIfNot "C:\Qt\6.6.1\msvc2019_64\include"
Update-EnvPathIfNot "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Scoop Apps"
128 changes: 83 additions & 45 deletions windows/scripts/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ param (
. $PSScriptRoot\utils.ps1
. $PSScriptRoot\..\functions.ps1

if ($update.IsPresent) {
if ($update.IsPresent)
{
$Env:UPDATE_OUTDATED_DEPS = $update
}
else {
} else
{
InstallerPromptUpdateOutdated
}

Expand Down Expand Up @@ -42,16 +43,21 @@ Install-Winget junegunn.fzf
Install-Winget gerardog.gsudo
Install-Winget ajeetdsouza.zoxide
Install-Winget sharkdp.bat
Install-Winget dandavison.delta
# scoop install yazi
# scoop install unar jq poppler

### Install oh-my-posh and dependencies
Install-Winget JanDeDobbeleer.OhMyPosh
Install-PowerShell -Name Terminal-Icons -Repository PSGallery -Force
if ($true) {
if ($true)
{
$script:TerminalIconsForkPath = (Join-Path $env:USERPROFILE "Terminal-Icons")
$script:TerminalIconsCloned = $false

# Clone a fork of Terminal-Icons
if (-not (Test-Path -Path $TerminalIconsForkPath -PathType Container)) {
if (-not (Test-Path -Path $TerminalIconsForkPath -PathType Container))
{
Write-Host "Cloning Terminal-Icons (fork) v$TerminalIconsVersion..." -ForegroundColor $InstallationIndicatorColorInstalling
git clone https://github.com/codyduong/Terminal-Icons.git "$TerminalIconsForkPath"
$script:TerminalIconsCloned = $true
Expand All @@ -60,77 +66,88 @@ if ($true) {
# Pull if possible
$script:gpOut = git -C "$TerminalIconsForkPath" pull

if ($gpOut -notlike '*Already up to date.*') {
if ($gpOut -notlike '*Already up to date.*')
{
Write-Host "Pulling Terminal-Icons (fork)..." -ForegroundColor $InstallationIndicatorColorUpdating
}
else {
} else
{
Write-Host "Terminal-Icons (fork) up to date." -ForegroundColor $InstallationIndicatorColorFound
}

# Install actual deps
$script:manifestData = Import-PowerShellDataFile -Path (Join-Path $TerminalIconsForkPath "Terminal-Icons/Terminal-Icons.psd1")

foreach ($script:moduleName in $manifestData.RequiredModules) {
foreach ($script:moduleName in $manifestData.RequiredModules)
{
Install-PowerShell -Name $moduleName -Force -RequiredVersion $moduleVersion
}

# Install build deps
$script:manifestData2 = Import-PowerShellDataFile -Path (Join-Path $TerminalIconsForkPath "requirements.psd1")

# Remove similiar deps
foreach ($script:actDep in $manifestData.Keys) {
if ($manifestData2.ContainsKey($actDep)) {
foreach ($script:actDep in $manifestData.Keys)
{
if ($manifestData2.ContainsKey($actDep))
{
$manifestData2.Remove($actDep)
}
}

$script:psDependOptions = $manifestData2.PSDependOptions

$script:scope = if ($psDependOptions -and $psDependOptions.Target) {
$script:scope = if ($psDependOptions -and $psDependOptions.Target)
{
$psDependOptions.Target
}
else {
} else
{
'CurrentUser'
}

foreach ($script:moduleName in $manifestData2.Keys) {
if ($moduleName -eq 'PSDependOptions') {
foreach ($script:moduleName in $manifestData2.Keys)
{
if ($moduleName -eq 'PSDependOptions')
{
continue
}

$script:moduleVersion = $manifestData2[$moduleName]

if ($moduleVersion -eq 'latest') {
if ($moduleVersion -eq 'latest')
{
Install-PowerShell -Name $moduleName -Force -Scope $scope
}
else {
} else
{
Install-PowerShell -Name $moduleName -Force -RequiredVersion $moduleVersion -Scope $scope
}
}

$script:TerminalIconsVersion = (Import-PowerShellDataFile (Join-Path $TerminalIconsForkPath "Terminal-Icons/Terminal-Icons.psd1")).ModuleVersion

# Build only if we haven't built the current version
if (-not (Test-Path -Path (Join-Path $TerminalIconsForkPath "Output/Terminal-Icons/$TerminalIconsVersion") -PathType Container)) {
if ($TerminalIconsCloned) {
if (-not (Test-Path -Path (Join-Path $TerminalIconsForkPath "Output/Terminal-Icons/$TerminalIconsVersion") -PathType Container))
{
if ($TerminalIconsCloned)
{
Write-Host "Building Terminal-Icons (fork) $TerminalIconsVersion..." -ForegroundColor $InstallationIndicatorColorInstalling
}
else {
} else
{
Write-Host "Building Terminal-Icons (fork) $TerminalIconsVersion..." -ForegroundColor $InstallationIndicatorColorUpdating
}
Push-Location
Set-Location $TerminalIconsForkPath
& (Join-Path $TerminalIconsForkPath "build.ps1")
Pop-Location
}
else {
} else
{
Write-Host "Terminal-Icons (fork) $TerminalIconsVersion found, skipping build..." -ForegroundColor $InstallationIndicatorColorFound
}
}

# Install Meslo if not already installed
$script:fonts = Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts'
if (-not ($fonts.PSObject.Properties.name -contains 'Meslo LG S Bold Italic Nerd Font Complete Mono Windows Compatible (TrueType)')) {
if (-not ($fonts.PSObject.Properties.name -contains 'Meslo LG S Bold Italic Nerd Font Complete Mono Windows Compatible (TrueType)'))
{
Invoke-ElevatedScript { oh-my-posh font install Meslo }
}

Expand All @@ -145,11 +162,12 @@ Install-GitHubRelease ahk AutoHotkey/AutoHotkey ".*\.exe"
# yasb
$script:__yasb_repo = [System.IO.Path]::Combine("$HOME", 'yasb')

if (Test-Path $__yasb_repo) {
if (Test-Path $__yasb_repo)
{
Push-Location $__yasb_repo;
git fetch && git pull;
}
else {
} else
{
git clone https://github.com/da-rth/yasb.git $__yasb_repo
Push-Location $__yasb_repo
}
Expand Down Expand Up @@ -178,7 +196,8 @@ New-Item $PowerToysPluginsPath -ItemType Directory -Force -ErrorAction SilentlyC
$script:EverythingPowerToysZip = $(Install-GitHubRelease lin-ycv/EverythingPowerToys lin-ycv/EverythingPowerToys ".*-x64\.zip$" -NoAction -Version $(
(Get-Content -Path $(Join-Path $PowerToysPluginsPath "Everything\plugin.json") -Raw -ErrorAction SilentlyContinue | ConvertFrom-Json -ErrorAction SilentlyContinue).Version ?? "0.0.0"
))
if ($null -ne $EverythingPowerToysZip) {
if ($null -ne $EverythingPowerToysZip)
{
Expand-Archive -LiteralPath $EverythingPowerToysZip -DestinationPath $env:TEMP -Force
Copy-Item -Path $(Join-Path $env:TEMP "Everything") -Destination $PowerToysPluginsPath -Recurse -Force
}
Expand Down Expand Up @@ -220,15 +239,17 @@ Write-Host "`nRust" -ForegroundColor "Cyan"
### Rust
# See https://github.com/rust-lang/rustup/pull/3047, on occasion it will read Unknown, add a custom GetCurrent ScriptBlock
Install-Winget Rustlang.Rustup -GetCurrent {
try {
if ((Get-Command rustup -ErrorAction SilentlyContinue) -and ($(rustup --version) -match "(?<=rustup)\s*[\d\.]+")) {
try
{
if ((Get-Command rustup -ErrorAction SilentlyContinue) -and ($(rustup --version) -match "(?<=rustup)\s*[\d\.]+"))
{
[version]($matches[0])
}
else {
} else
{
[version]"0.0.0"
}
}
catch {
} catch
{
Write-Warning $_
[version]"0.0.0"
}
Expand All @@ -237,20 +258,34 @@ Install-Winget Rustlang.Rustup -GetCurrent {
Write-Host "`nC/C++" -ForegroundColor "Cyan"
$script:msys2Path = "C:\msys64\usr\bin"
$script:mingwPath = "C:\msys64\ucrt64\bin"

# https://github.com/rust-lang/pkg-config-rs/issues/51#issuecomment-346300858
# WTF bruh -@codyduong

# This has an superfluous call but idgaf. We really only care when the gcc version is updated, so use that as our baseline lib for when to upgrade
$script:msys2Remote = Invoke-RestMethod https://api.github.com/repos/msys2/msys2-installer/releases/latest
$script:msys2PackagesAsset = $msys2Remote.assets | Where-Object { $_.name -match "msys2-base-x86_64-latest.packages.txt" }
$script:msys2PackagesTxt = Join-Path $env:TEMP "Github" $msys2PackagesAsset.name
Invoke-WebRequest -Uri $msys2PackagesAsset.browser_download_url -OutFile $msys2PackagesTxt
$script:msys2RemoteVersion = if (Get-Content -Path $msys2PackagesTxt | Where-Object { $_ -match "(?<=gcc-libs )(\d+\.\d+\.\d+)" }) { $matches[0] } else { "0.0.0" }
$script:msys2RemoteVersion = if (Get-Content -Path $msys2PackagesTxt | Where-Object { $_ -match "(?<=gcc-libs )(\d+\.\d+\.\d+)" })
{ $matches[0]
} else
{ "0.0.0"
}
$script:msys2LocalVersion = "0.0.0"
try {
try
{
$script:msys2LocalVersion = if (
# We use head instead of cat because there is some fuckery going on with Neovim/bin/cat.exe being on PATH that sometimes blows up msys2 bash cat
$(& $msys2Path\bash.exe -c "head /proc/version") -match "(?<=gcc version )\d+\.\d+\.\d+"
) { $matches[0] } else { "0.0.0" }
)
{ $matches[0]
} else
{ "0.0.0"
}
} catch
{ Write-Warning $_
}
catch { Write-Warning $_ }
Install-GitHubRelease msys2 msys2/msys2-installer "msys2-x86_64-latest\.exe$" -version $msys2LocalVersion -remoteVersion $msys2RemoteVersion

# install mingw
Expand Down Expand Up @@ -287,7 +322,8 @@ Install-Winget OBSProject.OBSStudio

### PATCH W11
# https://learn.microsoft.com/en-us/windows/release-health/windows11-release-information
if (([Environment]::OSVersion.Version).Build -ge 22621) {
if (([Environment]::OSVersion.Version).Build -ge 22621)
{
Install-Winget valinet.ExplorerPatcher
}

Expand All @@ -298,10 +334,11 @@ Clear-PowershellAll
# WSL
#####
Write-Host "`nInstalling WSL" -ForegroundColor "Yellow"
try {
try
{
wsl -v
}
catch {
} catch
{
wsl --install
}

Expand All @@ -314,6 +351,7 @@ reboot Windows for WSL to work properly
"@ -ForegroundColor White
Write-Host " * Reloading shell automatically..." -ForegroundColor Cyan
Write-Host "=======================================`n" -ForegroundColor White
if (-not $update) {
if (-not $update)
{
Invoke-Command { & "pwsh.exe" -NoLogo } -NoNewScope
}

0 comments on commit 00700bb

Please sign in to comment.