From 7e32fd952ef0ef4b4765e22f5c2cfe827fff00ad Mon Sep 17 00:00:00 2001 From: Segev Finer Date: Sun, 16 Jan 2022 21:28:26 +0200 Subject: [PATCH] feat(pwsh): Set STARSHIP_SHELL to pwsh on PS >5 (#3443) * feat(pwsh): Set STARSHIP_SHELL to pwsh ON PS >5 This is needed for the custom module to use the correct shell. Closes #3376 * Update src/context.rs Co-authored-by: David Knaack Co-authored-by: David Knaack --- src/context.rs | 2 +- src/init/starship.ps1 | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/context.rs b/src/context.rs index 8ee9ea787..8f9493e1a 100644 --- a/src/context.rs +++ b/src/context.rs @@ -278,7 +278,7 @@ impl<'a> Context<'a> { "bash" => Shell::Bash, "fish" => Shell::Fish, "ion" => Shell::Ion, - "powershell" => Shell::PowerShell, + "powershell" | "pwsh" => Shell::PowerShell, "zsh" => Shell::Zsh, "elvish" => Shell::Elvish, "tcsh" => Shell::Tcsh, diff --git a/src/init/starship.ps1 b/src/init/starship.ps1 index 2ae5158ba..d756476ee 100755 --- a/src/init/starship.ps1 +++ b/src/init/starship.ps1 @@ -135,7 +135,11 @@ $null = New-Module starship { # Disable virtualenv prompt, it breaks starship $ENV:VIRTUAL_ENV_DISABLE_PROMPT=1 - $ENV:STARSHIP_SHELL = "powershell" + if ($PSVersionTable.PSVersion.Major -gt 5) { + $ENV:STARSHIP_SHELL = "pwsh" + } else { + $ENV:STARSHIP_SHELL = "powershell" + } # Set up the session key that will be used to store logs $ENV:STARSHIP_SESSION_KEY = -join ((48..57) + (65..90) + (97..122) | Get-Random -Count 16 | ForEach-Object { [char]$_ })