mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-11 03:07:26 -08:00
feat: image background color
This commit is contained in:
parent
6bef088b83
commit
bf51f59ceb
|
@ -667,6 +667,15 @@
|
||||||
"contributions": [
|
"contributions": [
|
||||||
"doc"
|
"doc"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"login": "NickCraver",
|
||||||
|
"name": "Nick Craver",
|
||||||
|
"avatar_url": "https://avatars.githubusercontent.com/u/454813?v=4",
|
||||||
|
"profile": "https://nickcraver.com",
|
||||||
|
"contributions": [
|
||||||
|
"code"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"contributorsPerLine": 7,
|
"contributorsPerLine": 7,
|
||||||
|
|
|
@ -104,6 +104,7 @@ Thanks goes to these wonderful people ([emoji key][acek]):
|
||||||
<td align="center"><a href="http://www.m365princess.com"><img src="https://avatars.githubusercontent.com/u/49960482?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Luise Freese</b></sub></a><br /><a href="#design-LuiseFreese" title="Design">🎨</a></td>
|
<td align="center"><a href="http://www.m365princess.com"><img src="https://avatars.githubusercontent.com/u/49960482?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Luise Freese</b></sub></a><br /><a href="#design-LuiseFreese" title="Design">🎨</a></td>
|
||||||
<td align="center"><a href="https://github.com/asherber"><img src="https://avatars.githubusercontent.com/u/5248041?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Aaron Sherber</b></sub></a><br /><a href="https://github.com/JanDeDobbeleer/oh-my-posh/commits?author=asherber" title="Code">💻</a></td>
|
<td align="center"><a href="https://github.com/asherber"><img src="https://avatars.githubusercontent.com/u/5248041?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Aaron Sherber</b></sub></a><br /><a href="https://github.com/JanDeDobbeleer/oh-my-posh/commits?author=asherber" title="Code">💻</a></td>
|
||||||
<td align="center"><a href="http://SeanKilleen.com"><img src="https://avatars.githubusercontent.com/u/2148318?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sean Killeen</b></sub></a><br /><a href="https://github.com/JanDeDobbeleer/oh-my-posh/commits?author=SeanKilleen" title="Documentation">📖</a></td>
|
<td align="center"><a href="http://SeanKilleen.com"><img src="https://avatars.githubusercontent.com/u/2148318?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sean Killeen</b></sub></a><br /><a href="https://github.com/JanDeDobbeleer/oh-my-posh/commits?author=SeanKilleen" title="Documentation">📖</a></td>
|
||||||
|
<td align="center"><a href="https://nickcraver.com"><img src="https://avatars.githubusercontent.com/u/454813?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nick Craver</b></sub></a><br /><a href="https://github.com/JanDeDobbeleer/oh-my-posh/commits?author=NickCraver" title="Code">💻</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ There are a couple of parameters you can use to tweak the image rendering:
|
||||||
- `CursorPadding`: spaces to add after the cursor indication (`_`)
|
- `CursorPadding`: spaces to add after the cursor indication (`_`)
|
||||||
- `RPromptOffset`: spaces to add **before** a block that's right aligned
|
- `RPromptOffset`: spaces to add **before** a block that's right aligned
|
||||||
- `Author`: the name of the creator, added after `https://ohmyposh.dev`
|
- `Author`: the name of the creator, added after `https://ohmyposh.dev`
|
||||||
|
- `BGColor`: the hex background color to use (e.g. `#222222`)
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="others">
|
<TabItem value="others">
|
||||||
|
@ -49,6 +50,7 @@ There are a couple of additional switches you can use to tweak the image renderi
|
||||||
- `--cursor-padding`: spaces to add after the cursor indication (`_`)
|
- `--cursor-padding`: spaces to add after the cursor indication (`_`)
|
||||||
- `--rprompt-offset`: spaces to add **before** a block that's right aligned
|
- `--rprompt-offset`: spaces to add **before** a block that's right aligned
|
||||||
- `--author`: the name of the creator, added after `https://ohmyposh.dev`
|
- `--author`: the name of the creator, added after `https://ohmyposh.dev`
|
||||||
|
- `--bg-color`: the hex background color to use (e.g. `#222222`)
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
|
@ -8,11 +8,12 @@ const exec = util.promisify(require('child_process').exec);
|
||||||
const themesConfigDir = "./../themes";
|
const themesConfigDir = "./../themes";
|
||||||
const themesStaticDir = "./static/img/themes";
|
const themesStaticDir = "./static/img/themes";
|
||||||
|
|
||||||
function newThemeConfig(rpromptOffset = 40, cursorPadding = 30, author = "") {
|
function newThemeConfig(rpromptOffset = 40, cursorPadding = 30, author = "", bgColor = "#151515") {
|
||||||
var config = {
|
var config = {
|
||||||
rpromptOffset: rpromptOffset,
|
rpromptOffset: rpromptOffset,
|
||||||
cursorPadding: cursorPadding,
|
cursorPadding: cursorPadding,
|
||||||
author: author
|
author: author,
|
||||||
|
bgColor: bgColor
|
||||||
};
|
};
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
@ -69,6 +70,7 @@ themeConfigOverrrides.set('zash.omp.json', newThemeConfig(40, 40));
|
||||||
let poshCommand = `oh-my-posh --config=${configPath} --shell shell --export-png`;
|
let poshCommand = `oh-my-posh --config=${configPath} --shell shell --export-png`;
|
||||||
poshCommand += ` --rprompt-offset=${config.rpromptOffset}`;
|
poshCommand += ` --rprompt-offset=${config.rpromptOffset}`;
|
||||||
poshCommand += ` --cursor-padding=${config.cursorPadding}`;
|
poshCommand += ` --cursor-padding=${config.cursorPadding}`;
|
||||||
|
poshCommand += ` --bg-color=${config.cursorPadding}`;
|
||||||
if (config.author !== '') {
|
if (config.author !== '') {
|
||||||
poshCommand += ` --author=${config.author}`;
|
poshCommand += ` --author=${config.author}`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,7 @@ type ImageRenderer struct {
|
||||||
ansiString string
|
ansiString string
|
||||||
author string
|
author string
|
||||||
ansi *ansiUtils
|
ansi *ansiUtils
|
||||||
|
bgColor string
|
||||||
|
|
||||||
factor float64
|
factor float64
|
||||||
|
|
||||||
|
@ -285,7 +286,7 @@ func (ir *ImageRenderer) SavePNG(path string) error {
|
||||||
// Draw rounded rectangle with outline and three button to produce the
|
// Draw rounded rectangle with outline and three button to produce the
|
||||||
// impression of a window with controls and a content area
|
// impression of a window with controls and a content area
|
||||||
dc.DrawRoundedRectangle(xOffset, yOffset, width-2*marginX, height-2*marginY, corner)
|
dc.DrawRoundedRectangle(xOffset, yOffset, width-2*marginX, height-2*marginY, corner)
|
||||||
dc.SetHexColor("#151515")
|
dc.SetHexColor(ir.bgColor)
|
||||||
dc.Fill()
|
dc.Fill()
|
||||||
|
|
||||||
dc.DrawRoundedRectangle(xOffset, yOffset, width-2*marginX, height-2*marginY, corner)
|
dc.DrawRoundedRectangle(xOffset, yOffset, width-2*marginX, height-2*marginY, corner)
|
||||||
|
|
|
@ -185,16 +185,22 @@ function global:Export-PoshImage {
|
||||||
$CursorPadding = 30,
|
$CursorPadding = 30,
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
[string]
|
[string]
|
||||||
$Author
|
$Author,
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[string]
|
||||||
|
$BGColor
|
||||||
)
|
)
|
||||||
|
|
||||||
if ($Author) {
|
if ($Author) {
|
||||||
$Author = "--author=$Author"
|
$Author = "--author=$Author"
|
||||||
}
|
}
|
||||||
|
if ($BGColor) {
|
||||||
|
$BGColor = "--bg-color=$BGColor"
|
||||||
|
}
|
||||||
|
|
||||||
$omp = "::OMP::"
|
$omp = "::OMP::"
|
||||||
$config, $cleanPWD, $cleanPSWD = Get-PoshContext
|
$config, $cleanPWD, $cleanPSWD = Get-PoshContext
|
||||||
$standardOut = @(&$omp --config="$config" --pwd="$cleanPWD" --pswd="$cleanPSWD" --export-png --rprompt-offset="$RPromptOffset" --cursor-padding="$CursorPadding" $Author 2>&1)
|
$standardOut = @(&$omp --config="$config" --pwd="$cleanPWD" --pswd="$cleanPSWD" --export-png --rprompt-offset="$RPromptOffset" --cursor-padding="$CursorPadding" $Author $BGColor 2>&1)
|
||||||
$standardOut -join "`n"
|
$standardOut -join "`n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ type args struct {
|
||||||
Author *string
|
Author *string
|
||||||
CursorPadding *int
|
CursorPadding *int
|
||||||
RPromptOffset *int
|
RPromptOffset *int
|
||||||
|
BGColor *string
|
||||||
StackCount *int
|
StackCount *int
|
||||||
Command *string
|
Command *string
|
||||||
PrintTransient *bool
|
PrintTransient *bool
|
||||||
|
@ -139,6 +140,10 @@ func main() {
|
||||||
"rprompt-offset",
|
"rprompt-offset",
|
||||||
40,
|
40,
|
||||||
"Offset the right prompt with x when using --export-img"),
|
"Offset the right prompt with x when using --export-img"),
|
||||||
|
BGColor: flag.String(
|
||||||
|
"bg-color",
|
||||||
|
"#151515",
|
||||||
|
"Set the background color when using --export-img"),
|
||||||
StackCount: flag.Int(
|
StackCount: flag.Int(
|
||||||
"stack-count",
|
"stack-count",
|
||||||
0,
|
0,
|
||||||
|
@ -224,6 +229,7 @@ func main() {
|
||||||
author: *args.Author,
|
author: *args.Author,
|
||||||
cursorPadding: *args.CursorPadding,
|
cursorPadding: *args.CursorPadding,
|
||||||
rPromptOffset: *args.RPromptOffset,
|
rPromptOffset: *args.RPromptOffset,
|
||||||
|
bgColor: *args.BGColor,
|
||||||
ansi: ansi,
|
ansi: ansi,
|
||||||
}
|
}
|
||||||
imageCreator.init()
|
imageCreator.init()
|
||||||
|
|
Loading…
Reference in a new issue