fix(cursor): allow disabling cursor positioning

resolves #4072
This commit is contained in:
Jan De Dobbeleer 2023-07-24 19:07:16 +02:00 committed by Jan De Dobbeleer
parent f47da9592f
commit 0af3029cf1
5 changed files with 43 additions and 35 deletions

View file

@ -70,8 +70,8 @@ func runInit(shellName string) {
shell.ShellIntegration = cfg.ShellIntegration
for i, block := range cfg.Blocks {
// only fetch cursor position when relevant
if i == 0 && block.Newline {
shell.Cursor = true
if !cfg.DisableCursorPositioning && (i == 0 && block.Newline) {
shell.CursorPositioning = true
}
if block.Type == engine.RPrompt {
shell.RPrompt = true

View file

@ -34,24 +34,25 @@ const (
// Config holds all the theme for rendering the prompt
type Config struct {
Version int `json:"version"`
FinalSpace bool `json:"final_space,omitempty"`
ConsoleTitleTemplate string `json:"console_title_template,omitempty"`
TerminalBackground string `json:"terminal_background,omitempty"`
AccentColor string `json:"accent_color,omitempty"`
Blocks []*Block `json:"blocks,omitempty"`
Tooltips []*Segment `json:"tooltips,omitempty"`
TransientPrompt *Segment `json:"transient_prompt,omitempty"`
ValidLine *Segment `json:"valid_line,omitempty"`
ErrorLine *Segment `json:"error_line,omitempty"`
SecondaryPrompt *Segment `json:"secondary_prompt,omitempty"`
DebugPrompt *Segment `json:"debug_prompt,omitempty"`
Palette ansi.Palette `json:"palette,omitempty"`
Palettes *ansi.Palettes `json:"palettes,omitempty"`
Cycle ansi.Cycle `json:"cycle,omitempty"`
ShellIntegration bool `json:"shell_integration,omitempty"`
PWD string `json:"pwd,omitempty"`
Var map[string]interface{} `json:"var,omitempty"`
Version int `json:"version"`
FinalSpace bool `json:"final_space,omitempty"`
ConsoleTitleTemplate string `json:"console_title_template,omitempty"`
TerminalBackground string `json:"terminal_background,omitempty"`
AccentColor string `json:"accent_color,omitempty"`
Blocks []*Block `json:"blocks,omitempty"`
Tooltips []*Segment `json:"tooltips,omitempty"`
TransientPrompt *Segment `json:"transient_prompt,omitempty"`
ValidLine *Segment `json:"valid_line,omitempty"`
ErrorLine *Segment `json:"error_line,omitempty"`
SecondaryPrompt *Segment `json:"secondary_prompt,omitempty"`
DebugPrompt *Segment `json:"debug_prompt,omitempty"`
Palette ansi.Palette `json:"palette,omitempty"`
Palettes *ansi.Palettes `json:"palettes,omitempty"`
Cycle ansi.Cycle `json:"cycle,omitempty"`
ShellIntegration bool `json:"shell_integration,omitempty"`
PWD string `json:"pwd,omitempty"`
Var map[string]interface{} `json:"var,omitempty"`
DisableCursorPositioning bool `json:"disable_cursor_positioning,omitempty"`
// Deprecated
OSC99 bool `json:"osc99,omitempty"`

View file

@ -46,12 +46,12 @@ const (
)
var (
Transient bool
ErrorLine bool
Tooltips bool
ShellIntegration bool
RPrompt bool
Cursor bool
Transient bool
ErrorLine bool
Tooltips bool
ShellIntegration bool
RPrompt bool
CursorPositioning bool
)
func getExecutablePath(env platform.Environment) (string, error) {
@ -270,7 +270,7 @@ func PrintInit(env platform.Environment) string {
"::TOOLTIPS::", toggleSetting(Tooltips),
"::FTCS_MARKS::", toggleSetting(ShellIntegration),
"::RPROMPT::", strconv.FormatBool(RPrompt),
"::CURSOR::", strconv.FormatBool(Cursor),
"::CURSOR::", strconv.FormatBool(CursorPositioning),
"::UPGRADE::", strconv.FormatBool(hasNotice),
"::UPGRADENOTICE::", notice,
).Replace(script)

View file

@ -3269,6 +3269,12 @@
"description": "https://ohmyposh.dev/docs/configuration/overview#general-settings",
"default": true
},
"disable_cursor_positioning": {
"type": "boolean",
"title": "Disable Cursor Positioning",
"description": "https://ohmyposh.dev/docs/configuration/overview#general-settings",
"default": false
},
"shell_integration": {
"type": "boolean",
"title": "FTCS command marks for shell integration",

View file

@ -126,14 +126,15 @@ For example, the following is a valid `--config` flag:
## General Settings
| Name | Type | Description |
| --------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `final_space` | `boolean` | when true adds a space at the end of the prompt |
| `pwd` | `string` | notify terminal of current working directory, values can be `osc99`, `osc7`, or `osc51` depending on your terminal |
| `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 |
| `accent_color` | `string` | [color][colors] - accent color, used as a fallback when the `accent` [color][accent] is not supported |
| `var` | `map[string]any` | config variables to use in [templates][templates]. Can be any value |
| `shell_integration` | `boolean` | enable shell integration using FinalTerm's OSC sequences. Works in bash, cmd (Clink v1.14.25+), fish, powershell and zsh |
| Name | Type | Description |
| ---------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `final_space` | `boolean` | when true adds a space at the end of the prompt |
| `pwd` | `string` | notify terminal of current working directory, values can be `osc99`, `osc7`, or `osc51` depending on your terminal |
| `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 |
| `accent_color` | `string` | [color][colors] - accent color, used as a fallback when the `accent` [color][accent] is not supported |
| `var` | `map[string]any` | config variables to use in [templates][templates]. Can be any value |
| `shell_integration` | `boolean` | enable shell integration using FinalTerm's OSC sequences. Works in bash, cmd (Clink v1.14.25+), fish, powershell and zsh |
| `disable_cursor_positioning` | `boolean` | disable fetching the cursor position in bash and zsh in case of unwanted side-effects |
### JSON Schema Validation