Skip to content

Commit

Permalink
refactor(powershell): use PSDrive path
Browse files Browse the repository at this point in the history
resolves #329
  • Loading branch information
JanDeDobbeleer committed Jan 9, 2021
1 parent c7bbed1 commit 780722a
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 292 deletions.
3 changes: 2 additions & 1 deletion packages/powershell/oh-my-posh/oh-my-posh.psm1
Expand Up @@ -77,7 +77,8 @@ function Set-PoshPrompt {
$startInfo.FileName = Get-PoshCommand
$config = $global:PoshSettings.Theme
$cleanPWD = $PWD.ProviderPath.TrimEnd("\")
$startInfo.Arguments = "--config=""$config"" --error=$errorCode --pwd=""$cleanPWD"" --execution-time=$executionTime"
$cleanPSWD = $PWD.ToString().TrimEnd("\")
$startInfo.Arguments = "--config=""$config"" --error=$errorCode --pwd=""$cleanPWD"" --pswd=""$cleanPSWD"" --execution-time=$executionTime"
$startInfo.Environment["TERM"] = "xterm-256color"
$startInfo.CreateNoWindow = $true
$startInfo.StandardOutputEncoding = [System.Text.Encoding]::UTF8
Expand Down
3 changes: 2 additions & 1 deletion src/init/omp.ps1
Expand Up @@ -41,7 +41,8 @@ function Set-GitStatus {
$startInfo.FileName = "::OMP::"
$config = $global:PoshSettings.Theme
$cleanPWD = $PWD.ProviderPath.TrimEnd("\")
$startInfo.Arguments = "--config=""$config"" --error=$errorCode --pwd=""$cleanPWD"" --execution-time=$executionTime"
$cleanPSWD = $PWD.ToString().TrimEnd("\")
$startInfo.Arguments = "--config=""$config"" --error=$errorCode --pwd=""$cleanPWD"" --pswd=""$cleanPSWD"" --execution-time=$executionTime"
$startInfo.Environment["TERM"] = "xterm-256color"
$startInfo.CreateNoWindow = $true
$startInfo.StandardOutputEncoding = [System.Text.Encoding]::UTF8
Expand Down
7 changes: 5 additions & 2 deletions src/main.go
Expand Up @@ -30,6 +30,7 @@ type args struct {
Config *string
Shell *string
PWD *string
PSWD *string
Version *bool
Debug *bool
ExecutionTime *float64
Expand Down Expand Up @@ -65,6 +66,10 @@ func main() {
"pwd",
"",
"the path you are working in"),
PSWD: flag.String(
"pswd",
"",
"the powershell path you are working in, useful when working with drives"),
Version: flag.Bool(
"version",
false,
Expand Down Expand Up @@ -98,7 +103,6 @@ func main() {
env := &environment{
args: args,
commands: make(map[string]string),
cwd: *args.PWD,
}
if *args.Millis {
fmt.Print(time.Now().UnixNano() / 1000000)
Expand Down Expand Up @@ -131,7 +135,6 @@ func main() {

formats := &ansiFormats{}
formats.init(env.getShellName())

renderer := &AnsiRenderer{
formats: formats,
}
Expand Down
7 changes: 4 additions & 3 deletions src/segment_path.go
Expand Up @@ -119,12 +119,13 @@ func (pt *path) getFolderPath() string {
}

func (pt *path) getPwd() string {
pwd := pt.env.getcwd()

pwd := *pt.env.getArgs().PSWD
if pwd == "" {
pwd = pt.env.getcwd()
}
if pt.props.getBool(MappedLocationsEnabled, true) {
pwd = pt.replaceMappedLocations(pwd)
}

return pwd
}

Expand Down

0 comments on commit 780722a

Please sign in to comment.