Skip to content

Oh-my-posh CWD profile #546

@Pettor

Description

@Pettor

I am using oh-my-posh and would like to add a working CWD configuration to restore directories. I basically use a modified version of the posh-git configuration.

At the top of my PowerShell profile I add the following:

# Load Posh theme
Set-PoshPrompt -Theme robbyrussel

# Store prompt for later
[ScriptBlock]$Prompt = $function:prompt

# Create Prompt function sending CWD to terminal
function prompt {
  $loc = Get-Location

  $prompt = & $Prompt

  $prompt += "$([char]27)]9;12$([char]7)"
  if ($loc.Provider.Name -eq "FileSystem") {
    $prompt += "$([char]27)]9;9;`"$($loc.Path)`"$([char]7)"
  }

  return $prompt
}

Hope this helps 😊


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions