diff options
author | Jean Gautier <jeanga@users.noreply.github.com> | 2020-04-30 10:40:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-30 10:40:56 +0200 |
commit | 02edad0c66474758d145ac17e36ba28836d1eced (patch) | |
tree | 42d95faef09a390ffa2d063f72c7bb0ef8d101f9 /src/init | |
parent | 4d55936f3514d2e7698ca50dd089b7e7eba4e48f (diff) |
fix(directory): avoid confusing modules with PowerShell paths (#1114)
* Avoid confusing modules with PowerShell paths
* Avoid confusing modules with PowerShell paths
Powershell supports PSDrives (https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/new-psdrive?view=powershell-7) that allow to create "logical" drives mapped to actual Windows drives.
* Preserve Windows directories
* Preserve logical paths for Powershell
* Fix formating with cargo fmt
* Fix directory_in_root test
Co-authored-by: Jean Gautier <jean.gautier@ssi.gouv.fr>
Diffstat (limited to 'src/init')
-rw-r--r-- | src/init/starship.ps1 | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/init/starship.ps1 b/src/init/starship.ps1 index 0ae42c789..15b8a3598 100644 --- a/src/init/starship.ps1 +++ b/src/init/starship.ps1 @@ -7,12 +7,15 @@ function global:prompt { # @ makes sure the result is an array even if single or no values are returned $jobs = @(Get-Job | Where-Object { $_.State -eq 'Running' }).Count + $env:PWD = $PWD + $current_directory = (Convert-Path $PWD) + if ($lastCmd = Get-History -Count 1) { $duration = [math]::Round(($lastCmd.EndExecutionTime - $lastCmd.StartExecutionTime).TotalMilliseconds) # & ensures the path is interpreted as something to execute - $out = @(&::STARSHIP:: prompt "--path=$PWD" --status=$lastexitcode --jobs=$jobs --cmd-duration=$duration) + $out = @(&::STARSHIP:: prompt "--path=$current_directory" --status=$lastexitcode --jobs=$jobs --cmd-duration=$duration) } else { - $out = @(&::STARSHIP:: prompt "--path=$PWD" --status=$lastexitcode --jobs=$jobs) + $out = @(&::STARSHIP:: prompt "--path=$current_directory" --status=$lastexitcode --jobs=$jobs) } # Convert stdout (array of lines) to expected return type string |