From 3c10d4ddc65d53f9c9d74dacbfbbce906c939147 Mon Sep 17 00:00:00 2001 From: Julian Pawlowski <75446+jpawlowski@users.noreply.github.com> Date: Sat, 17 Aug 2024 16:48:10 +0200 Subject: [PATCH] add URL support for OhMyPosh --- src/powershell-extended/NOTES.md | 3 +- .../PROFILE.AllUsersAllHosts.ps1 | 18 +++++------ src/powershell-extended/PROFILE.Functions.ps1 | 30 ++++++++++--------- .../devcontainer-feature.json | 4 +-- .../Microsoft.PowerShell_profile.ps1 | 26 ++++++++-------- .../powershell/Microsoft.VSCode_profile.ps1 | 24 +++++++-------- .../dotfiles/.config/powershell/profile.ps1 | 2 +- src/powershell-extended/install.sh | 2 +- 8 files changed, 56 insertions(+), 53 deletions(-) diff --git a/src/powershell-extended/NOTES.md b/src/powershell-extended/NOTES.md index f98c694..6a81745 100644 --- a/src/powershell-extended/NOTES.md +++ b/src/powershell-extended/NOTES.md @@ -6,7 +6,8 @@ This feature comes with a custom [Oh My Posh](https://ohmyposh.dev/) theme to ad You may [change the theme](https://ohmyposh.dev/docs/themes) to one of the preinstalled ones by setting the container environment variables `PSPROFILE_POSH_THEME` (for the PowerShell host) and/or `PSPROFILE_VSCODE_POSH_THEME` (for the VSCode PowerShell -Extension) to the name of the desired theme. You may also put your own theme into the `~/.config/oh-my-posh/themes` folder. +Extension) to the name of the desired theme. You may also put your own theme into the `~/.config/oh-my-posh/themes` folder, +or set the environment variable to a URL to have the theme downloaded automatically. > **Note**: Most themes require installing a [Nerd Font](https://ohmyposh.dev/docs/installation/fonts) on your host > system (not the Dev Container) and changing your font settings in VSCode. The VSCode default font _Cascadia Mono_ diff --git a/src/powershell-extended/PROFILE.AllUsersAllHosts.ps1 b/src/powershell-extended/PROFILE.AllUsersAllHosts.ps1 index 3e3d127..f718a66 100644 --- a/src/powershell-extended/PROFILE.AllUsersAllHosts.ps1 +++ b/src/powershell-extended/PROFILE.AllUsersAllHosts.ps1 @@ -42,8 +42,8 @@ try { if ($IsWindows) { return } # This global profile is for *nix only #region Script Variables ======================================================= - $__PSProfileEnvPathOriginal = [Environment]::GetEnvironmentVariable('PATH') - $__PSProfileEnvTermProgram = [Environment]::GetEnvironmentVariable('TERM_PROGRAM') + $__PSProfileEnvPathOriginal = [System.Environment]::GetEnvironmentVariable('PATH') + $__PSProfileEnvTermProgram = [System.Environment]::GetEnvironmentVariable('TERM_PROGRAM') $__PSProfileEnvAliasDirForce = [System.Environment]::GetEnvironmentVariable('PSPROFILE_ALIAS_DIR_FORCE') $__PSProfileEnvAliasDirHidden = [System.Environment]::GetEnvironmentVariable('PSPROFILE_ALIAS_DIR_HIDDEN') @@ -68,8 +68,8 @@ try { # Mark first run notice as displayed after 10s to avoid problems with fast terminal refreshes hiding it $null = Start-ThreadJob -Name FirstRunNoticeAlreadyDisplayed -ScriptBlock { Start-Sleep -Seconds 10 - $null = New-Item -ItemType Directory -Force -Path "$env:HOME/.config/vscode-dev-containers" - $null = New-Item -ItemType File -Force -Path "$env:HOME/.config/vscode-dev-containers/first-run-notice-already-displayed" + $null = New-Item -ItemType Directory -Force -Path "${HOME}/.config/vscode-dev-containers" + $null = New-Item -ItemType File -Force -Path "${HOME}/.config/vscode-dev-containers/first-run-notice-already-displayed" } } @@ -81,24 +81,24 @@ try { #region Environment Variables ================================================== # Add local bin directory to PATH if not already present - if ($__PSProfileEnvPathOriginal.Split(':') -notcontains "${HOME}/.local/bin") { [Environment]::SetEnvironmentVariable('PATH', "${__PSProfileOriginalPath}:${HOME}/.local/bin") } + if ($__PSProfileEnvPathOriginal.Split(':') -notcontains "${HOME}/.local/bin") { [System.Environment]::SetEnvironmentVariable('PATH', "${__PSProfileOriginalPath}:${HOME}/.local/bin") } # Set the USER environment variable if not already set - if ($null -eq [Environment]::GetEnvironmentVariable('USER') -and $null -eq [Environment]::GetEnvironmentVariable('USERNAME')) { [Environment]::SetEnvironmentVariable('USER', (& $(& which whoami))) } + if ($null -eq [System.Environment]::GetEnvironmentVariable('USER') -and $null -eq [System.Environment]::GetEnvironmentVariable('USERNAME')) { [System.Environment]::SetEnvironmentVariable('USER', (& $(& which whoami))) } # Set the default git editor if not already set if ( - $null -eq [Environment]::GetEnvironmentVariable('GIT_EDITOR') -and + $null -eq [System.Environment]::GetEnvironmentVariable('GIT_EDITOR') -and $null -eq $(try { git config --get core.editor } catch { $Error.Clear(); $null }) ) { # Check if the terminal program is vscode if ($__PSProfileEnvTermProgram -match '^(vscode|codespaces)$') { # Check if code-insiders is available and code is not available if ((Get-Command -Name 'code-insiders' -ErrorAction Ignore) -and $null -eq (Get-Command -Name 'code' -ErrorAction Ignore)) { - [Environment]::SetEnvironmentVariable('GIT_EDITOR', 'code-insiders --wait') + [System.Environment]::SetEnvironmentVariable('GIT_EDITOR', 'code-insiders --wait') } else { - [Environment]::SetEnvironmentVariable('GIT_EDITOR', 'code --wait') + [System.Environment]::SetEnvironmentVariable('GIT_EDITOR', 'code --wait') } } } diff --git a/src/powershell-extended/PROFILE.Functions.ps1 b/src/powershell-extended/PROFILE.Functions.ps1 index ab31125..9e30f8c 100644 --- a/src/powershell-extended/PROFILE.Functions.ps1 +++ b/src/powershell-extended/PROFILE.Functions.ps1 @@ -76,7 +76,7 @@ function __PSProfile-Write-ProfileLoadMessage { [switch]$Force ) - if ($Force -or ($env:POWERSHELL_HIDE_PROFILE_LOAD_MESSAGES -ne $true -and (__PSProfile-Assert-IsUserInteractiveShell))) { + if ($Force -or ([System.Environment]::GetEnvironmentVariable('POWERSHELL_HIDE_PROFILE_LOAD_MESSAGES') -ne $true -and (__PSProfile-Assert-IsUserInteractiveShell))) { $writeHostParams = @{ Object = $Message ForegroundColor = $ForegroundColor @@ -359,23 +359,25 @@ function __PSProfile-Enable-OhMyPosh-Theme { #> [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseApprovedVerbs', '')] param( - [string]$Theme = 'devcontainers.minimal' + [string]$Theme = 'devcontainers.minimal.omp.json' ) - # Let codespaces always be an alias for devcontainers - $Theme = [regex]::Replace($Theme, 'codespaces', 'devcontainers') + if ($Theme -notmatch '^https?://') { + # Let codespaces always be an alias for devcontainers + $Theme = [regex]::Replace($Theme, 'codespaces', 'devcontainers') - # Ensure the theme file has the correct extension - if ($Theme -notmatch '\.omp\.json$') { $Theme = "$Theme.omp.json" } + # Ensure the theme file has the correct extension + if ($Theme -notmatch '\.omp\.[^\.]+$') { $Theme = "$Theme.omp.json" } - # Find path to theme file - if ($Theme -notmatch '^/') { - if ([System.IO.File]::Exists("$env:HOME/.config/oh-my-posh/themes/$Theme")) { - $Theme = "$env:HOME/.config/oh-my-posh/themes/$Theme" - } - else { - if (-not $env:POSH_THEMES_PATH) { $env:POSH_THEMES_PATH = "$env:HOME/.cache/oh-my-posh/themes" } - $Theme = "$env:POSH_THEMES_PATH/$Theme" + # Find path to theme file + if ($Theme -notmatch '^/') { + if ([System.IO.File]::Exists("${HOME}/.config/oh-my-posh/themes/$Theme")) { + $Theme = "${HOME}/.config/oh-my-posh/themes/$Theme" + } + else { + if (-not [System.Environment]::GetEnvironmentVariable('POSH_THEMES_PATH')) { [System.Environment]::SetEnvironmentVariable('POSH_THEMES_PATH', "${HOME}/.cache/oh-my-posh/themes") } + $Theme = "${HOME}/.cache/oh-my-posh/themes/$Theme" + } } } diff --git a/src/powershell-extended/devcontainer-feature.json b/src/powershell-extended/devcontainer-feature.json index 333b18e..6496f07 100644 --- a/src/powershell-extended/devcontainer-feature.json +++ b/src/powershell-extended/devcontainer-feature.json @@ -110,7 +110,7 @@ "PSPROFILE_AUTOUPDATE_MODULEHELP": "true", "PSPROFILE_PSREADLINE_PREDICTION_SOURCE": "HistoryAndPlugin", "PSPROFILE_PSREADLINE_PREDICTION_VIEWSTYLE": "InlineView", - "PSPROFILE_POSH_THEME": "devcontainers.minimal", + "PSPROFILE_POSH_THEME": "devcontainers.minimal.omp.json", "PSPROFILE_TERMINAL_COMPLETION_GIT": "true", "PSPROFILE_TERMINAL_COMPLETION_POSH": "false", "PSPROFILE_TERMINAL_COMPLETION_PREDICTOR": "true", @@ -123,7 +123,7 @@ "PSPROFILE_VSCODE_AUTOUPDATE_MODULEHELP": "false", "PSPROFILE_VSCODE_PSREADLINE_PREDICTION_SOURCE": "HistoryAndPlugin", "PSPROFILE_VSCODE_PSREADLINE_PREDICTION_VIEWSTYLE": "InlineView", - "PSPROFILE_VSCODE_POSH_THEME": "devcontainers.minimal", + "PSPROFILE_VSCODE_POSH_THEME": "devcontainers.minimal.omp.json", "PSPROFILE_VSCODE_TERMINAL_COMPLETION_GIT": "true", "PSPROFILE_VSCODE_TERMINAL_COMPLETION_POSH": "false", "PSPROFILE_VSCODE_TERMINAL_COMPLETION_PREDICTOR": "true", diff --git a/src/powershell-extended/dotfiles/.config/powershell/Microsoft.PowerShell_profile.ps1 b/src/powershell-extended/dotfiles/.config/powershell/Microsoft.PowerShell_profile.ps1 index 88e5b03..c2fab5a 100644 --- a/src/powershell-extended/dotfiles/.config/powershell/Microsoft.PowerShell_profile.ps1 +++ b/src/powershell-extended/dotfiles/.config/powershell/Microsoft.PowerShell_profile.ps1 @@ -29,34 +29,34 @@ try { __PSProfile-Write-ProfileLoadMessage '💻 Applying shared configurations for all terminals.' -ForegroundColor DarkCyan #region Import Modules ===================================================== - if ([Environment]::GetEnvironmentVariable('PSPROFILE_TERMINAL_COMPLETION_GIT') -eq $true) { __PSProfile-Import-ModuleAndInstallIfMissing -Name posh-git } - if ([Environment]::GetEnvironmentVariable('PSPROFILE_TERMINAL_COMPLETION_PSFZF') -eq $true -and $null -ne (Get-Command -Name fzf -CommandType Application -ErrorAction Ignore)) { __PSProfile-Import-ModuleAndInstallIfMissing -Name PSFzf } - if ([Environment]::GetEnvironmentVariable('PSPROFILE_TERMINAL_COMPLETION_PREDICTOR') -eq $true) { __PSProfile-Import-ModuleAndInstallIfMissing -Name CompletionPredictor } - if ([Environment]::GetEnvironmentVariable('PSPROFILE_TERMINAL_COMPLETION_PREDICTOR_AZ') -eq $true) { if (Get-Module -Name Az.Accounts -ListAvailable) { __PSProfile-Import-ModuleAndInstallIfMissing -Name Az.Tools.Predictor } } - if ([Environment]::GetEnvironmentVariable('PSPROFILE_TERMINAL_Z') -eq $true) { __PSProfile-Import-ModuleAndInstallIfMissing -Name z } - if ([Environment]::GetEnvironmentVariable('PSPROFILE_TERMINAL_ICONS') -eq $true) { __PSProfile-Import-ModuleAndInstallIfMissing -Name Terminal-Icons } + if ([System.Environment]::GetEnvironmentVariable('PSPROFILE_TERMINAL_COMPLETION_GIT') -eq $true) { __PSProfile-Import-ModuleAndInstallIfMissing -Name posh-git } + if ([System.Environment]::GetEnvironmentVariable('PSPROFILE_TERMINAL_COMPLETION_PSFZF') -eq $true -and $null -ne (Get-Command -Name fzf -CommandType Application -ErrorAction Ignore)) { __PSProfile-Import-ModuleAndInstallIfMissing -Name PSFzf } + if ([System.Environment]::GetEnvironmentVariable('PSPROFILE_TERMINAL_COMPLETION_PREDICTOR') -eq $true) { __PSProfile-Import-ModuleAndInstallIfMissing -Name CompletionPredictor } + if ([System.Environment]::GetEnvironmentVariable('PSPROFILE_TERMINAL_COMPLETION_PREDICTOR_AZ') -eq $true) { if (Get-Module -Name Az.Accounts -ListAvailable) { __PSProfile-Import-ModuleAndInstallIfMissing -Name Az.Tools.Predictor } } + if ([System.Environment]::GetEnvironmentVariable('PSPROFILE_TERMINAL_Z') -eq $true) { __PSProfile-Import-ModuleAndInstallIfMissing -Name z } + if ([System.Environment]::GetEnvironmentVariable('PSPROFILE_TERMINAL_ICONS') -eq $true) { __PSProfile-Import-ModuleAndInstallIfMissing -Name Terminal-Icons } #endregion Import Modules -------------------------------------------------- #region PSReadLine predictor plugins ======================================= $__PSProfilePSReadLineOptions = @{} - $__PSProfileEnvPSReadlinePredictionSource = [Environment]::GetEnvironmentVariable('PSPROFILE_PSREADLINE_PREDICTION_SOURCE') - $__PSProfileEnvPSReadlinePredictionViewStyle = [Environment]::GetEnvironmentVariable('PSPROFILE_PSREADLINE_PREDICTION_VIEWSTYLE') + $__PSProfileEnvPSReadlinePredictionSource = [System.Environment]::GetEnvironmentVariable('PSPROFILE_PSREADLINE_PREDICTION_SOURCE') + $__PSProfileEnvPSReadlinePredictionViewStyle = [System.Environment]::GetEnvironmentVariable('PSPROFILE_PSREADLINE_PREDICTION_VIEWSTYLE') if ($null -ne $__PSProfileEnvPSReadlinePredictionSource) { $__PSProfilePSReadLineOptions.PredictionSource = $__PSProfileEnvPSReadlinePredictionSource } if ($null -ne $__PSProfileEnvPSReadlinePredictionViewStyle) { $__PSProfilePSReadLineOptions.PredictionViewStyle = $__PSProfileEnvPSReadlinePredictionViewStyle } if ($__PSProfilePSReadLineOptions.Count -gt 0) { Set-PSReadLineOption @__PSProfilePSReadLineOptions } #endregion PSReadLine ------------------------------------------------------ #region Environment ======================================================== - $__PSProfileEnvAutoUpdateModuleHelp = [Environment]::GetEnvironmentVariable('PSPROFILE_AUTOUPDATE_MODULEHELP') + $__PSProfileEnvAutoUpdateModuleHelp = [System.Environment]::GetEnvironmentVariable('PSPROFILE_AUTOUPDATE_MODULEHELP') if ($null -eq $__PSProfileEnvAutoUpdateModuleHelp -or $__PSProfileEnvAutoUpdateModuleHelp -eq $true) { __PSProfile-Update-Help } #endregion Environment ----------------------------------------------------- #region Oh My Posh ========================================================= - $__PSProfileEnvOhMyPoshDisableUpgradeNotice = [Environment]::GetEnvironmentVariable('PSPROFILE_POSH_DISABLE_UPGRADE_NOTICE') - $__PSProfileEnvOhMyPoshTheme = [Environment]::GetEnvironmentVariable('PSPROFILE_POSH_THEME') + $__PSProfileEnvOhMyPoshDisableUpgradeNotice = [System.Environment]::GetEnvironmentVariable('PSPROFILE_POSH_DISABLE_UPGRADE_NOTICE') + $__PSProfileEnvOhMyPoshTheme = [System.Environment]::GetEnvironmentVariable('PSPROFILE_POSH_THEME') if ($null -eq $__PSProfileEnvOhMyPoshDisableUpgradeNotice -or $__PSProfileEnvOhMyPoshDisableUpgradeNotice -eq $true) { __PSProfile-Set-OhMyPosh-UpdateNotice -Disable } if ($null -ne $__PSProfileEnvOhMyPoshTheme) { __PSProfile-Enable-OhMyPosh-Theme -ThemeName $__PSProfileEnvOhMyPoshTheme } else { __PSProfile-Enable-OhMyPosh-Theme } - if ([Environment]::GetEnvironmentVariable('PSPROFILE_TERMINAL_COMPLETION_POSH') -eq $true -and $null -ne [Environment]::GetEnvironmentVariable('POSH_PID')) { oh-my-posh completion powershell | Out-String | Invoke-Expression } + if ([System.Environment]::GetEnvironmentVariable('PSPROFILE_TERMINAL_COMPLETION_POSH') -eq $true -and $null -ne [System.Environment]::GetEnvironmentVariable('POSH_PID')) { oh-my-posh completion powershell | Out-String | Invoke-Expression } #endregion Oh My Posh ------------------------------------------------------ #region Custom Profile ===================================================== @@ -99,7 +99,7 @@ try { [regex]::Replace( ( [regex]::Replace( - [Environment]::GetEnvironmentVariable('TERM_PROGRAM'), + [System.Environment]::GetEnvironmentVariable('TERM_PROGRAM'), '\.[^\.]*$', '' ) diff --git a/src/powershell-extended/dotfiles/.config/powershell/Microsoft.VSCode_profile.ps1 b/src/powershell-extended/dotfiles/.config/powershell/Microsoft.VSCode_profile.ps1 index 35a7929..eaf1f32 100644 --- a/src/powershell-extended/dotfiles/.config/powershell/Microsoft.VSCode_profile.ps1 +++ b/src/powershell-extended/dotfiles/.config/powershell/Microsoft.VSCode_profile.ps1 @@ -40,33 +40,33 @@ try { __PSProfile-Write-ProfileLoadMessage "📝 Applying configurations for $($PSStyle.Bold)PowerShell Extension$($PSStyle.BoldOff)." -ForegroundColor DarkCyan #region Import Modules ===================================================== - if ([Environment]::GetEnvironmentVariable('PSPROFILE_VSCODE_TERMINAL_COMPLETION_GIT') -eq $true) { __PSProfile-Import-ModuleAndInstallIfMissing -Name posh-git } - if ([Environment]::GetEnvironmentVariable('PSPROFILE_VSCODE_TERMINAL_COMPLETION_PSFZF') -eq $true -and $null -ne (Get-Command -Name fzf -CommandType Application -ErrorAction Ignore)) { __PSProfile-Import-ModuleAndInstallIfMissing -Name PSFzf } - if ([Environment]::GetEnvironmentVariable('PSPROFILE_VSCODE_TERMINAL_COMPLETION_PREDICTOR') -eq $true) { __PSProfile-Import-ModuleAndInstallIfMissing -Name CompletionPredictor } - if ([Environment]::GetEnvironmentVariable('PSPROFILE_VSCODE_TERMINAL_COMPLETION_PREDICTOR_AZ') -eq $true) { if (Get-Module -Name Az.Accounts -ListAvailable) { __PSProfile-Import-ModuleAndInstallIfMissing -Name Az.Tools.Predictor } } - if ([Environment]::GetEnvironmentVariable('PSPROFILE_VSCODE_TERMINAL_Z') -eq $true) { __PSProfile-Import-ModuleAndInstallIfMissing -Name z } - if ([Environment]::GetEnvironmentVariable('PSPROFILE_VSCODE_TERMINAL_ICONS') -eq $true) { __PSProfile-Import-ModuleAndInstallIfMissing -Name Terminal-Icons } + if ([System.Environment]::GetEnvironmentVariable('PSPROFILE_VSCODE_TERMINAL_COMPLETION_GIT') -eq $true) { __PSProfile-Import-ModuleAndInstallIfMissing -Name posh-git } + if ([System.Environment]::GetEnvironmentVariable('PSPROFILE_VSCODE_TERMINAL_COMPLETION_PSFZF') -eq $true -and $null -ne (Get-Command -Name fzf -CommandType Application -ErrorAction Ignore)) { __PSProfile-Import-ModuleAndInstallIfMissing -Name PSFzf } + if ([System.Environment]::GetEnvironmentVariable('PSPROFILE_VSCODE_TERMINAL_COMPLETION_PREDICTOR') -eq $true) { __PSProfile-Import-ModuleAndInstallIfMissing -Name CompletionPredictor } + if ([System.Environment]::GetEnvironmentVariable('PSPROFILE_VSCODE_TERMINAL_COMPLETION_PREDICTOR_AZ') -eq $true) { if (Get-Module -Name Az.Accounts -ListAvailable) { __PSProfile-Import-ModuleAndInstallIfMissing -Name Az.Tools.Predictor } } + if ([System.Environment]::GetEnvironmentVariable('PSPROFILE_VSCODE_TERMINAL_Z') -eq $true) { __PSProfile-Import-ModuleAndInstallIfMissing -Name z } + if ([System.Environment]::GetEnvironmentVariable('PSPROFILE_VSCODE_TERMINAL_ICONS') -eq $true) { __PSProfile-Import-ModuleAndInstallIfMissing -Name Terminal-Icons } #endregion Import Modules -------------------------------------------------- #region PSReadLine Predictor plugins ======================================= $__PSProfilePSReadLineOptions = @{} - $__PSProfileEnvPSReadlinePredictionSource = [Environment]::GetEnvironmentVariable('PSPROFILE_VSCODE_PSREADLINE_PREDICTION_SOURCE') - $__PSProfileEnvPSReadlinePredictionViewStyle = [Environment]::GetEnvironmentVariable('PSPROFILE_VSCODE_PSREADLINE_PREDICTION_VIEWSTYLE') + $__PSProfileEnvPSReadlinePredictionSource = [System.Environment]::GetEnvironmentVariable('PSPROFILE_VSCODE_PSREADLINE_PREDICTION_SOURCE') + $__PSProfileEnvPSReadlinePredictionViewStyle = [System.Environment]::GetEnvironmentVariable('PSPROFILE_VSCODE_PSREADLINE_PREDICTION_VIEWSTYLE') if ($null -ne $__PSProfileEnvPSReadlinePredictionSource) { $__PSProfilePSReadLineOptions.PredictionSource = $__PSProfileEnvPSReadlinePredictionSource } if ($null -ne $__PSProfileEnvPSReadlinePredictionViewStyle) { $__PSProfilePSReadLineOptions.PredictionViewStyle = $__PSProfileEnvPSReadlinePredictionViewStyle } if ($__PSProfilePSReadLineOptions.Count -gt 0) { Set-PSReadLineOption @__PSProfilePSReadLineOptions } #endregion PSReadLine ------------------------------------------------------ #region Environment ======================================================== - if ([Environment]::GetEnvironmentVariable('PSPROFILE_VSCODE_AUTOUPDATE_MODULEHELP') -eq $true) { __PSProfile-Update-Help } + if ([System.Environment]::GetEnvironmentVariable('PSPROFILE_VSCODE_AUTOUPDATE_MODULEHELP') -eq $true) { __PSProfile-Update-Help } #endregion Environment ----------------------------------------------------- #region Oh My Posh ========================================================= - $__PSProfileEnvOhMyPoshDisableUpgradeNotice = [Environment]::GetEnvironmentVariable('PSPROFILE_POSH_DISABLE_UPGRADE_NOTICE') - $__PSProfileEnvOhMyPoshTheme = [Environment]::GetEnvironmentVariable('PSPROFILE_VSCODE_POSH_THEME') + $__PSProfileEnvOhMyPoshDisableUpgradeNotice = [System.Environment]::GetEnvironmentVariable('PSPROFILE_POSH_DISABLE_UPGRADE_NOTICE') + $__PSProfileEnvOhMyPoshTheme = [System.Environment]::GetEnvironmentVariable('PSPROFILE_VSCODE_POSH_THEME') if ($null -eq $__PSProfileEnvOhMyPoshDisableUpgradeNotice -or $__PSProfileEnvOhMyPoshDisableUpgradeNotice -eq $true) { __PSProfile-Set-OhMyPosh-UpdateNotice -Disable } if ($null -ne $__PSProfileEnvOhMyPoshTheme) { __PSProfile-Enable-OhMyPosh-Theme -ThemeName $__PSProfileEnvOhMyPoshTheme } else { __PSProfile-Enable-OhMyPosh-Theme } - if ([Environment]::GetEnvironmentVariable('PSPROFILE_VSCODE_TERMINAL_COMPLETION_POSH') -eq $true -and $null -ne [Environment]::GetEnvironmentVariable('POSH_PID')) { oh-my-posh completion powershell | Out-String | Invoke-Expression } + if ([System.Environment]::GetEnvironmentVariable('PSPROFILE_VSCODE_TERMINAL_COMPLETION_POSH') -eq $true -and $null -ne [System.Environment]::GetEnvironmentVariable('POSH_PID')) { oh-my-posh completion powershell | Out-String | Invoke-Expression } #endregion Oh My Posh ------------------------------------------------------ #region Custom Profile ===================================================== diff --git a/src/powershell-extended/dotfiles/.config/powershell/profile.ps1 b/src/powershell-extended/dotfiles/.config/powershell/profile.ps1 index b979513..ef5fead 100644 --- a/src/powershell-extended/dotfiles/.config/powershell/profile.ps1 +++ b/src/powershell-extended/dotfiles/.config/powershell/profile.ps1 @@ -33,7 +33,7 @@ try { __PSProfile-Write-ProfileLoadMessage "👤 Loading $($PSStyle.Bold)user$($PSStyle.BoldOff) profile." #region PSReadLine, except predictor plugins =============================== - $__PSProfileEnvPSReadlineEditMode = [Environment]::GetEnvironmentVariable('PSPROFILE_PSREADLINE_EDITMODE') + $__PSProfileEnvPSReadlineEditMode = [System.Environment]::GetEnvironmentVariable('PSPROFILE_PSREADLINE_EDITMODE') $__PSProfilePSReadLineOptions = @{ EditMode = $(if ($null -ne $__PSProfileEnvPSReadlineEditMode) { $__PSProfileEnvPSReadlineEditMode } else { 'Emacs' }) HistorySearchCursorMovesToEnd = $true diff --git a/src/powershell-extended/install.sh b/src/powershell-extended/install.sh index 5e01757..66b59ba 100755 --- a/src/powershell-extended/install.sh +++ b/src/powershell-extended/install.sh @@ -404,7 +404,7 @@ if [ "$POWERSHELL_UPDATE_MODULESHELP" = 'true' ]; then touch "/root/.local/state/powershell/.updateHelpMarker" else # shellcheck disable=SC2140 - sudo -H -u "${USERNAME}" "$(command -v pwsh)" -NoLogo -NoProfile -Command "$prefs; Update-Help -Scope CurrentUser -UICulture en-US -ErrorAction Stop -ProgressAction Ignore; New-Item -Path "\$env:HOME/.local/state/powershell/.updateHelpMarker" -ItemType File -Force" + sudo -H -u "${USERNAME}" "$(command -v pwsh)" -NoLogo -NoProfile -Command "$prefs; Update-Help -Scope CurrentUser -UICulture en-US -ErrorAction Stop -ProgressAction Ignore; New-Item -Path "\${HOME}/.local/state/powershell/.updateHelpMarker" -ItemType File -Force" fi fi