Skip to content

Commit 9b94059

Browse files
fix: make newline compatible cross shell
When using PowerShell, "\n" isn't recognized as a newline character. To resolve this, moving the cursor down 1 line is more interesting as it will work in any shell using ANSI escape sequences (which we depends upon).
1 parent f3582d2 commit 9b94059

File tree

10 files changed

+11
-11
lines changed

10 files changed

+11
-11
lines changed

Themes/agnosterplus.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
]
1818
},
1919
{
20-
"type": "line-break"
20+
"type": "newline"
2121
},
2222
{
2323
"type": "prompt",

Themes/avit.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
]
5151
},
5252
{
53-
"type": "line-break"
53+
"type": "newline"
5454
},
5555
{
5656
"type": "prompt",

Themes/darkblood.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
]
5959
},
6060
{
61-
"type": "line-break"
61+
"type": "newline"
6262
},
6363
{
6464
"type": "prompt",

Themes/honukai.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
]
6565
},
6666
{
67-
"type": "line-break"
67+
"type": "newline"
6868
},
6969
{
7070
"type": "prompt",

Themes/paradox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
]
7373
},
7474
{
75-
"type": "line-break"
75+
"type": "newline"
7676
},
7777
{
7878
"type": "prompt",

Themes/pararussel.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
]
6464
},
6565
{
66-
"type": "line-break"
66+
"type": "newline"
6767
},
6868
{
6969
"type": "prompt",

Themes/powerlevel10k_lean.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
]
1818
},
1919
{
20-
"type": "line-break"
20+
"type": "newline"
2121
},
2222
{
2323
"type": "prompt",

Themes/star.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
]
5858
},
5959
{
60-
"type": "line-break"
60+
"type": "newline"
6161
},
6262
{
6363
"type": "prompt",

engine.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@ func (e *engine) string() string {
128128
for _, block := range e.settings.Blocks {
129129
// if line break, append a line break
130130
if block.Type == LineBreak {
131-
buffer.WriteString("\n")
131+
buffer.WriteString("\x1b[1B")
132132
continue
133133
}
134134
if block.LineOffset < 0 {
135135
buffer.WriteString(fmt.Sprintf("\x1b[%dF", -block.LineOffset))
136136
} else if block.LineOffset > 0 {
137-
buffer.WriteString(fmt.Sprintf("\x1b[%dE", block.LineOffset))
137+
buffer.WriteString(fmt.Sprintf("\x1b[%dB", block.LineOffset))
138138
}
139139
switch block.Alignment {
140140
case Right:

settings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const (
2626
//Prompt writes one or more Segments
2727
Prompt BlockType = "prompt"
2828
//LineBreak creates a line break in the prompt
29-
LineBreak BlockType = "line-break"
29+
LineBreak BlockType = "newline"
3030
//Left aligns left
3131
Left BlockAlignment = "left"
3232
//Right aligns right

0 commit comments

Comments
 (0)