diff --git a/.chezmoi.toml.tmpl b/.chezmoi.toml.tmpl index a6793a3..a3b65c6 100644 --- a/.chezmoi.toml.tmpl +++ b/.chezmoi.toml.tmpl @@ -10,6 +10,3 @@ encryption = "age" [data] posh = {{ promptBool "Install Oh My Posh?" }} - # hosts = { - # "your-hostname" = { enableZoxide = true, addReplayUploaderToPath = true } - # } diff --git a/.chezmoiignore b/.chezmoiignore index f0bd027..7ac2999 100644 --- a/.chezmoiignore +++ b/.chezmoiignore @@ -15,7 +15,7 @@ Documents # Alawys include Powershell profiles and Keys !.config/powershell -!.config/powershell/**/* +!.config/powershell/* # Oh-my-posh theme !.config/oh-my-posh.yaml diff --git a/Documents/PowerShell/Microsoft.PowerShell_profile.ps1.tmpl b/Documents/PowerShell/Microsoft.PowerShell_profile.ps1.tmpl index 14601ba..60d669f 100644 --- a/Documents/PowerShell/Microsoft.PowerShell_profile.ps1.tmpl +++ b/Documents/PowerShell/Microsoft.PowerShell_profile.ps1.tmpl @@ -1,5 +1,18 @@ -# Windows PowerShell -# Intentionally minimal: load main config from .config +# Windows Powershell + +k3d completion powershell | Out-String | Invoke-Expression +pv-migrate completion powershell | Out-String | Invoke-Expression +flux completion powershell | Out-String | Invoke-Expression + +$env:EDITOR="nvim" +$env:GEMINI_API="AIzaSyCKiR-bb51iqvAPDntOA3AXioZBXj9JLkE" +$env:TAVILY_API_KEY="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" + +$env:Path += ';Z:\replay_uploader\bin' + + +# Load chezmoi data + . (Join-Path $HOME ".config\powershell\main.ps1") diff --git a/dot_config/powershell/Modules/Aliases/Aliases.psm1 b/dot_config/powershell/Modules/Aliases/Aliases.psm1 deleted file mode 100644 index eba2a9f..0000000 --- a/dot_config/powershell/Modules/Aliases/Aliases.psm1 +++ /dev/null @@ -1,60 +0,0 @@ -# Aliases and helper functions - -if ($IsLinux) { - function Invoke-SudoLast { - $history = Get-History -Count 3 - if ($history.Count -lt 1) { Write-Host "No previous command found."; return } - $lastCommand = $history[-1].CommandLine - if ([string]::IsNullOrWhiteSpace($lastCommand)) { Write-Host "Last command was empty."; return } - Invoke-Expression "sudo $lastCommand" - } - Set-Alias -Name 's!' -Value Invoke-SudoLast | Out-Null - Set-Alias -Name 's!!' -Value Invoke-SudoLast | Out-Null -} - -if (Get-Command eza -ErrorAction SilentlyContinue) { - function Get-DirectoryColored { - param([Parameter(ValueFromRemainingArguments = $true)][string[]]$Args) - eza --icons=auto --color=always --color-scale=size -h @Args - } - Set-Alias -Name ls -Value Get-DirectoryColored | Out-Null -} - -function Import-Profile { if (Test-Path $PROFILE.CurrentUserAllHosts) { . $PROFILE.CurrentUserAllHosts } } -Set-Alias -Name Reload-Profile -Value Import-Profile | Out-Null - -function Start-Scrcpy { - param([switch]$Webcam) - $scrcpyArgs = @("--video-codec=h264", "--video-bit-rate=16M", "--audio-bit-rate=128K", "--max-fps=60", "--v4l2-sink=/dev/video0", "--camera-size=1920x1080") - if ($Webcam) { $scrcpyArgs += "--video-source=camera", "--camera-id=0", "--no-video-playback", "--camera-size=1920x1080" } - if (Get-Command scrcpy -ErrorAction SilentlyContinue) { Start-Process "scrcpy" -ArgumentList $scrcpyArgs -Wait } else { Write-Warning "scrcpy not found. Please install it first." } -} - - -# yay no confirm alias -if (Get-Command yay -ErrorAction SilentlyContinue) { - function yay-no-confirm { - param ( - [Parameter(ValueFromRemainingArguments = $true)] - [string[]]$Args - ) - yay --noconfirm @Args - } - - Set-Alias -Name yyay -Value yay-no-confirm | Out-Null -} - -function Measure-Script { - param( - [Parameter(Mandatory)] - [string]$Path - ) - if (-not (Test-Path $Path)) { - throw "Script '$Path' does not exist." - } - $sw = [System.Diagnostics.Stopwatch]::StartNew() - try { & $Path } finally { - $sw.Stop(); - Write-Host ("{0} ms" -f [math]::Round($sw.Elapsed.TotalMilliseconds)) - } -} \ No newline at end of file diff --git a/dot_config/powershell/Modules/Chezmoi/Chezmoi.psm1 b/dot_config/powershell/Modules/Chezmoi/Chezmoi.psm1 deleted file mode 100644 index a838830..0000000 --- a/dot_config/powershell/Modules/Chezmoi/Chezmoi.psm1 +++ /dev/null @@ -1,18 +0,0 @@ -# Chezmoi helpers module - -if (Get-Command chezmoi -ErrorAction SilentlyContinue) { - Invoke-Expression (& { (chezmoi completion powershell | Out-String) }) - function Edit-Chezmoi { - param([string]$FilePath) - if ([string]::IsNullOrWhiteSpace($FilePath)) { chezmoi managed -t } - else { chezmoi edit --watch -a $FilePath } - } - Set-Alias -Name ce -Value Edit-Chezmoi | Out-Null -} -else { - if (Get-Command Add-ProfileIssue -ErrorAction SilentlyContinue) { - Add-ProfileIssue 'chezmoi' 'not installed' - } -} - - diff --git a/dot_config/powershell/Modules/Completions/Completions.psm1 b/dot_config/powershell/Modules/Completions/Completions.psm1 deleted file mode 100644 index 9813035..0000000 --- a/dot_config/powershell/Modules/Completions/Completions.psm1 +++ /dev/null @@ -1,55 +0,0 @@ -# Completions module: PSCompletions and Bash bridge - -try { - if (Get-Module -ListAvailable -Name PSCompletions) { - if (-not (Get-Module PSCompletions)) { - Import-Module PSCompletions -ErrorAction Stop - } - psc menu config enable_menu_enhance 0 *> $null - } -} -catch {} - -function Register-BashCompletion { - param([string]$Command) - Register-ArgumentCompleter -Native -CommandName $Command -ScriptBlock { - param($wordToComplete, $commandAst, $cursorPosition) - $cmd = $commandAst.GetCommandName() - $helper = Join-Path $HOME ".config/powershell/bash_complete.sh" - $results = @() - if (Test-Path $helper) { - $results = @(bash $helper $cmd "$cmd $wordToComplete") - } - foreach ($item in $results) { - [System.Management.Automation.CompletionResult]::new($item, $item, 'ParameterValue', $item) - } - } -} - -function Import-BashCompletionsToPwsh { - $commands = @() - if (Test-Path '/usr/share/bash-completion/bash_completion') { - $commands = bash -c 'source /usr/share/bash-completion/bash_completion; complete -p' | - ForEach-Object { if ($_ -match 'complete .* ([\w.-]+)$') { $matches[1] } } - $completionFiles = Get-ChildItem -Path '/usr/share/bash-completion/completions' -File | - Where-Object { -not $_.Name.StartsWith('_') } | - ForEach-Object { $_.Name } - $commands = ($commands + $completionFiles) | - Where-Object { $_ -ne '-D' } | Sort-Object -Unique - } - foreach ($cmd in $commands) { Register-BashCompletion $cmd } -} - -# Arch-specific completions for pacman/yay on Linux -if ($IsLinux) { - if (Get-Command pacman -ErrorAction SilentlyContinue) { - Register-ArgumentCompleter -Native -CommandName 'pacman' -ScriptBlock { param($wordToComplete) } - } - if (Get-Command yay -ErrorAction SilentlyContinue) { - Register-ArgumentCompleter -Native -CommandName 'yay' -ScriptBlock { param($wordToComplete) } - } -} - -Export-ModuleMember -Function Register-BashCompletion, Import-BashCompletionsToPwsh - - diff --git a/dot_config/powershell/Modules/Core/Core.psm1 b/dot_config/powershell/Modules/Core/Core.psm1 deleted file mode 100644 index 89ed1e3..0000000 --- a/dot_config/powershell/Modules/Core/Core.psm1 +++ /dev/null @@ -1,22 +0,0 @@ -# Core profile utilities and baseline configuration - -if (-not $global:ProfileIssues) { $global:ProfileIssues = @() } - -function Add-ProfileIssue { - param( - [Parameter(Mandatory)][string]$Name, - [Parameter(Mandatory)][string]$Message - ) - $global:ProfileIssues += "${Name}: ${Message}" -} - -# PSReadLine settings -try { - Set-PSReadLineOption -PredictionViewStyle ListView - Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete -} -catch {} - -Export-ModuleMember -Function Add-ProfileIssue - - diff --git a/dot_config/powershell/Modules/Prompt/Prompt.psm1 b/dot_config/powershell/Modules/Prompt/Prompt.psm1 deleted file mode 100644 index b74a038..0000000 --- a/dot_config/powershell/Modules/Prompt/Prompt.psm1 +++ /dev/null @@ -1,10 +0,0 @@ -# Prompt and Oh My Posh integration (optional) - -function Initialize-PromptTheme { - if (Get-Command oh-my-posh -ErrorAction SilentlyContinue) { - oh-my-posh init --config "$HOME/.config/oh-my-posh.yaml" pwsh | Invoke-Expression - } -} - -Export-ModuleMember -Function Initialize-PromptTheme - diff --git a/dot_config/powershell/Modules/Zoxide/Zoxide.psm1 b/dot_config/powershell/Modules/Zoxide/Zoxide.psm1 deleted file mode 100644 index 9b28ea5..0000000 --- a/dot_config/powershell/Modules/Zoxide/Zoxide.psm1 +++ /dev/null @@ -1,16 +0,0 @@ -# Zoxide initialization module (lazy-init function) - -function Initialize-Zoxide { - if (Get-Command zoxide -ErrorAction SilentlyContinue) { - Invoke-Expression (& { (zoxide init --cmd cd powershell | Out-String) }) - } - else { - if (Get-Command Add-ProfileIssue -ErrorAction SilentlyContinue) { - Add-ProfileIssue 'zoxide' 'not installed' - } - } -} - -Export-ModuleMember -Function Initialize-Zoxide - - diff --git a/dot_config/powershell/alias.ps1.tmpl b/dot_config/powershell/alias.ps1.tmpl new file mode 100644 index 0000000..0dc36e3 --- /dev/null +++ b/dot_config/powershell/alias.ps1.tmpl @@ -0,0 +1,99 @@ +# Aliases + +### Sudo +{{ if eq .chezmoi.os "linux" -}} +function sudo-last +{ + $history = Get-History -Count 3 + + if ($history.Count -lt 1) + { + Write-Host "No previous command found." + return + } + + $lastCommand = $history[-1].CommandLine + + if ([string]::IsNullOrWhiteSpace($lastCommand)) + { + Write-Host "Last command was empty." + return + } + + Invoke-Expression "sudo $lastCommand" +} +Set-Alias -Name 's!' -Value sudo-last | Out-Null +Set-Alias -Name 's!!' -Value sudo-last | Out-Null +{{- end }} + + + +### EZA +if (Get-Command eza -ErrorAction SilentlyContinue) +{ + function Eza-With-Color + { + param ( + [Parameter(ValueFromRemainingArguments = $true)] + [string[]]$Args + ) + eza --icons=auto --color=always --color-scale=size -h @Args + } + Set-Alias -Name ls -Value Eza-With-Color | Out-Null +} + +### Measure in a new Terminal +function Measure-Script-Separate { + param( + [Parameter(Mandatory)] + [string]$ScriptPath + ) + + if (-not (Test-Path $ScriptPath)) { + throw "Script file '$ScriptPath' does not exist." + } + + # Compose the command to run inside the new pwsh process + $pwshCommand = @" +Import-Module PSProfiler -ErrorAction Stop +Measure-Script -Path '$ScriptPath' +"@ + + # Start new pwsh process with -NoProfile and run the above command + $result = pwsh -NoProfile -Command $pwshCommand + + return $result +} + +### Reload +function Reload-Profile { + . $PROFILE.CurrentUserAllHosts +} + + + +function Start-Scrcpy() { +param( + # Use -Webcam to enable webcam mode + [switch]$Webcam +) + +$IP = "pocof2" + +$args = @( + "--video-codec=h264", + "--video-bit-rate=16M", + "--audio-bit-rate=128K", + "--max-fps=60" + "--v4l2-sink=/dev/video0" + "--camera-size=1920x1080" +) + +if ($Webcam) { + $args += "--video-source=camera", "--camera-id=0", "--no-video-playback", "--camera-size=1920x1080" +} + + +# Start scrcpy and get the process object +Start-Process "scrcpy" -ArgumentList $args -Wait +} diff --git a/dot_config/powershell/chezmoi.ps1.tmpl b/dot_config/powershell/chezmoi.ps1.tmpl new file mode 100644 index 0000000..fe1e017 --- /dev/null +++ b/dot_config/powershell/chezmoi.ps1.tmpl @@ -0,0 +1,24 @@ + +### Setup Chezmoi +if (Get-Command chezmoi -ErrorAction SilentlyContinue) +{ + Invoke-Expression (& { (chezmoi completion powershell | Out-String) }) + + function Chezmoi-Edit-With-Args + { + param ( + [string]$FilePath + ) + # List all if empty + if ([string]::IsNullOrWhiteSpace($FilePath)) + { + chezmoi managed -t + } else + { + chezmoi edit --watch -a $FilePath + } + } + Set-Alias -Name ce -Value Chezmoi-Edit-With-Args | Out-Null +} + + diff --git a/dot_config/powershell/completion.ps1.tmpl b/dot_config/powershell/completion.ps1.tmpl new file mode 100644 index 0000000..24a84dd --- /dev/null +++ b/dot_config/powershell/completion.ps1.tmpl @@ -0,0 +1,170 @@ +# Ensure PSCompletions is installed and loaded +if (-not (Get-Module -ListAvailable -Name PSCompletions)) +{ + try + { + Install-Module PSCompletions -Scope CurrentUser -Force -ErrorAction Stop + psc add 7z arch basename bun cargo chfs choco cksum conda date dd deno df dircolors dirname docker du env fold git hashsum head join kubectl link ln md5sum ngrok nl npm nproc oh-my-posh paste pip pnpm powershell psc pwsh python scoop scoop-install scoop-update sfsu uv volta winget wsh wsl wt yarn + } catch + { + Write-Warning "Failed to install PSCompletions: $_" + } +} + +# Load the module if installed successfully +if (Get-Module -ListAvailable -Name PSCompletions) +{ + try { + Import-Module PSCompletions + psc menu config enable_menu_enhance 0 *> $null + } catch {} +} + + + +{{ if eq .chezmoi.os "linux" -}} +# Global cache +if (-not $global:PackageCache) +{ + $global:PackageCache = @{} +} + +# Function to fetch and parse packages +function Get-PackageCompletions +{ + param ( + [string]$Command + ) + + if (-not $global:PackageCache.ContainsKey($Command)) + { + $output = & $Command -Ss | Out-String + + $pattern = '^(?\S+)/(?\S+)\s+(?\S+)[^\n]*\n\s+(?[^\n]+)$' + $matches = [regex]::Matches($output, $pattern, 'Multiline') + + $pkgs = foreach ($match in $matches) + { + [PSCustomObject]@{ + Repo = $match.Groups['repo'].Value + Name = $match.Groups['name'].Value + Version = $match.Groups['version'].Value.Trim() + Description = $match.Groups['desc'].Value.Trim() + } + } + + $global:PackageCache[$Command] = $pkgs + } + + return $global:PackageCache[$Command] +} + +# Register completions for pacman +Register-ArgumentCompleter -Native -CommandName 'pacman' -ScriptBlock { + param($wordToComplete, $commandAst, $cursorPosition) + + $packages = Get-PackageCompletions 'pacman' + $prefix = [regex]::Escape($wordToComplete) + + $packages | + Where-Object { $_.Name -match "^$prefix" } | + Sort-Object -Property Name -Unique | + ForEach-Object { + [System.Management.Automation.CompletionResult]::new( + $_.Name, + $_.Name, + 'ParameterValue', + "$($_.Description) [$($_.Repo)/$($_.Version)]" + ) + } +} + +# Register completions for yay +Register-ArgumentCompleter -Native -CommandName 'yay' -ScriptBlock { + param($wordToComplete, $commandAst, $cursorPosition) + + $packages = Get-PackageCompletions 'yay' + $prefix = [regex]::Escape($wordToComplete) + + $packages | + Where-Object { $_.Name -match "^$prefix" } | + Sort-Object -Property Name -Unique | + ForEach-Object { + [System.Management.Automation.CompletionResult]::new( + $_.Name, + $_.Name, + 'ParameterValue', + "$($_.Description) [$($_.Repo)/$($_.Version)]" + ) + } +} +{{- end }} + +### Bash Autocomplete +function Register-BashCompletion +{ + param( + # The name of the command to register for completion + [string]$Command + ) + + Register-ArgumentCompleter -Native -CommandName $Command -ScriptBlock { + param( + $wordToComplete, + $commandAst, + $cursorPosition + ) + $cmd = $commandAst.GetCommandName() + + $helper = $files.completionHelper + $results = @(bash $helper $cmd "$cmd $wordToComplete") + + foreach ($item in $results) + { + [System.Management.Automation.CompletionResult]::new($item, $item, 'ParameterValue', $item) + } + } +} + +function Get-BashCompletions +{ + # Get commands that have registered completions + $cmds = bash -c 'source /usr/share/bash-completion/bash_completion; complete -p' | + ForEach-Object { + if ($_ -match 'complete .* ([\w.-]+)$') + { + $matches[1] + } + } + + # Get filenames ignoring those starting with underscore + $completionFiles = Get-ChildItem -Path '/usr/share/bash-completion/completions' -File | + Where-Object { -not $_.Name.StartsWith('_') } | + ForEach-Object { $_.Name } + + # Combine, filter out '-D', and get unique sorted list + ($cmds + $completionFiles) | + Where-Object { $_ -ne '-D' } | + Sort-Object -Unique +} + +function Import-BashCompletionsToPwsh +{ + $commands = Get-BashCompletions + + Write-Host "Registering $($commands.Count) commands for pwsh completion..." -ForegroundColor Green + foreach ($cmd in $commands) + { + Register-BashCompletion $cmd + } +} + +{{ if eq .chezmoi.os "linux" -}} +if (Test-Path '/usr/share/bash-completion/bash_completion') +{ + # Require bash-helper + + + Import-BashCompletionsToPwsh +} +{{- end }} diff --git a/dot_config/powershell/executable_bash_complete.sh b/dot_config/powershell/executable_bash_complete.sh index 9a00d8d..4540b60 100644 --- a/dot_config/powershell/executable_bash_complete.sh +++ b/dot_config/powershell/executable_bash_complete.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # Usage: ./complete.sh "sed --r" input="$1" diff --git a/dot_config/powershell/main.ps1.tmpl b/dot_config/powershell/main.ps1.tmpl index 33d56b3..e876fba 100644 --- a/dot_config/powershell/main.ps1.tmpl +++ b/dot_config/powershell/main.ps1.tmpl @@ -1,36 +1,31 @@ # Disable update check -if ($env:POWERSHELL_UPDATECHECK -ne 'LTS') { +if ($env:POWERSHELL_UPDATECHECK -ne 'LTS') +{ [System.Environment]::SetEnvironmentVariable('POWERSHELL_UPDATECHECK', 'LTS', 'User') } $time = [System.Diagnostics.Stopwatch]::StartNew() -$modulesBase = Join-Path $HOME ".config/powershell/Modules" -# Session-scoped issue collector for optional tooling -if (-not $global:ProfileIssues) { $global:ProfileIssues = @() } -function Add-ProfileIssue { - param( - [Parameter(Mandatory)][string]$Name, - [Parameter(Mandatory)][string]$Message - ) - $global:ProfileIssues += "${Name}: ${Message}" +# Related Files +$filesDir = Join-Path $HOME ".config/powershell/" +$files = @{ + zoxide = Join-Path $filesDir "zoxide.ps1" + apiKeys = Join-Path $filesDir "api_keys.ps1" + completion = Join-Path $filesDir "completion.ps1" + completionHelper = Join-Path $filesDir "bash_complete.sh" + alias = Join-Path $filesDir "alias.ps1" + chezmoi = Join-Path $filesDir "chezmoi.ps1" + measureTime = Join-Path $filesDir "measure_time.ps1" } -function Import-Module-Try { - param( - [Parameter(Mandatory)][string]$Name - ) - try { - Import-Module (Join-Path $modulesBase "$Name/$Name.psm1") - return $true - } - catch { - Add-ProfileIssue "Could not import module $Name :" $_.Exception.Message - return $false +# Ensure all files exist +foreach ($key in $files.Keys) { + if (-Not (Test-Path $files[$key])) { + Write-Warning "Missing File: $key → $($files[$key])" } } -Import-Module-Try "Core" +. $files.measureTime ### Setup-PSReadline # Show multi line history (Toggle with F2) @@ -42,26 +37,18 @@ Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete # Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward -### Prompt init -if (Import-Module-Try "Prompt") { - Initialize-PromptTheme -} - -# Import modular components if available -if (Test-Path (Join-Path $HOME ".config/powershell/api_keys.ps1")) { . (Join-Path $HOME ".config/powershell/api_keys.ps1") } else { Add-ProfileIssue "api_keys.ps1" "not found" } +### Oh My Posh init +{{ if .posh -}} +oh-my-posh init --config "$HOME/.config/oh-my-posh.yaml" pwsh | Invoke-Expression +{{- end }} -if (Import-Module-Try "Zoxide") { Initialize-Zoxide } -if (Import-Module-Try "Completions") { Import-BashCompletionsToPwsh } -Import-Module-Try "Aliases" -Import-Module-Try "Chezmoi" +. $files.apiKeys +. $files.zoxide +. $files.completion +. $files.alias +. $files.chezmoi # Print timing info $time.Stop() -Write-Host "Profile loaded $(if ($global:ProfileIssues.Count -gt 0) { "with $($global:ProfileIssues.Count) issues" } else { "successfully" }) in $([math]::Round($time.Elapsed.TotalMilliseconds))ms" - -# Print issues if any -if ($global:ProfileIssues.Count -gt 0) { - $preview = ($global:ProfileIssues | Select-Object -First 4) -join '; ' - Write-Host "Failed: $preview" -ForegroundColor Yellow -} +Write-Host "Profile loaded successfully in $([math]::Round($time.Elapsed.TotalMilliseconds))ms" diff --git a/dot_config/powershell/measure_time.ps1 b/dot_config/powershell/measure_time.ps1 index e69de29..4480b80 100644 --- a/dot_config/powershell/measure_time.ps1 +++ b/dot_config/powershell/measure_time.ps1 @@ -0,0 +1,19 @@ +# Check if PSProfiler is installed +if (-not (Get-Module -ListAvailable -Name PSProfiler)) { + try { + Write-Host "Installing PSProfiler..." + Install-Module PSProfiler -Scope CurrentUser -Force -ErrorAction Stop + } + catch { + Write-Warning "Failed to install PSProfiler: $_" + } +} + +# Try to import the module +try { + Import-Module PSProfiler -ErrorAction Stop +} +catch { + Write-Warning "⚠ Could not load PSProfiler: $_" +} + diff --git a/dot_config/powershell/profile.ps1.tmpl b/dot_config/powershell/profile.ps1.tmpl index bd730bb..ddda0e8 100644 --- a/dot_config/powershell/profile.ps1.tmpl +++ b/dot_config/powershell/profile.ps1.tmpl @@ -2,6 +2,19 @@ $env:PATH += ":$HOME/.local/bin" +# yay no confirm alias +if (Get-Command yay -ErrorAction SilentlyContinue) { + function yay-no-confirm { + param ( + [Parameter(ValueFromRemainingArguments = $true)] + [string[]]$Args + ) + yay --noconfirm @Args + } + + Set-Alias -Name yyay -Value yay-no-confirm | Out-Null +} + # Load Main Data . (Join-Path $HOME ".config/powershell/main.ps1") diff --git a/dot_config/powershell/zoxide.ps1.tmpl b/dot_config/powershell/zoxide.ps1.tmpl new file mode 100644 index 0000000..1b099fe --- /dev/null +++ b/dot_config/powershell/zoxide.ps1.tmpl @@ -0,0 +1,17 @@ +# Install zoxide if not present +if (-not (Get-Command zoxide -ErrorAction SilentlyContinue)) +{ + {{ if eq .chezmoi.os "windows" -}} + Write-Host "Installing zoxide via winget…" -ForegroundColor Cyan + winget install --silent ajeetdsouza.zoxide + {{- else -}} + Write-Host "Installing zoxide via curl…" -ForegroundColor Cyan + bash -c "curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh" + {{- end }} +} + +# Initialize zoxide +if (Get-Command zoxide -ErrorAction SilentlyContinue) +{ + Invoke-Expression (& { (zoxide init --cmd cd powershell | Out-String) }) +} diff --git a/run_onchange_3-oh-my-posh.ps1.tmpl b/run_onchange_3-oh-my-posh.ps1.tmpl index 24f5a04..a81e0fe 100644 --- a/run_onchange_3-oh-my-posh.ps1.tmpl +++ b/run_onchange_3-oh-my-posh.ps1.tmpl @@ -15,7 +15,7 @@ fi if (-not (Get-Command oh-my-posh -ErrorAction SilentlyContinue)) { Write-Host "[Oh My Posh] Not found! Installing using winget..." - winget install JanDeDobbeleer.OhMyPosh --source winget --scope user --force --accept-package-agreements --accept-source-agreements + winget install JanDeDobbeleer.OhMyPosh --source winget --scope user --force } {{- end -}} diff --git a/run_onchange_before_2-decrypt-private-key.ps1.tmpl b/run_onchange_before_2-decrypt-private-key.ps1.tmpl index b328f8b..211db70 100644 --- a/run_onchange_before_2-decrypt-private-key.ps1.tmpl +++ b/run_onchange_before_2-decrypt-private-key.ps1.tmpl @@ -10,8 +10,7 @@ if (-not (Test-Path $keyPath)) { New-Item -ItemType Directory -Path $dir -Force | Out-Null } - # Decrypt passphrase-encrypted age file into identity path - # Requires interactive passphrase entry on first apply - chezmoi age decrypt --passphrase --input $agePath --output $keyPath + # Decrypt using chezmoi and age + chezmoi age decrypt --output $keyPath --passphrase $agePath }