Skip to content

Commit

Permalink
feat(pwsh): Set STARSHIP_SHELL to pwsh on PS >5 (starship#3443)
Browse files Browse the repository at this point in the history
* feat(pwsh): Set STARSHIP_SHELL to pwsh ON PS >5

This is needed for the custom module to use the correct shell.

Closes starship#3376

* Update src/context.rs

Co-authored-by: David Knaack <[email protected]>

Co-authored-by: David Knaack <[email protected]>
  • Loading branch information
segevfiner and davidkna authored Jan 16, 2022
1 parent 6aa2bab commit 7e32fd9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion src/init/starship.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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]$_ })
Expand Down

0 comments on commit 7e32fd9

Please sign in to comment.