mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
parent
fb83354186
commit
3fd70ce716
|
@ -123,8 +123,6 @@ The configuration has the following properties:
|
||||||
- foreground: `string` [color][colors]
|
- foreground: `string` [color][colors]
|
||||||
- template: `string` - A go [text/template][go-text-template] template extended with [sprig][sprig] utilizing the
|
- template: `string` - A go [text/template][go-text-template] template extended with [sprig][sprig] utilizing the
|
||||||
properties below. Defaults to `{{ .Shell }}> <#f7dc66>{{ .Command }}</>`
|
properties below. Defaults to `{{ .Shell }}> <#f7dc66>{{ .Command }}</>`
|
||||||
- vertical_offset: `int` - Move the prompt up or down x lines. For example `vertical_offset: 1` moves the prompt down one line, `vertical_offset: -1`
|
|
||||||
moves it up one line. Useful when you have a multiline prompt. Defaults to `0`
|
|
||||||
|
|
||||||
#### Template Properties
|
#### Template Properties
|
||||||
|
|
||||||
|
|
|
@ -32,10 +32,9 @@ type Config struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type TransientPrompt struct {
|
type TransientPrompt struct {
|
||||||
Template string `config:"template"`
|
Template string `config:"template"`
|
||||||
Background string `config:"background"`
|
Background string `config:"background"`
|
||||||
Foreground string `config:"foreground"`
|
Foreground string `config:"foreground"`
|
||||||
VerticalOffset int `config:"vertical_offset"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -232,8 +232,15 @@ func (e *engine) renderTransientPrompt(command string) string {
|
||||||
prompt := template.renderPlainContextTemplate(context)
|
prompt := template.renderPlainContextTemplate(context)
|
||||||
e.colorWriter.write(e.config.TransientPrompt.Background, e.config.TransientPrompt.Foreground, prompt)
|
e.colorWriter.write(e.config.TransientPrompt.Background, e.config.TransientPrompt.Foreground, prompt)
|
||||||
transientPrompt := e.ansi.carriageBackward()
|
transientPrompt := e.ansi.carriageBackward()
|
||||||
if e.config.TransientPrompt.VerticalOffset != 0 {
|
// calculate offset for multiline prompt
|
||||||
transientPrompt += e.ansi.changeLine(e.config.TransientPrompt.VerticalOffset)
|
lineOffset := 0
|
||||||
|
for _, block := range e.config.Blocks {
|
||||||
|
if block.Newline {
|
||||||
|
lineOffset--
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if lineOffset != 0 {
|
||||||
|
transientPrompt += e.ansi.changeLine(lineOffset)
|
||||||
}
|
}
|
||||||
return transientPrompt + e.colorWriter.string() + e.ansi.clearEOL
|
return transientPrompt + e.colorWriter.string() + e.ansi.clearEOL
|
||||||
}
|
}
|
||||||
|
|
|
@ -1601,11 +1601,6 @@
|
||||||
"title": "Transient Prompt Template",
|
"title": "Transient Prompt Template",
|
||||||
"default": "{{ .Shell }}> <#f7dc66>{{ .Command }}</>"
|
"default": "{{ .Shell }}> <#f7dc66>{{ .Command }}</>"
|
||||||
},
|
},
|
||||||
"vertical_offset": {
|
|
||||||
"type": "integer",
|
|
||||||
"title": "Transient Prompt vertical offset",
|
|
||||||
"default": 0
|
|
||||||
},
|
|
||||||
"background": { "$ref": "#/definitions/color" },
|
"background": { "$ref": "#/definitions/color" },
|
||||||
"foreground": { "$ref": "#/definitions/color" }
|
"foreground": { "$ref": "#/definitions/color" }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue