File tree Expand file tree Collapse file tree 4 files changed +15
-5
lines changed
Expand file tree Collapse file tree 4 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -47,9 +47,8 @@ which you can find [here][nf].
4747
4848## General Settings
4949
50- 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
51- segments are rendered. This is useful when there's conditional logic that shows or hides segments at the end of your
52- prompt. That way you don't have to worry about how to handle that space at the end.
50+ - final_space: ` boolean ` - when true adds a space at the end of the prompt
51+ - console_title: ` boolean ` - when true sets the current location as the console title
5352
5453> "I Like The Way You Speak Words" - Gary Goodspeed
5554
Original file line number Diff line number Diff line change @@ -126,6 +126,9 @@ func (e *engine) render() {
126126 fmt .Print (e .renderBlockSegments (block ))
127127 }
128128 }
129+ if e .settings .ConsoleTitle {
130+ e .renderer .setConsoleTitle (e .env .getcwd ())
131+ }
129132 if e .settings .FinalSpace {
130133 fmt .Print (" " )
131134 }
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ type formats struct {
1919 left string
2020 right string
2121 rANSI string
22+ title string
2223}
2324
2425//Shell indicates the shell we're currently in
@@ -51,6 +52,7 @@ func (r *Renderer) init(shell string) {
5152 r .formats .linechange = "%%{\x1b [%d%s%%}"
5253 r .formats .left = "%%{\x1b [%dC%%}"
5354 r .formats .right = "%%{\x1b [%dD%%}"
55+ r .formats .title = "%%{\033 ]0;%s\007 %%}"
5456 r .shell = zsh
5557 default :
5658 r .formats .single = "\x1b [%sm%s\x1b [0m"
@@ -60,6 +62,7 @@ func (r *Renderer) init(shell string) {
6062 r .formats .linechange = "\x1b [%d%s"
6163 r .formats .left = "\x1b [%dC"
6264 r .formats .right = "\x1b [%dD"
65+ r .formats .title = "\033 ]0;%s\007 "
6366 r .shell = universal
6467 }
6568}
@@ -142,6 +145,10 @@ func (r *Renderer) changeLine(numberOfLines int) string {
142145 return fmt .Sprintf (r .formats .linechange , numberOfLines , position )
143146}
144147
148+ func (r * Renderer ) setConsoleTitle (title string ) {
149+ fmt .Printf (r .formats .title , title )
150+ }
151+
145152func (r * Renderer ) string () string {
146153 return r .Buffer .String ()
147154}
Original file line number Diff line number Diff line change 88
99//Settings holds all the theme for rendering the prompt
1010type Settings struct {
11- FinalSpace bool `json:"final_space"`
12- Blocks []* Block `json:"blocks"`
11+ FinalSpace bool `json:"final_space"`
12+ ConsoleTitle bool `json:"console_title"`
13+ Blocks []* Block `json:"blocks"`
1314}
1415
1516//BlockType type of block
You can’t perform that action at this time.
0 commit comments