Skip to content

Commit 0af3029

Browse files
fix(cursor): allow disabling cursor positioning
resolves JanDeDobbeleer#4072
1 parent f47da95 commit 0af3029

File tree

5 files changed

+43
-35
lines changed

5 files changed

+43
-35
lines changed

src/cli/init.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ func runInit(shellName string) {
7070
shell.ShellIntegration = cfg.ShellIntegration
7171
for i, block := range cfg.Blocks {
7272
// only fetch cursor position when relevant
73-
if i == 0 && block.Newline {
74-
shell.Cursor = true
73+
if !cfg.DisableCursorPositioning && (i == 0 && block.Newline) {
74+
shell.CursorPositioning = true
7575
}
7676
if block.Type == engine.RPrompt {
7777
shell.RPrompt = true

src/engine/config.go

+19-18
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,25 @@ const (
3434

3535
// Config holds all the theme for rendering the prompt
3636
type Config struct {
37-
Version int `json:"version"`
38-
FinalSpace bool `json:"final_space,omitempty"`
39-
ConsoleTitleTemplate string `json:"console_title_template,omitempty"`
40-
TerminalBackground string `json:"terminal_background,omitempty"`
41-
AccentColor string `json:"accent_color,omitempty"`
42-
Blocks []*Block `json:"blocks,omitempty"`
43-
Tooltips []*Segment `json:"tooltips,omitempty"`
44-
TransientPrompt *Segment `json:"transient_prompt,omitempty"`
45-
ValidLine *Segment `json:"valid_line,omitempty"`
46-
ErrorLine *Segment `json:"error_line,omitempty"`
47-
SecondaryPrompt *Segment `json:"secondary_prompt,omitempty"`
48-
DebugPrompt *Segment `json:"debug_prompt,omitempty"`
49-
Palette ansi.Palette `json:"palette,omitempty"`
50-
Palettes *ansi.Palettes `json:"palettes,omitempty"`
51-
Cycle ansi.Cycle `json:"cycle,omitempty"`
52-
ShellIntegration bool `json:"shell_integration,omitempty"`
53-
PWD string `json:"pwd,omitempty"`
54-
Var map[string]interface{} `json:"var,omitempty"`
37+
Version int `json:"version"`
38+
FinalSpace bool `json:"final_space,omitempty"`
39+
ConsoleTitleTemplate string `json:"console_title_template,omitempty"`
40+
TerminalBackground string `json:"terminal_background,omitempty"`
41+
AccentColor string `json:"accent_color,omitempty"`
42+
Blocks []*Block `json:"blocks,omitempty"`
43+
Tooltips []*Segment `json:"tooltips,omitempty"`
44+
TransientPrompt *Segment `json:"transient_prompt,omitempty"`
45+
ValidLine *Segment `json:"valid_line,omitempty"`
46+
ErrorLine *Segment `json:"error_line,omitempty"`
47+
SecondaryPrompt *Segment `json:"secondary_prompt,omitempty"`
48+
DebugPrompt *Segment `json:"debug_prompt,omitempty"`
49+
Palette ansi.Palette `json:"palette,omitempty"`
50+
Palettes *ansi.Palettes `json:"palettes,omitempty"`
51+
Cycle ansi.Cycle `json:"cycle,omitempty"`
52+
ShellIntegration bool `json:"shell_integration,omitempty"`
53+
PWD string `json:"pwd,omitempty"`
54+
Var map[string]interface{} `json:"var,omitempty"`
55+
DisableCursorPositioning bool `json:"disable_cursor_positioning,omitempty"`
5556

5657
// Deprecated
5758
OSC99 bool `json:"osc99,omitempty"`

src/shell/init.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ const (
4646
)
4747

4848
var (
49-
Transient bool
50-
ErrorLine bool
51-
Tooltips bool
52-
ShellIntegration bool
53-
RPrompt bool
54-
Cursor bool
49+
Transient bool
50+
ErrorLine bool
51+
Tooltips bool
52+
ShellIntegration bool
53+
RPrompt bool
54+
CursorPositioning bool
5555
)
5656

5757
func getExecutablePath(env platform.Environment) (string, error) {
@@ -270,7 +270,7 @@ func PrintInit(env platform.Environment) string {
270270
"::TOOLTIPS::", toggleSetting(Tooltips),
271271
"::FTCS_MARKS::", toggleSetting(ShellIntegration),
272272
"::RPROMPT::", strconv.FormatBool(RPrompt),
273-
"::CURSOR::", strconv.FormatBool(Cursor),
273+
"::CURSOR::", strconv.FormatBool(CursorPositioning),
274274
"::UPGRADE::", strconv.FormatBool(hasNotice),
275275
"::UPGRADENOTICE::", notice,
276276
).Replace(script)

themes/schema.json

+6
Original file line numberDiff line numberDiff line change
@@ -3269,6 +3269,12 @@
32693269
"description": "https://ohmyposh.dev/docs/configuration/overview#general-settings",
32703270
"default": true
32713271
},
3272+
"disable_cursor_positioning": {
3273+
"type": "boolean",
3274+
"title": "Disable Cursor Positioning",
3275+
"description": "https://ohmyposh.dev/docs/configuration/overview#general-settings",
3276+
"default": false
3277+
},
32723278
"shell_integration": {
32733279
"type": "boolean",
32743280
"title": "FTCS command marks for shell integration",

website/docs/configuration/overview.mdx

+9-8
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,15 @@ For example, the following is a valid `--config` flag:
126126

127127
## General Settings
128128

129-
| Name | Type | Description |
130-
| --------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
131-
| `final_space` | `boolean` | when true adds a space at the end of the prompt |
132-
| `pwd` | `string` | notify terminal of current working directory, values can be `osc99`, `osc7`, or `osc51` depending on your terminal |
133-
| `terminal_background` | `string` | [color][colors] - terminal background color, set to your terminal's background color when you notice black elements in Windows Terminal or the Visual Studio Code integrated terminal |
134-
| `accent_color` | `string` | [color][colors] - accent color, used as a fallback when the `accent` [color][accent] is not supported |
135-
| `var` | `map[string]any` | config variables to use in [templates][templates]. Can be any value |
136-
| `shell_integration` | `boolean` | enable shell integration using FinalTerm's OSC sequences. Works in bash, cmd (Clink v1.14.25+), fish, powershell and zsh |
129+
| Name | Type | Description |
130+
| ---------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
131+
| `final_space` | `boolean` | when true adds a space at the end of the prompt |
132+
| `pwd` | `string` | notify terminal of current working directory, values can be `osc99`, `osc7`, or `osc51` depending on your terminal |
133+
| `terminal_background` | `string` | [color][colors] - terminal background color, set to your terminal's background color when you notice black elements in Windows Terminal or the Visual Studio Code integrated terminal |
134+
| `accent_color` | `string` | [color][colors] - accent color, used as a fallback when the `accent` [color][accent] is not supported |
135+
| `var` | `map[string]any` | config variables to use in [templates][templates]. Can be any value |
136+
| `shell_integration` | `boolean` | enable shell integration using FinalTerm's OSC sequences. Works in bash, cmd (Clink v1.14.25+), fish, powershell and zsh |
137+
| `disable_cursor_positioning` | `boolean` | disable fetching the cursor position in bash and zsh in case of unwanted side-effects |
137138

138139
### JSON Schema Validation
139140

0 commit comments

Comments
 (0)