mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 20:09:39 -08:00
parent
de498044c9
commit
9b137827e1
|
@ -339,14 +339,7 @@ available options first, by starting with the [configuration guide][configuratio
|
|||
You can output the current theme to its `JSON` representation which can be used to tweak and store as your custom theme.
|
||||
|
||||
```powershell
|
||||
Write-PoshTheme
|
||||
```
|
||||
|
||||
Due to a bug in PowerShell, if you want to use `Out-File` directly to write the current theme to a new file, use the `oem`
|
||||
encoding to ensure the symbols are outputted correctly.
|
||||
|
||||
```powershell
|
||||
Write-PoshTheme | Out-File -FilePath ~/.mytheme.omp.json -Encoding oem
|
||||
Export-PoshTheme -FilePath ~/.mytheme.omp.json
|
||||
```
|
||||
|
||||
Once you're done editing, adjust your `$PROFILE` to use your newly created theme.
|
||||
|
|
|
@ -61,7 +61,7 @@ If you see one you like, set it, then export its config so you can customize/ext
|
|||
|
||||
```powershell
|
||||
Set-PoshPrompt -Theme jandedobbeleer
|
||||
Write-PoshTheme | Out-File -FilePath ~/.go-my-posh.json -Encoding oem
|
||||
Export-PoshTheme | Out-File -FilePath ~/.go-my-posh.json -Encoding oem
|
||||
```
|
||||
|
||||
Adjust the config (`~/.go-my-posh.json`) to your liking by going through the [configuration][configuration] guide.
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
# Aliases to export from this module
|
||||
AliasesToExport = '*'
|
||||
# Functions to export from this module
|
||||
FunctionsToExport = @('Get-PoshThemes', 'Set-PoshPrompt', 'Write-PoshTheme', 'Set-PoshContext', 'Get-PoshInfoForV2Users')
|
||||
FunctionsToExport = @('Get-PoshThemes', 'Set-PoshPrompt', 'Export-PoshTheme', 'Set-PoshContext', 'Get-PoshInfoForV2Users')
|
||||
# Private data to pass to the module specified in RootModule. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
|
||||
PrivateData = @{
|
||||
PSData = @{
|
||||
|
|
|
@ -92,10 +92,21 @@ function Get-PoshThemes {
|
|||
Write-Host ("=" * $consoleWidth)
|
||||
}
|
||||
|
||||
function Write-PoshTheme {
|
||||
function Export-PoshTheme {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]
|
||||
$FilePath
|
||||
)
|
||||
|
||||
$config = $global:PoshSettings.Theme
|
||||
$poshCommand = Get-PoshCommand
|
||||
& $poshCommand -config $config -print-config
|
||||
# Save current encoding and swap for UTF8
|
||||
$originalOutputEncoding = [Console]::OutputEncoding
|
||||
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
||||
& $poshCommand -config $config -print-config | Out-File -FilePath $FilePath
|
||||
# Restore initial encoding
|
||||
[Console]::OutputEncoding = $originalOutputEncoding
|
||||
}
|
||||
|
||||
# Helper function to create argument completion results
|
||||
|
|
Loading…
Reference in a new issue