refactor(prompt): explicitly enable cursor positioning

This commit is contained in:
Jan De Dobbeleer 2024-07-06 20:47:47 +02:00 committed by Jan De Dobbeleer
parent a2ee64f3b9
commit b103581ed6
4 changed files with 39 additions and 39 deletions

View file

@ -77,7 +77,7 @@ func runInit(shellName string) {
for i, block := range cfg.Blocks { for i, block := range cfg.Blocks {
// only fetch cursor position when relevant // only fetch cursor position when relevant
if !cfg.DisableCursorPositioning && (i == 0 && block.Newline) { if cfg.EnableCursorPositioning && (i == 0 && block.Newline) {
shell.CursorPositioning = true shell.CursorPositioning = true
} }

View file

@ -17,29 +17,29 @@ const (
// Config holds all the theme for rendering the prompt // Config holds all the theme for rendering the prompt
type Config struct { type Config struct {
Version int `json:"version" toml:"version"` Version int `json:"version" toml:"version"`
FinalSpace bool `json:"final_space,omitempty" toml:"final_space,omitempty"` FinalSpace bool `json:"final_space,omitempty" toml:"final_space,omitempty"`
ConsoleTitleTemplate string `json:"console_title_template,omitempty" toml:"console_title_template,omitempty"` ConsoleTitleTemplate string `json:"console_title_template,omitempty" toml:"console_title_template,omitempty"`
TerminalBackground color.Ansi `json:"terminal_background,omitempty" toml:"terminal_background,omitempty"` TerminalBackground color.Ansi `json:"terminal_background,omitempty" toml:"terminal_background,omitempty"`
AccentColor color.Ansi `json:"accent_color,omitempty" toml:"accent_color,omitempty"` AccentColor color.Ansi `json:"accent_color,omitempty" toml:"accent_color,omitempty"`
Blocks []*Block `json:"blocks,omitempty" toml:"blocks,omitempty"` Blocks []*Block `json:"blocks,omitempty" toml:"blocks,omitempty"`
Tooltips []*Segment `json:"tooltips,omitempty" toml:"tooltips,omitempty"` Tooltips []*Segment `json:"tooltips,omitempty" toml:"tooltips,omitempty"`
TransientPrompt *Segment `json:"transient_prompt,omitempty" toml:"transient_prompt,omitempty"` TransientPrompt *Segment `json:"transient_prompt,omitempty" toml:"transient_prompt,omitempty"`
ValidLine *Segment `json:"valid_line,omitempty" toml:"valid_line,omitempty"` ValidLine *Segment `json:"valid_line,omitempty" toml:"valid_line,omitempty"`
ErrorLine *Segment `json:"error_line,omitempty" toml:"error_line,omitempty"` ErrorLine *Segment `json:"error_line,omitempty" toml:"error_line,omitempty"`
SecondaryPrompt *Segment `json:"secondary_prompt,omitempty" toml:"secondary_prompt,omitempty"` SecondaryPrompt *Segment `json:"secondary_prompt,omitempty" toml:"secondary_prompt,omitempty"`
DebugPrompt *Segment `json:"debug_prompt,omitempty" toml:"debug_prompt,omitempty"` DebugPrompt *Segment `json:"debug_prompt,omitempty" toml:"debug_prompt,omitempty"`
Palette color.Palette `json:"palette,omitempty" toml:"palette,omitempty"` Palette color.Palette `json:"palette,omitempty" toml:"palette,omitempty"`
Palettes *color.Palettes `json:"palettes,omitempty" toml:"palettes,omitempty"` Palettes *color.Palettes `json:"palettes,omitempty" toml:"palettes,omitempty"`
Cycle color.Cycle `json:"cycle,omitempty" toml:"cycle,omitempty"` Cycle color.Cycle `json:"cycle,omitempty" toml:"cycle,omitempty"`
ShellIntegration bool `json:"shell_integration,omitempty" toml:"shell_integration,omitempty"` ShellIntegration bool `json:"shell_integration,omitempty" toml:"shell_integration,omitempty"`
PWD string `json:"pwd,omitempty" toml:"pwd,omitempty"` PWD string `json:"pwd,omitempty" toml:"pwd,omitempty"`
Var map[string]any `json:"var,omitempty" toml:"var,omitempty"` Var map[string]any `json:"var,omitempty" toml:"var,omitempty"`
DisableCursorPositioning bool `json:"disable_cursor_positioning,omitempty" toml:"disable_cursor_positioning,omitempty"` EnableCursorPositioning bool `json:"enable_cursor_positioning,omitempty" toml:"enable_cursor_positioning,omitempty"`
PatchPwshBleed bool `json:"patch_pwsh_bleed,omitempty" toml:"patch_pwsh_bleed,omitempty"` PatchPwshBleed bool `json:"patch_pwsh_bleed,omitempty" toml:"patch_pwsh_bleed,omitempty"`
DisableNotice bool `json:"disable_notice,omitempty" toml:"disable_notice,omitempty"` DisableNotice bool `json:"disable_notice,omitempty" toml:"disable_notice,omitempty"`
AutoUpgrade bool `json:"auto_upgrade,omitempty" toml:"auto_upgrade,omitempty"` AutoUpgrade bool `json:"auto_upgrade,omitempty" toml:"auto_upgrade,omitempty"`
ITermFeatures terminal.ITermFeatures `json:"iterm_features,omitempty" toml:"iterm_features,omitempty"` ITermFeatures terminal.ITermFeatures `json:"iterm_features,omitempty" toml:"iterm_features,omitempty"`
// Deprecated // Deprecated
OSC99 bool `json:"osc99,omitempty" toml:"osc99,omitempty"` OSC99 bool `json:"osc99,omitempty" toml:"osc99,omitempty"`

View file

@ -4721,9 +4721,9 @@
"description": "https://ohmyposh.dev/docs/configuration/general#general-settings", "description": "https://ohmyposh.dev/docs/configuration/general#general-settings",
"default": true "default": true
}, },
"disable_cursor_positioning": { "enable_cursor_positioning": {
"type": "boolean", "type": "boolean",
"title": "Disable Cursor Positioning", "title": "Enable Cursor Positioning",
"description": "https://ohmyposh.dev/docs/configuration/general#general-settings", "description": "https://ohmyposh.dev/docs/configuration/general#general-settings",
"default": false "default": false
}, },

View file

@ -126,19 +126,19 @@ For example, the following is a valid `--config` flag:
## General Settings ## General Settings
| Name | Type | Description | | Name | Type | Description |
| ---------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | --------------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `final_space` | `boolean` | when true adds a space at the end of the prompt | | `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. Supports [templates][templates] | | `pwd` | `string` | notify terminal of current working directory, values can be `osc99`, `osc7` or `osc51` depending on your terminal. Supports [templates][templates] |
| `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 | | `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 | | `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 | | `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 | | `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 | | `enable_cursor_positioning` | `boolean` | enable fetching the cursor position in bash and zsh to allow automatic hiding of leading newlines when at the top of the shell |
| `patch_pwsh_bleed` | `boolean` | patch a PowerShell bug where the background colors bleed into the next line at the end of the buffer (can be removed when [this][pwsh-bleed] is merged) | | `patch_pwsh_bleed` | `boolean` | patch a PowerShell bug where the background colors bleed into the next line at the end of the buffer (can be removed when [this][pwsh-bleed] is merged) |
| `disable_notice` | `boolean` | disables the notice that a new upgrade is available when `auto_upgrade` is disabled, and the notice that no new upgrade is available when `auto_upgrade` is enabled | | `disable_notice` | `boolean` | disables the notice that a new upgrade is available when `auto_upgrade` is disabled, and the notice that no new upgrade is available when `auto_upgrade` is enabled |
| `auto_upgrade` | `boolean` | enable automatic upgrades for Oh My Posh (supports Windows, macOS and Linux) | | `auto_upgrade` | `boolean` | enable automatic upgrades for Oh My Posh (supports Windows, macOS and Linux) |
| `iterm_features` | `[]string` | enable iTerm2 specific features:<ul><li>`prompt_mark`: add the `iterm2_prompt_mark` [function][iterm2-si] for supported shells</li><li>`current_dir`: expose the current directory for iTerm2</li><li>`remote_host`: expose the current remote and user for iTerm2</li></ul> | | `iterm_features` | `[]string` | enable iTerm2 specific features:<ul><li>`prompt_mark`: add the `iterm2_prompt_mark` [function][iterm2-si] for supported shells</li><li>`current_dir`: expose the current directory for iTerm2</li><li>`remote_host`: expose the current remote and user for iTerm2</li></ul> |
### JSON Schema Validation ### JSON Schema Validation