feat(iterm): add iTerm features to the root configuration

BREAKING CHANGE: The iTerm segment has been removed and its features
have been added to the root configuration. To re-enable the iTerm
features, remove the iTerm segment and add the following to your
oh-my-posh configuration:

```json
{
  "iterm_features": ["prompt_mark", "current_dir", "remote_host"]
}
```

Choose this option if you want to enable the prompt mark for shell
integration and/or enable current directory and remote host in the
iTerm status bar.
This commit is contained in:
Jan De Dobbeleer 2024-05-19 13:31:19 +02:00 committed by Jan De Dobbeleer
parent 391ceaf5f0
commit e7a10ac029
13 changed files with 248 additions and 255 deletions

View file

@ -114,6 +114,10 @@ type Writer struct {
hyperlinkStart string hyperlinkStart string
hyperlinkCenter string hyperlinkCenter string
hyperlinkEnd string hyperlinkEnd string
iTermPromptMark string
iTermCurrentDir string
iTermRemoteHost string
} }
func (w *Writer) Init(shellName string) { func (w *Writer) Init(shellName string) {
@ -137,6 +141,9 @@ func (w *Writer) Init(shellName string) {
w.osc99 = "\\[\x1b]9;9;%s\x1b\\\\\\]" w.osc99 = "\\[\x1b]9;9;%s\x1b\\\\\\]"
w.osc7 = "\\[\x1b]7;file://%s/%s\x1b\\\\\\]" w.osc7 = "\\[\x1b]7;file://%s/%s\x1b\\\\\\]"
w.osc51 = "\\[\x1b]51;A;%s@%s:%s\x1b\\\\\\]" w.osc51 = "\\[\x1b]51;A;%s@%s:%s\x1b\\\\\\]"
w.iTermPromptMark = "\\[$(iterm2_prompt_mark)\\]"
w.iTermCurrentDir = "\\[\x1b]1337;CurrentDir=%s\x07\\]"
w.iTermRemoteHost = "\\[\x1b]1337;RemoteHost=%s@%s\x07\\]"
case shell.ZSH, shell.TCSH: case shell.ZSH, shell.TCSH:
w.format = "%%{%s%%}" w.format = "%%{%s%%}"
w.linechange = "%%{\x1b[%d%s%%}" w.linechange = "%%{\x1b[%d%s%%}"
@ -154,6 +161,9 @@ func (w *Writer) Init(shellName string) {
w.osc99 = "%%{\x1b]9;9;%s\x1b\\%%}" w.osc99 = "%%{\x1b]9;9;%s\x1b\\%%}"
w.osc7 = "%%{\x1b]7;file://%s/%s\x1b\\%%}" w.osc7 = "%%{\x1b]7;file://%s/%s\x1b\\%%}"
w.osc51 = "%%{\x1b]51;A%s@%s:%s\x1b\\%%}" w.osc51 = "%%{\x1b]51;A%s@%s:%s\x1b\\%%}"
w.iTermPromptMark = "%{$(iterm2_prompt_mark)%}"
w.iTermCurrentDir = "%%{\x1b]1337;CurrentDir=%s\x07%%}"
w.iTermRemoteHost = "%%{\x1b]1337;RemoteHost=%s@%s\x07%%}"
default: default:
w.linechange = "\x1b[%d%s" w.linechange = "\x1b[%d%s"
w.left = "\x1b[%dD" w.left = "\x1b[%dD"
@ -171,6 +181,9 @@ func (w *Writer) Init(shellName string) {
w.osc99 = "\x1b]9;9;%s\x1b\\" w.osc99 = "\x1b]9;9;%s\x1b\\"
w.osc7 = "\x1b]7;file://%s/%s\x1b\\" w.osc7 = "\x1b]7;file://%s/%s\x1b\\"
w.osc51 = "\x1b]51;A%s@%s:%s\x1b\\" w.osc51 = "\x1b]51;A%s@%s:%s\x1b\\"
w.iTermPromptMark = "$(iterm2_prompt_mark)"
w.iTermCurrentDir = "\x1b]1337;CurrentDir=%s\x07"
w.iTermRemoteHost = "\x1b]1337;RemoteHost=%s@%s\x07"
} }
} }

32
src/ansi/iterm.go Normal file
View file

@ -0,0 +1,32 @@
package ansi
import (
"fmt"
"strings"
)
type iTermFeature string
const (
PromptMark iTermFeature = "prompt_mark"
CurrentDir iTermFeature = "current_dir"
RemoteHost iTermFeature = "remote_host"
)
type ITermFeatures []iTermFeature
func (w *Writer) RenderItermFeatures(features ITermFeatures, pwd, user, host string) string {
var result strings.Builder
for _, feature := range features {
switch feature {
case PromptMark:
result.WriteString(w.iTermPromptMark)
case CurrentDir:
result.WriteString(fmt.Sprintf(w.iTermCurrentDir, pwd))
case RemoteHost:
result.WriteString(fmt.Sprintf(w.iTermRemoteHost, user, host))
}
}
return result.String()
}

View file

@ -31,27 +31,28 @@ 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 string `json:"terminal_background,omitempty" toml:"terminal_background,omitempty"` TerminalBackground string `json:"terminal_background,omitempty" toml:"terminal_background,omitempty"`
AccentColor string `json:"accent_color,omitempty" toml:"accent_color,omitempty"` AccentColor string `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 ansi.Palette `json:"palette,omitempty" toml:"palette,omitempty"` Palette ansi.Palette `json:"palette,omitempty" toml:"palette,omitempty"`
Palettes *ansi.Palettes `json:"palettes,omitempty" toml:"palettes,omitempty"` Palettes *ansi.Palettes `json:"palettes,omitempty" toml:"palettes,omitempty"`
Cycle ansi.Cycle `json:"cycle,omitempty" toml:"cycle,omitempty"` Cycle ansi.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"` DisableCursorPositioning bool `json:"disable_cursor_positioning,omitempty" toml:"disable_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"`
ITermFeatures ansi.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

@ -132,6 +132,10 @@ func (e *Engine) isWarp() bool {
return e.Env.Getenv("TERM_PROGRAM") == "WarpTerminal" return e.Env.Getenv("TERM_PROGRAM") == "WarpTerminal"
} }
func (e *Engine) isIterm() bool {
return e.Env.Getenv("TERM_PROGRAM") == "iTerm.app"
}
func (e *Engine) shouldFill(filler string, remaining, blockLength int) (string, bool) { func (e *Engine) shouldFill(filler string, remaining, blockLength int) (string, bool) {
if len(filler) == 0 { if len(filler) == 0 {
return "", false return "", false

View file

@ -68,6 +68,11 @@ func (e *Engine) Primary() string {
e.currentLineLength++ e.currentLineLength++
} }
if e.Config.ITermFeatures != nil && e.isIterm() {
host, _ := e.Env.Host()
e.write(e.Writer.RenderItermFeatures(e.Config.ITermFeatures, e.Env.Pwd(), e.Env.User(), host))
}
if e.Config.ShellIntegration && e.Config.TransientPrompt == nil { if e.Config.ShellIntegration && e.Config.TransientPrompt == nil {
e.write(e.Writer.CommandStart()) e.write(e.Writer.CommandStart())
} }

View file

@ -160,8 +160,6 @@ const (
HELM SegmentType = "helm" HELM SegmentType = "helm"
// IPIFY segment // IPIFY segment
IPIFY SegmentType = "ipify" IPIFY SegmentType = "ipify"
// ITERM inserts the Shell Integration prompt mark on iTerm zsh/bash/fish
ITERM SegmentType = "iterm"
// JAVA writes the active java version // JAVA writes the active java version
JAVA SegmentType = "java" JAVA SegmentType = "java"
// JULIA writes which julia version is currently active // JULIA writes which julia version is currently active
@ -307,7 +305,6 @@ var Segments = map[SegmentType]func() SegmentWriter{
HASKELL: func() SegmentWriter { return &segments.Haskell{} }, HASKELL: func() SegmentWriter { return &segments.Haskell{} },
HELM: func() SegmentWriter { return &segments.Helm{} }, HELM: func() SegmentWriter { return &segments.Helm{} },
IPIFY: func() SegmentWriter { return &segments.IPify{} }, IPIFY: func() SegmentWriter { return &segments.IPify{} },
ITERM: func() SegmentWriter { return &segments.ITerm{} },
JAVA: func() SegmentWriter { return &segments.Java{} }, JAVA: func() SegmentWriter { return &segments.Java{} },
JULIA: func() SegmentWriter { return &segments.Julia{} }, JULIA: func() SegmentWriter { return &segments.Julia{} },
KOTLIN: func() SegmentWriter { return &segments.Kotlin{} }, KOTLIN: func() SegmentWriter { return &segments.Kotlin{} },

View file

@ -200,6 +200,7 @@ type Shell struct {
Var SimpleMap Var SimpleMap
cwd string cwd string
host string
cmdCache *commandCache cmdCache *commandCache
fileCache *fileCache fileCache *fileCache
tmplCache *TemplateCache tmplCache *TemplateCache
@ -496,13 +497,20 @@ func (env *Shell) User() string {
func (env *Shell) Host() (string, error) { func (env *Shell) Host() (string, error) {
defer env.Trace(time.Now()) defer env.Trace(time.Now())
if len(env.host) != 0 {
return env.host, nil
}
hostName, err := os.Hostname() hostName, err := os.Hostname()
if err != nil { if err != nil {
env.Error(err) env.Error(err)
return "", err return "", err
} }
hostName = cleanHostName(hostName) hostName = cleanHostName(hostName)
env.Debug(hostName) env.Debug(hostName)
env.host = hostName
return hostName, nil return hostName, nil
} }

View file

@ -1,69 +0,0 @@
package segments
import (
"fmt"
"github.com/jandedobbeleer/oh-my-posh/src/platform"
"github.com/jandedobbeleer/oh-my-posh/src/properties"
"github.com/jandedobbeleer/oh-my-posh/src/shell"
)
type ITerm struct {
props properties.Properties
env platform.Environment
}
func (i *ITerm) Template() string {
return "{{ .PromptMark }}"
}
func (i *ITerm) Enabled() bool {
return i.env.Getenv("TERM_PROGRAM") == "iTerm.app"
}
func (i *ITerm) PromptMark() string {
// Check to ensure the user has squelched the default mark for BASH and ZSH
if i.env.Getenv("ITERM2_SQUELCH_MARK") != "1" {
i.env.Debug("iTerm default mark enabled, adjust using export ITERM2_SQUELCH_MARK=1")
return ""
}
sh := i.env.Shell()
if sh != shell.ZSH && sh != shell.BASH {
i.env.Debug("Shell is not ZSH or BASH, cannot set prompt mark")
return ""
}
return i.format("$(iterm2_prompt_mark)")
}
func (i *ITerm) CurrentDir() string {
dir := fmt.Sprintf("\x1b]1337;CurrentDir=%s\x07", i.env.Pwd())
return i.format(dir)
}
func (i *ITerm) RemoteHost() string {
host, err := i.env.Host()
if err != nil {
return ""
}
remoteHost := fmt.Sprintf("\x1b]1337;RemoteHost=%s@%s\x07", i.env.User(), host)
return i.format(remoteHost)
}
func (i *ITerm) format(input string) string {
switch i.env.Shell() {
case shell.ZSH:
return fmt.Sprintf(`%%{%s%%}`, input)
case shell.BASH:
return fmt.Sprintf(`\[%s\]`, input)
default:
return input
}
}
func (i *ITerm) Init(props properties.Properties, env platform.Environment) {
i.props = props
i.env = env
}

View file

@ -1,46 +0,0 @@
package segments
import (
"testing"
"github.com/jandedobbeleer/oh-my-posh/src/mock"
"github.com/stretchr/testify/assert"
mock2 "github.com/stretchr/testify/mock"
)
func TestITermSegment(t *testing.T) {
cases := []struct {
Case string
TermProgram string
SquelchMark string
Shell string
Template string
ExpectedString string
ExpectedDisabled bool
}{
{Case: "not iterm", TermProgram: "", SquelchMark: "1", Shell: "zsh", ExpectedDisabled: true},
{Case: "default mark", TermProgram: "iTerm.app", Shell: "zsh", Template: "{{ .PromptMark }}", ExpectedDisabled: false},
{Case: "zsh", TermProgram: "iTerm.app", SquelchMark: "1", Shell: "zsh", Template: "{{ .PromptMark }}", ExpectedString: `%{$(iterm2_prompt_mark)%}`},
{Case: "bash", TermProgram: "iTerm.app", SquelchMark: "1", Shell: "bash", Template: "{{ .PromptMark }}", ExpectedString: `\[$(iterm2_prompt_mark)\]`},
{Case: "fish", TermProgram: "iTerm.app", SquelchMark: "1", Shell: "fish", Template: "{{ .PromptMark }}", ExpectedDisabled: false},
{Case: "pwsh", TermProgram: "iTerm.app", SquelchMark: "1", Shell: "pwsh", Template: "{{ .PromptMark }}", ExpectedDisabled: false},
{Case: "gibberishshell", TermProgram: "iTerm.app", SquelchMark: "1", Shell: "jaserhuashf", Template: "{{ .PromptMark }}", ExpectedDisabled: false},
}
for _, tc := range cases {
env := new(mock.MockedEnvironment)
env.On("PathSeparator").Return("/")
env.On("Getenv", "TERM_PROGRAM").Return(tc.TermProgram)
env.On("Getenv", "ITERM2_SQUELCH_MARK").Return(tc.SquelchMark)
env.On("Shell").Return(tc.Shell)
env.On("Error", mock2.Anything).Return()
iterm := &ITerm{
env: env,
}
assert.Equal(t, !tc.ExpectedDisabled, iterm.Enabled(), tc.Case)
if !tc.ExpectedDisabled {
assert.Equal(t, tc.ExpectedString, renderTemplate(env, tc.Template, iterm), tc.Case)
}
}
}

View file

@ -321,7 +321,6 @@
"haskell", "haskell",
"helm", "helm",
"ipify", "ipify",
"iterm",
"julia", "julia",
"java", "java",
"kotlin", "kotlin",
@ -549,7 +548,10 @@
"type": "array", "type": "array",
"title": "Extensions", "title": "Extensions",
"description": "The extensions to look for when determining if a folder is an NPM workspace", "description": "The extensions to look for when determining if a folder is an NPM workspace",
"default": ["package.json", "package-lock.json"], "default": [
"package.json",
"package-lock.json"
],
"items": { "items": {
"type": "string" "type": "string"
} }
@ -631,7 +633,11 @@
"title": "Source", "title": "Source",
"description": "https://ohmyposh.dev/docs/segments/az#properties", "description": "https://ohmyposh.dev/docs/segments/az#properties",
"default": "first_match", "default": "first_match",
"enum": ["first_match", "cli", "pwsh"] "enum": [
"first_match",
"cli",
"pwsh"
]
} }
} }
} }
@ -745,7 +751,11 @@
"type": "array", "type": "array",
"title": "Folders", "title": "Folders",
"description": "The folders to look for when determining if a folder is a Bazel workspace", "description": "The folders to look for when determining if a folder is a Bazel workspace",
"default": ["bazel-bin", "bazel-out", "bazel-testlogs"], "default": [
"bazel-bin",
"bazel-out",
"bazel-testlogs"
],
"items": { "items": {
"type": "string" "type": "string"
} }
@ -791,7 +801,11 @@
"type": "array", "type": "array",
"title": "Extensions", "title": "Extensions",
"description": "The extensions to look for when determining if a folder is a Buf workspace", "description": "The extensions to look for when determining if a folder is a Buf workspace",
"default": ["buf.yaml", "buf.gen.yaml", "buf.work.yaml"], "default": [
"buf.yaml",
"buf.gen.yaml",
"buf.work.yaml"
],
"items": { "items": {
"type": "string" "type": "string"
} }
@ -884,7 +898,12 @@
"type": "string", "type": "string",
"title": "Connection type", "title": "Connection type",
"description": "The connection type to display", "description": "The connection type to display",
"enum": ["ethernet", "wifi", "cellular", "bluetooth"], "enum": [
"ethernet",
"wifi",
"cellular",
"bluetooth"
],
"default": "wifi|ethernet" "default": "wifi|ethernet"
}, },
"unit": { "unit": {
@ -946,7 +965,10 @@
"type": "array", "type": "array",
"title": "Extensions", "title": "Extensions",
"description": "The extensions to look for when determining if a folder is a CMake workspace", "description": "The extensions to look for when determining if a folder is a CMake workspace",
"default": ["*.cmake", "CMakeLists.txt"], "default": [
"*.cmake",
"CMakeLists.txt"
],
"items": { "items": {
"type": "string" "type": "string"
} }
@ -1054,10 +1076,10 @@
"default": false "default": false
}, },
"status_template": { "status_template": {
"type": "string", "type": "string",
"title": "Status Template", "title": "Status Template",
"description": "The template to use for the status segment", "description": "The template to use for the status segment",
"default": "|" "default": "|"
}, },
"status_separator": { "status_separator": {
"type": "string", "type": "string",
@ -1120,7 +1142,9 @@
"type": "array", "type": "array",
"title": "Folders", "title": "Folders",
"description": "The folders to look for when determining if a folder is a Flutter workspace", "description": "The folders to look for when determining if a folder is a Flutter workspace",
"default": [".dart_tool"], "default": [
".dart_tool"
],
"items": { "items": {
"type": "string" "type": "string"
} }
@ -1393,7 +1417,10 @@
"type": "array", "type": "array",
"title": "Extensions", "title": "Extensions",
"description": "The extensions to look for when determining if a folder is a Go workspace", "description": "The extensions to look for when determining if a folder is a Go workspace",
"default": ["*.go", "go.mod"], "default": [
"*.go",
"go.mod"
],
"items": { "items": {
"type": "string" "type": "string"
} }
@ -1456,7 +1483,9 @@
"type": "array", "type": "array",
"title": "Folders", "title": "Folders",
"description": "The folders to look for when determining if a folder is a Dart workspace", "description": "The folders to look for when determining if a folder is a Dart workspace",
"default": [".dart_tool"], "default": [
".dart_tool"
],
"items": { "items": {
"type": "string" "type": "string"
} }
@ -1502,7 +1531,11 @@
"type": "array", "type": "array",
"title": "Extensions", "title": "Extensions",
"description": "The extensions to look for when determining if a folder is a Deno workspace", "description": "The extensions to look for when determining if a folder is a Deno workspace",
"default": ["*.js", "*.ts", "deno.json"], "default": [
"*.js",
"*.ts",
"deno.json"
],
"items": { "items": {
"type": "string" "type": "string"
} }
@ -1551,7 +1584,10 @@
"type": "array", "type": "array",
"title": "Extensions", "title": "Extensions",
"description": "The extensions to look for when determining if a folder is a Crystal workspace", "description": "The extensions to look for when determining if a folder is a Crystal workspace",
"default": ["*.cr", "shard.yml"], "default": [
"*.cr",
"shard.yml"
],
"items": { "items": {
"type": "string" "type": "string"
} }
@ -1600,7 +1636,9 @@
"type": "array", "type": "array",
"title": "Extensions", "title": "Extensions",
"description": "The extensions to look for when determining if a folder is a Julia workspace", "description": "The extensions to look for when determining if a folder is a Julia workspace",
"default": ["*.jl"], "default": [
"*.jl"
],
"items": { "items": {
"type": "string" "type": "string"
} }
@ -1649,7 +1687,12 @@
"type": "array", "type": "array",
"title": "Extensions", "title": "Extensions",
"description": "The extensions to look for when determining if a folder is a Perl workspace", "description": "The extensions to look for when determining if a folder is a Perl workspace",
"default": [".perl-version", "*.pl", "*.pm", "*.t"], "default": [
".perl-version",
"*.pl",
"*.pm",
"*.t"
],
"items": { "items": {
"type": "string" "type": "string"
} }
@ -1812,7 +1855,11 @@
"type": "array", "type": "array",
"title": "Extensions", "title": "Extensions",
"description": "The extensions to look for when determining if a folder is a Ruby workspace", "description": "The extensions to look for when determining if a folder is a Ruby workspace",
"default": ["*.rb", "Rakefile", "Gemfile"] "default": [
"*.rb",
"Rakefile",
"Gemfile"
]
}, },
"folders": { "folders": {
"$ref": "#/definitions/folders" "$ref": "#/definitions/folders"
@ -1858,7 +1905,11 @@
"type": "array", "type": "array",
"title": "Extensions", "title": "Extensions",
"description": "The extensions to look for when determining if a folder is a Rust workspace", "description": "The extensions to look for when determining if a folder is a Rust workspace",
"default": ["*.rs", "Cargo.toml", "Cargo.lock"] "default": [
"*.rs",
"Cargo.toml",
"Cargo.lock"
]
}, },
"folders": { "folders": {
"$ref": "#/definitions/folders" "$ref": "#/definitions/folders"
@ -1904,7 +1955,9 @@
"type": "array", "type": "array",
"title": "Extensions", "title": "Extensions",
"description": "The extensions to look for when determining if a folder is a XMake workspace", "description": "The extensions to look for when determining if a folder is a XMake workspace",
"default": ["xmake.lua"], "default": [
"xmake.lua"
],
"items": { "items": {
"type": "string" "type": "string"
} }
@ -2564,7 +2617,10 @@
"type": "array", "type": "array",
"title": "Extensions", "title": "Extensions",
"description": "The extensions to look for when determining if a folder is a Quasar workspace", "description": "The extensions to look for when determining if a folder is a Quasar workspace",
"default": ["quasar.config", "quasar.config.js"] "default": [
"quasar.config",
"quasar.config.js"
]
}, },
"folders": { "folders": {
"$ref": "#/definitions/folders" "$ref": "#/definitions/folders"
@ -2890,13 +2946,13 @@
"description": "Location to use for the API call interpreted only if valid coordinates aren't given. Formatted as <City>,<STATE>,<COUNTRY_CODE>. City name, state code and country code divided by comma. Please, refer to ISO 3166 for the state codes or country codes.", "description": "Location to use for the API call interpreted only if valid coordinates aren't given. Formatted as <City>,<STATE>,<COUNTRY_CODE>. City name, state code and country code divided by comma. Please, refer to ISO 3166 for the state codes or country codes.",
"default": "De Bilt,NL" "default": "De Bilt,NL"
}, },
"latitude" : { "latitude": {
"type": "number", "type": "number",
"title": "Latitude", "title": "Latitude",
"description": "The latitude of the requested location, valid between -90 and 90", "description": "The latitude of the requested location, valid between -90 and 90",
"default": 91 "default": 91
}, },
"longitude" : { "longitude": {
"type": "number", "type": "number",
"title": "Longitude", "title": "Longitude",
"description": "The longitude of the requested location, valid between -180 and 180", "description": "The longitude of the requested location, valid between -180 and 180",
@ -2907,7 +2963,11 @@
"title": "units", "title": "units",
"description": "Units of measurement. Available values are standard (kelvin), metric (celsius), and imperial (fahrenheit). Default is standard", "description": "Units of measurement. Available values are standard (kelvin), metric (celsius), and imperial (fahrenheit). Default is standard",
"default": "standard", "default": "standard",
"enum": ["standard", "metric", "imperial"] "enum": [
"standard",
"metric",
"imperial"
]
}, },
"http_timeout": { "http_timeout": {
"$ref": "#/definitions/http_timeout" "$ref": "#/definitions/http_timeout"
@ -2956,7 +3016,10 @@
"type": "array", "type": "array",
"title": "Extensions", "title": "Extensions",
"description": "The extensions to look for when determining if a folder is a Elixir workspace", "description": "The extensions to look for when determining if a folder is a Elixir workspace",
"default": ["*.ex", "*.exs"], "default": [
"*.ex",
"*.exs"
],
"items": { "items": {
"type": "string" "type": "string"
} }
@ -3179,7 +3242,9 @@
"type": "array", "type": "array",
"title": "Extensions", "title": "Extensions",
"description": "The extensions to look for when determining if the current directory is an Angular project", "description": "The extensions to look for when determining if the current directory is an Angular project",
"default": ["angular.json"], "default": [
"angular.json"
],
"items": { "items": {
"type": "string" "type": "string"
} }
@ -3228,7 +3293,9 @@
"type": "array", "type": "array",
"title": "Extensions", "title": "Extensions",
"description": "The extensions to look for when determining if the current directory is a React project", "description": "The extensions to look for when determining if the current directory is a React project",
"default": ["package.json"], "default": [
"package.json"
],
"items": { "items": {
"type": "string" "type": "string"
} }
@ -3277,7 +3344,10 @@
"type": "array", "type": "array",
"title": "Extensions", "title": "Extensions",
"description": "The extensions to look for when determining if the current directory is an Nx project", "description": "The extensions to look for when determining if the current directory is an Nx project",
"default": ["workspace.json", "nx.json"], "default": [
"workspace.json",
"nx.json"
],
"items": { "items": {
"type": "string" "type": "string"
} }
@ -3696,7 +3766,11 @@
"type": "string", "type": "string",
"title": "Use Stack GHC", "title": "Use Stack GHC",
"description": "Get the GHC version used by Stack. Will decrease performance. Boolean indicating whether stack ghc was used available in template as .StackGhc", "description": "Get the GHC version used by Stack. Will decrease performance. Boolean indicating whether stack ghc was used available in template as .StackGhc",
"enum": ["always", "package", "never"], "enum": [
"always",
"package",
"never"
],
"default": "never" "default": "never"
}, },
"extensions": { "extensions": {
@ -3781,7 +3855,9 @@
"type": "array", "type": "array",
"title": "Extensions", "title": "Extensions",
"description": "The extensions to look for when determining if the current directory is a UI5 project", "description": "The extensions to look for when determining if the current directory is a UI5 project",
"default": ["*ui5*.y*ml"], "default": [
"*ui5*.y*ml"
],
"items": { "items": {
"type": "string" "type": "string"
} }
@ -3874,7 +3950,9 @@
"type": "array", "type": "array",
"title": "Extensions", "title": "Extensions",
"description": "The extensions to look for when determining if the current directory is a Vala project", "description": "The extensions to look for when determining if the current directory is a Vala project",
"default": ["*.vala"], "default": [
"*.vala"
],
"items": { "items": {
"type": "string" "type": "string"
} }
@ -3923,7 +4001,10 @@
"type": "array", "type": "array",
"title": "Extensions", "title": "Extensions",
"description": "The extensions to look for when determining if the current directory is a Cloud Foundry project", "description": "The extensions to look for when determining if the current directory is a Cloud Foundry project",
"default": ["manifest.yml", "mta.yaml"], "default": [
"manifest.yml",
"mta.yaml"
],
"items": { "items": {
"type": "string" "type": "string"
} }
@ -4001,7 +4082,11 @@
"type": "array", "type": "array",
"title": "Extensions", "title": "Extensions",
"description": "The extensions to look for when determining if the current directory is a Kotlin project", "description": "The extensions to look for when determining if the current directory is a Kotlin project",
"default": ["*.kt", "*.kts", "*.ktm"], "default": [
"*.kt",
"*.kts",
"*.ktm"
],
"items": { "items": {
"type": "string" "type": "string"
} }
@ -4099,14 +4184,20 @@
"type": "string", "type": "string",
"title": "Preferred Executable", "title": "Preferred Executable",
"description": "The preferred executable to use when fetching the version.", "description": "The preferred executable to use when fetching the version.",
"enum": ["lua", "luajit"], "enum": [
"lua",
"luajit"
],
"default": "lua" "default": "lua"
}, },
"extensions": { "extensions": {
"type": "array", "type": "array",
"title": "Extensions", "title": "Extensions",
"description": "The extensions to look for when determining if the current directory is a Lua project", "description": "The extensions to look for when determining if the current directory is a Lua project",
"default": ["*.lua", "*.rockspec"], "default": [
"*.lua",
"*.rockspec"
],
"items": { "items": {
"type": "string" "type": "string"
} }
@ -4155,7 +4246,10 @@
"type": "array", "type": "array",
"title": "Extensions", "title": "Extensions",
"description": "The extensions to look for when determining if the current directory is a Swift project", "description": "The extensions to look for when determining if the current directory is a Swift project",
"default": ["*.swift", "*.SWIFT"], "default": [
"*.swift",
"*.SWIFT"
],
"items": { "items": {
"type": "string" "type": "string"
} }
@ -4204,7 +4298,11 @@
"type": "array", "type": "array",
"title": "Extensions", "title": "Extensions",
"description": "The extensions to look for when determining if the current directory is a CDS project", "description": "The extensions to look for when determining if the current directory is a CDS project",
"default": [".cdsrc.json", ".cdsrc-private.json", "*.cds"], "default": [
".cdsrc.json",
".cdsrc-private.json",
"*.cds"
],
"items": { "items": {
"type": "string" "type": "string"
} }
@ -4399,7 +4497,9 @@
{ {
"if": { "if": {
"properties": { "properties": {
"type": { "const": "umbraco" } "type": {
"const": "umbraco"
}
} }
}, },
"then": { "then": {
@ -4587,6 +4687,18 @@
"accent_color": { "accent_color": {
"title": "Accent color", "title": "Accent color",
"$ref": "#/definitions/color" "$ref": "#/definitions/color"
},
"iterm_features": {
"type": "array",
"title": "The iTerm2 features to enable",
"items": {
"type": "string",
"enum": [
"prompt_mark",
"current_dir",
"remote_host"
]
}
} }
} }
} }

View file

@ -126,17 +126,18 @@ 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 | | `disable_cursor_positioning` | `boolean` | disable fetching the cursor position in bash and zsh in case of unwanted side-effects |
| `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` | disable the upgrade notice | | `disable_notice` | `boolean` | disable the upgrade notice |
| `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
@ -191,3 +192,4 @@ Converters won't catch this change, so you will need to adjust manually.
[accent]: /docs/configuration/colors#standard-colors [accent]: /docs/configuration/colors#standard-colors
[templates]: /docs/configuration/templates#config-variables [templates]: /docs/configuration/templates#config-variables
[pwsh-bleed]: https://github.com/PowerShell/PowerShell/pull/19019 [pwsh-bleed]: https://github.com/PowerShell/PowerShell/pull/19019
[iterm2-si]: https://iterm2.com/documentation-shell-integration.html

View file

@ -1,65 +0,0 @@
---
id: iterm
title: iTerm
sidebar_label: iTerm
---
## What
Inserts iTerm2 shell integration prompt marks and extensions. This segment has no visible output
but is used to enable iTerm2 terminal features.
For more information, read the [shell integration][int-page] and [extension page][ext-page] on
the developer's website.
:::info PromptMark in Bash and ZSH
You will need to add `export ITERM2_SQUELCH_MARK=1` before the shell integration script is sourced.
:::
:::info PromptMark in Fish shell
For fish, you can make use of Oh My Posh's `set_poshcontext` function to set the prompt mark. Add the
following line after initialising Oh My Posh:
```fish
function set_poshcontext
iterm2_prompt_mark
end
```
You do not need to add this segment to use the prompt mark.
:::
## Sample Configuration
import Config from "@site/src/components/Config.js";
<Config
data={{
type: "iterm",
interactive: true,
style: "plain",
foreground: "#80ffea",
template: "{{ .PromptMark }}",
}}
/>
## Template ([info][templates])
:::note default template
```template
{{ .PromptMark }}
```
:::
### Properties
| Name | Type | Description |
| ------------- | -------- | --------------------------------------------------- |
| `.PromptMark` | `string` | inserts the prompt mark to enable shell integration |
| `.CurrentDir` | `string` | inserts the current directory |
| `.RemoteHost` | `string` | inserts the current user and host name |
[templates]: /docs/configuration/templates
[int-page]: https://iterm2.com/documentation-shell-integration.html
[ext-page]: https://iterm2.com/documentation-escape-codes.html

View file

@ -84,7 +84,6 @@ module.exports = {
"segments/haskell", "segments/haskell",
"segments/helm", "segments/helm",
"segments/ipify", "segments/ipify",
"segments/iterm",
"segments/java", "segments/java",
"segments/julia", "segments/julia",
"segments/kotlin", "segments/kotlin",