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 <davidkna@users.noreply.github.com>

Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
This commit is contained in:
Segev Finer 2022-01-16 21:28:26 +02:00 committed by GitHub
parent 6aa2bab97e
commit 7e32fd952e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -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,

View File

@ -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]$_ })