mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-10 04:54:03 -08:00
feat: set console title option
This commit is contained in:
parent
c23a1d6e1c
commit
1086a48d91
|
@ -47,9 +47,8 @@ which you can find [here][nf].
|
|||
|
||||
## General Settings
|
||||
|
||||
At the top you can see `final_space`. This tells the engine to add a space at the end of the prompt once all blocks and
|
||||
segments are rendered. This is useful when there's conditional logic that shows or hides segments at the end of your
|
||||
prompt. That way you don't have to worry about how to handle that space at the end.
|
||||
- final_space: `boolean` - when true adds a space at the end of the prompt
|
||||
- console_title: `boolean` - when true sets the current location as the console title
|
||||
|
||||
> "I Like The Way You Speak Words" - Gary Goodspeed
|
||||
|
||||
|
|
|
@ -126,6 +126,9 @@ func (e *engine) render() {
|
|||
fmt.Print(e.renderBlockSegments(block))
|
||||
}
|
||||
}
|
||||
if e.settings.ConsoleTitle {
|
||||
e.renderer.setConsoleTitle(e.env.getcwd())
|
||||
}
|
||||
if e.settings.FinalSpace {
|
||||
fmt.Print(" ")
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ type formats struct {
|
|||
left string
|
||||
right string
|
||||
rANSI string
|
||||
title string
|
||||
}
|
||||
|
||||
//Shell indicates the shell we're currently in
|
||||
|
@ -51,6 +52,7 @@ func (r *Renderer) init(shell string) {
|
|||
r.formats.linechange = "%%{\x1b[%d%s%%}"
|
||||
r.formats.left = "%%{\x1b[%dC%%}"
|
||||
r.formats.right = "%%{\x1b[%dD%%}"
|
||||
r.formats.title = "%%{\033]0;%s\007%%}"
|
||||
r.shell = zsh
|
||||
default:
|
||||
r.formats.single = "\x1b[%sm%s\x1b[0m"
|
||||
|
@ -60,6 +62,7 @@ func (r *Renderer) init(shell string) {
|
|||
r.formats.linechange = "\x1b[%d%s"
|
||||
r.formats.left = "\x1b[%dC"
|
||||
r.formats.right = "\x1b[%dD"
|
||||
r.formats.title = "\033]0;%s\007"
|
||||
r.shell = universal
|
||||
}
|
||||
}
|
||||
|
@ -142,6 +145,10 @@ func (r *Renderer) changeLine(numberOfLines int) string {
|
|||
return fmt.Sprintf(r.formats.linechange, numberOfLines, position)
|
||||
}
|
||||
|
||||
func (r *Renderer) setConsoleTitle(title string) {
|
||||
fmt.Printf(r.formats.title, title)
|
||||
}
|
||||
|
||||
func (r *Renderer) string() string {
|
||||
return r.Buffer.String()
|
||||
}
|
||||
|
|
|
@ -8,8 +8,9 @@ import (
|
|||
|
||||
//Settings holds all the theme for rendering the prompt
|
||||
type Settings struct {
|
||||
FinalSpace bool `json:"final_space"`
|
||||
Blocks []*Block `json:"blocks"`
|
||||
FinalSpace bool `json:"final_space"`
|
||||
ConsoleTitle bool `json:"console_title"`
|
||||
Blocks []*Block `json:"blocks"`
|
||||
}
|
||||
|
||||
//BlockType type of block
|
||||
|
|
Loading…
Reference in a new issue