diff --git a/docs/docs/config-transient.mdx b/docs/docs/config-transient.mdx index 92904c86..86b2f738 100644 --- a/docs/docs/config-transient.mdx +++ b/docs/docs/config-transient.mdx @@ -49,7 +49,7 @@ The configuration has the following properties: - template: `string` - A go [text/template][go-text-template] template extended with [sprig][sprig] utilizing the properties below - defaults to `{{ .Shell }}> ` -## [Template][templates] Properties +## Template ([info][templates]) - `.Root`: `boolean` - is the current user root/admin or not - `.PWD`: `string` - the current working directory diff --git a/docs/docs/segment-angular.md b/docs/docs/segment-angular.md index 7db12427..8478c0d7 100644 --- a/docs/docs/segment-angular.md +++ b/docs/docs/segment-angular.md @@ -30,7 +30,17 @@ Display the currently active Angular CLI version. - `always`: the segment is always displayed - `files`: the segment is only displayed when `angular.json` file is present (default) -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} +``` + +::: + +### Properties - `.Full`: `string` - the full version - `.Major`: `string` - major number diff --git a/docs/docs/segment-aws.md b/docs/docs/segment-aws.md index bfad42bf..178d0cd1 100644 --- a/docs/docs/segment-aws.md +++ b/docs/docs/segment-aws.md @@ -29,7 +29,17 @@ Display the currently active AWS profile and region. - display_default: `boolean` - display the segment or not when the user profile matches `default` - defaults to `true` -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ .Profile }}{{ if .Region }}@{{ .Region }}{{ end }} +``` + +::: + +### Properties - `.Profile`: `string` - the currently active profile - `.Region`: `string` - the currently active region diff --git a/docs/docs/segment-az.md b/docs/docs/segment-az.md index 0c0ff5d8..5c6364be 100644 --- a/docs/docs/segment-az.md +++ b/docs/docs/segment-az.md @@ -14,7 +14,7 @@ Display the currently active Azure subscription information. { "type": "az", "style": "powerline", - "powerline_symbol": "\uE0B0", +"powerline_symbol": "\uE0B0", "foreground": "#000000", "background": "#9ec3f0", "properties": { @@ -24,7 +24,17 @@ Display the currently active Azure subscription information. } ``` -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ .Name }} +``` + +::: + +### Properties - `.EnvironmentName`: `string` - the account environment name - `.HomeTenantID`: `string` - the home tenant id @@ -33,7 +43,7 @@ Display the currently active Azure subscription information. - `.Name`: `string` - the account name - `.State`: `string` - the account state - `.TenantID`: `string` - the tenant id -- `.UserName`: `string` - the user name +- `.User.Name`: `string` - the user name - `.Origin`: `string` - where we received the information from, can be `CLI` or `PWSH` [templates]: /docs/config-templates diff --git a/docs/docs/segment-azfunc.md b/docs/docs/segment-azfunc.md index 596aa654..63ea2984 100644 --- a/docs/docs/segment-azfunc.md +++ b/docs/docs/segment-azfunc.md @@ -34,7 +34,17 @@ Display the currently active Azure functions CLI version. - `always`: the segment is always displayed - `files`: the segment is only displayed when a `host.json` or `local.settings.json` files is present (default) -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} +``` + +::: + +### Properties - `.Full`: `string` - the full version - `.Major`: `string` - major number diff --git a/docs/docs/segment-battery.md b/docs/docs/segment-battery.md index 3575e683..0a8d5af2 100644 --- a/docs/docs/segment-battery.md +++ b/docs/docs/segment-battery.md @@ -39,7 +39,17 @@ Battery displays the remaining power percentage for your battery. - discharging_icon: `string` - icon to display on the left when discharging - defaults to empty - charged_icon: `string` - icon to display on the left when fully charged - defaults to empty -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ if not .Error }}{{ .Icon }}{{ .Percentage }}{{ end }}{{ .Error }} +``` + +::: + +### Properties - `.State`: `struct` - the battery state, has a `.String` function - `.Current`: `float64` - Current (momentary) charge rate (in mW). diff --git a/docs/docs/segment-brewfather.md b/docs/docs/segment-brewfather.md index 77eb229a..0f836677 100644 --- a/docs/docs/segment-brewfather.md +++ b/docs/docs/segment-brewfather.md @@ -68,7 +68,17 @@ You can override the default icons for batch status as used by template property - completed_status_icon - archived_status_icon -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ .StatusIcon }} {{ if .DaysBottledOrFermented }}{{ .DaysBottledOrFermented }}{{ .DayIcon }} {{ end }}{{ url .Recipe.Name .URL }} {{ printf \"%.1f\" .MeasuredAbv }}%{{ if and (.Reading) (eq .Status \"Fermenting\") }} {{ printf \"%.3f\" .Reading.Gravity }} {{ .Reading.Temperature }}\u00b0 {{ .TemperatureTrendIcon }}{{ end }} +``` + +::: + +### Properties Commonly used fields diff --git a/docs/docs/segment-command.md b/docs/docs/segment-command.md index ddcbab44..eb1d93f3 100644 --- a/docs/docs/segment-command.md +++ b/docs/docs/segment-command.md @@ -45,7 +45,17 @@ error). The `&&` functionality will join the output of the commands when success - shell: `string` - the shell in which to run the command in. Uses `shell -c command` under the hood. - command: `string` - the command(s) to run -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ .Output }} +``` + +::: + +### Properties - `.Output`: `string` - the output of the command. diff --git a/docs/docs/segment-crystal.md b/docs/docs/segment-crystal.md index 20138841..7df9d46b 100644 --- a/docs/docs/segment-crystal.md +++ b/docs/docs/segment-crystal.md @@ -33,7 +33,17 @@ Display the currently active crystal version. - `always`: the segment is always displayed - `files`: the segment is only displayed when `*.cr` or `shard.yml` files are present (default) -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} +``` + +::: + +### Properties - `.Full`: `string` - the full version - `.Major`: `string` - major number diff --git a/docs/docs/segment-dart.md b/docs/docs/segment-dart.md index 8980b5a0..413495f7 100644 --- a/docs/docs/segment-dart.md +++ b/docs/docs/segment-dart.md @@ -34,7 +34,17 @@ Display the currently active dart version. - `files`: the segment is only displayed when `*.dart`, `pubspec.yaml`, `pubspec.yml`, `pubspec.lock` files or the `.dart_tool` folder are present (default) -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} +``` + +::: + +### Properties - `.Full`: `string` - the full version - `.Major`: `string` - major number diff --git a/docs/docs/segment-dotnet.md b/docs/docs/segment-dotnet.md index 4246f88f..45014451 100644 --- a/docs/docs/segment-dotnet.md +++ b/docs/docs/segment-dotnet.md @@ -36,7 +36,17 @@ Display the currently active .NET SDK version. or `*.fsproj` files are present (default) - version_url_template: `string` - A go text/template [template][templates] that creates the changelog URL -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ if .Unsupported }}\uf071{{ else }}{{ .Full }}{{ end }} +``` + +::: + +### Properties - `.Full`: `string` - the full version - `.Major`: `string` - major number diff --git a/docs/docs/segment-executiontime.md b/docs/docs/segment-executiontime.md index d0a2f8d6..e6a37f3e 100644 --- a/docs/docs/segment-executiontime.md +++ b/docs/docs/segment-executiontime.md @@ -49,7 +49,17 @@ Style specifies the format in which the time will be displayed. The table below | amarillo | `0.001s` | `2.1s` | `182.1s` | `14,582.1s` | | round | `1ms` | `2s` | `3m 2s` | `4h 3m` | -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ .FormattedMs }} +``` + +::: + +### Properties - `.Ms`: `number` - the execution time in milliseconds - `.FormattedMs`: `string` - the formatted value based on the `style` above. diff --git a/docs/docs/segment-exit.md b/docs/docs/segment-exit.md index fea22cb4..266dd0f5 100644 --- a/docs/docs/segment-exit.md +++ b/docs/docs/segment-exit.md @@ -35,7 +35,17 @@ Displays the last exit code or that the last command failed based on the configu [colors]: /docs/config-colors -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ if gt .Code 0 }}\uf00d {{ .Meaning }}{{ else }}\uf42e{{ end }} +``` + +::: + +### Properties - `.Code`: `number` - the last known exit code - `.Meaning`: `string` - the textual meaning linked to exit code (if applicable, otherwise identical to `.Code`) diff --git a/docs/docs/segment-git.mdx b/docs/docs/segment-git.mdx index ecfcaf96..0c351ec9 100644 --- a/docs/docs/segment-git.mdx +++ b/docs/docs/segment-git.mdx @@ -93,7 +93,17 @@ You can set the following properties to `true` to enable fetching additional inf - azure_devops_icon: `string` - icon/text to display when the upstream is Azure DevOps - defaults to `\uFD03 ` - git_icon: `string` - icon/text to display when the upstream is not known/mapped - defaults to `\uE5FB ` -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ .HEAD }} {{ .BranchStatus }}{{ if .Working.Changed }} \uF044 {{ .Working.String }}{{ end }}{{ if and (.Staging.Changed) (.Working.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uF046 {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0}} \uF692 {{ .StashCount }}{{ end }}{{ if gt .WorktreeCount 0}} \uf1bb {{ .WorktreeCount }}{{ end }} +``` + +::: + +### Properties - `.Working`: `GitStatus` - changes in the working tree (see below) - `.Staging`: `GitStatus` - staged changes in the work tree (see below) diff --git a/docs/docs/segment-golang.md b/docs/docs/segment-golang.md index 118265ba..173da44a 100644 --- a/docs/docs/segment-golang.md +++ b/docs/docs/segment-golang.md @@ -34,7 +34,17 @@ Display the currently active golang version. - `files`: the segment is only displayed when `*.go` or `go.mod` files are present (default) - parse_mod_file: `boolean`: parse the go.mod file instead of calling `go version` -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} +``` + +::: + +### Properties - `.Full`: `string` - the full version - `.Major`: `string` - major number diff --git a/docs/docs/segment-ipify.md b/docs/docs/segment-ipify.md index 9ef780ea..b92a802d 100644 --- a/docs/docs/segment-ipify.md +++ b/docs/docs/segment-ipify.md @@ -34,7 +34,17 @@ sidebar_label: Ipify - cache_timeout: `int` in minutes - How long do you want your IP address cached? - defaults to 10 min -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ .IP }} +``` + +::: + +### Properties - .IP: `string` - Your external IP address diff --git a/docs/docs/segment-java.md b/docs/docs/segment-java.md index 69a252ab..ff5b1610 100644 --- a/docs/docs/segment-java.md +++ b/docs/docs/segment-java.md @@ -46,7 +46,17 @@ Display the currently active java version. - `*.clj` - `*.cljc` -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} +``` + +::: + +### Properties - `.Full`: `string` - the full version - `.Major`: `string` - major number diff --git a/docs/docs/segment-julia.md b/docs/docs/segment-julia.md index dc80aa5e..822172de 100644 --- a/docs/docs/segment-julia.md +++ b/docs/docs/segment-julia.md @@ -33,7 +33,17 @@ Display the currently active julia version. - `always`: the segment is always displayed - `files`: the segment is only displayed when `*.jl` files are present (default) -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} +``` + +::: + +### Properties - `.Full`: `string` - the full version - `.Major`: `string` - major number diff --git a/docs/docs/segment-kubectl.md b/docs/docs/segment-kubectl.md index 95f78822..a27677af 100644 --- a/docs/docs/segment-kubectl.md +++ b/docs/docs/segment-kubectl.md @@ -30,7 +30,17 @@ Display the currently active Kubernetes context name and namespace name. - parse_kubeconfig: `boolean` - parse kubeconfig files instead of calling out to kubectl to improve performance - defaults to `false` -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ .Context }}{{ if .Namespace }} :: {{ .Namespace }}{{ end }} +``` + +::: + +### Properties - `.Context`: `string` - the current kubectl context - `.Namespace`: `string` - the current kubectl context namespace diff --git a/docs/docs/segment-nbgv.mdx b/docs/docs/segment-nbgv.mdx index f2699d39..14768cc8 100644 --- a/docs/docs/segment-nbgv.mdx +++ b/docs/docs/segment-nbgv.mdx @@ -27,7 +27,17 @@ The Nerdbank.GitVersioning CLI can be a bit slow causing the prompt to feel slow } ``` -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ .Version }} +``` + +::: + +### Properties - `.Version`: `string` - the current version - `.AssemblyVersion`: `string` - the current assembly version diff --git a/docs/docs/segment-nightscout.md b/docs/docs/segment-nightscout.md index 38c13f02..88d301a7 100644 --- a/docs/docs/segment-nightscout.md +++ b/docs/docs/segment-nightscout.md @@ -45,7 +45,7 @@ if that color is visible against any of your backgrounds. "properties": { "url": "https://YOURNIGHTSCOUTAPP.herokuapp.com/api/v1/entries.json?count=1&token=APITOKENFROMYOURADMIN", "http_timeout": 1500, - "template": " {{.Sgv}}{{.TrendIcon}}" + "template": "\ue2a1 {{ .Sgv }}{{ .TrendIcon }}" } } ``` @@ -53,7 +53,7 @@ if that color is visible against any of your backgrounds. Or display in mmol/l (instead of the default mg/dl) with the following template: ```json -"template": " {{ if eq (mod .Sgv 18) 0 }}{{divf .Sgv 18}}.0{{ else }} {{ round (divf .Sgv 18) 1 }}{{ end }}{{.TrendIcon}}" +"template": "\ue2a1 {{ if eq (mod .Sgv 18) 0 }}{{divf .Sgv 18}}.0{{ else }} {{ round (divf .Sgv 18) 1 }}{{ end }}{{ .TrendIcon }}" ``` ## Properties @@ -79,7 +79,17 @@ Or display in mmol/l (instead of the default mg/dl) with the following template: - SingleDownIcon - defaults to ↓ - DoubleDownIcon - defaults to ↓↓ -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ .Sgv }} +``` + +::: + +### Properties - .ID: `string` - The internal ID of the object - .Sgv: `int` - Your Serum Glucose Value (your sugar) diff --git a/docs/docs/segment-node.md b/docs/docs/segment-node.md index 242f83cf..2731c3d0 100644 --- a/docs/docs/segment-node.md +++ b/docs/docs/segment-node.md @@ -34,7 +34,17 @@ Display the currently active node version. - yarn_icon: `string` - the icon/text to display when using Yarn - defaults to ` \uF61A` - npm_icon: `string` - the icon/text to display when using NPM - defaults to ` \uE71E` -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ if .PackageManagerIcon }}{{ .PackageManagerIcon }} {{ end }}{{ .Full }} +``` + +::: + +### Properties - `.Full`: `string` - the full version - `.Major`: `string` - major number diff --git a/docs/docs/segment-os.md b/docs/docs/segment-os.md index cbf5e267..873fdc50 100644 --- a/docs/docs/segment-os.md +++ b/docs/docs/segment-os.md @@ -49,8 +49,18 @@ Display OS specific info - defaults to Icon. - slackware: `string` - the icon to use for Slackware - defaults to Slackware icon - defaults to `\uF319` - ubuntu: `string` - the icon to use for Ubuntu - defaults to Ubuntu icon - defaults to `\uF31b` -## [Template][templates] Properties +## Template ([info][templates]) -- `.OS`: `string` - the OS platform +:::note default template + +``` template +{{ if .WSL }}WSL at {{ end }}{{.Icon}} +``` + +::: + +### Properties + +- `.Icon`: `string` - the OS icon [templates]: /docs/config-templates diff --git a/docs/docs/segment-owm.md b/docs/docs/segment-owm.md index 7eceb94d..f3ae3f99 100644 --- a/docs/docs/segment-owm.md +++ b/docs/docs/segment-owm.md @@ -47,7 +47,17 @@ The free tier for *Current weather and forecasts collection* is sufficient. - template: `string` - A go [text/template][go-text-template] template extended with [sprig][sprig] utilizing the properties below - defaults to `{{.Weather}} ({{.Temperature}}{{.UnitIcon}})` -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ .Weather }} ({{ .Temperature }}{{ .UnitIcon }}) +``` + +::: + +### Properties - `.Weather`: `string` - the current weather icon - `.Temperature`: `string` - the current temperature diff --git a/docs/docs/segment-path.md b/docs/docs/segment-path.md index afa8b91d..fd32ab5e 100644 --- a/docs/docs/segment-path.md +++ b/docs/docs/segment-path.md @@ -121,9 +121,19 @@ starts with a symbol or icon. - `__pycache__` will be shortened to `__p` - `➼ folder` will be shortened to `➼ f` -## [Template][templates] Properties +## Template ([info][templates]) -- `.Path`: `string` - the current directory (styled) +:::note default template + +``` template +{{ .Path }} +``` + +::: + +### Properties + +- `.Path`: `string` - the current directory (based on the `style` property) - `.StackCount`: `int` - the stack count [templates]: /docs/config-templates diff --git a/docs/docs/segment-php.md b/docs/docs/segment-php.md index 40b48482..1cf3b8e4 100644 --- a/docs/docs/segment-php.md +++ b/docs/docs/segment-php.md @@ -33,7 +33,17 @@ Display the currently active php version. - `always`: the segment is always displayed - `files`: the segment is only displayed when `*.php, composer.json, composer.lock, .php-version` files are present (default) -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} +``` + +::: + +### Properties - `.Full`: `string` - the full version - `.Major`: `string` - major number diff --git a/docs/docs/segment-plastic.md b/docs/docs/segment-plastic.md index 5aaaed2d..e2490a8a 100644 --- a/docs/docs/segment-plastic.md +++ b/docs/docs/segment-plastic.md @@ -71,7 +71,17 @@ You can set the following property to `true` to enable fetching additional infor - commit_icon: `string` - icon/text to display before the commit context (detached HEAD) - defaults to `\uF417` - tag_icon: `string` - icon/text to display before the tag context - defaults to `\uF412` -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ .Selector }} +``` + +::: + +### Properties - `.Selector`: `string` - the current selector context (branch/changeset/label) - `.Behind`: `bool` - the current workspace is behind and changes are incoming diff --git a/docs/docs/segment-posh-git.mdx b/docs/docs/segment-posh-git.mdx index ff0c40e7..0664129a 100644 --- a/docs/docs/segment-posh-git.mdx +++ b/docs/docs/segment-posh-git.mdx @@ -25,7 +25,17 @@ To enable the `posh-git` module, set `$env:POSH_GIT_ENABLED = $true` in your `$P } ``` -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ .Status }} +``` + +::: + +### Properties - `.Status`: `string` - the status reported from posh-git diff --git a/docs/docs/segment-python.md b/docs/docs/segment-python.md index 2563a06f..e2f9eb60 100644 --- a/docs/docs/segment-python.md +++ b/docs/docs/segment-python.md @@ -40,7 +40,17 @@ or not - defaults to `true` - `environment`: the segment is only displayed when a virtual env is present - `context`: the segment is only displayed when either `environment` or `files` is active -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}{{ end }} +``` + +::: + +### Properties - `.Venv`: `string` - the virtual environment name (if present) - `.Full`: `string` - the full version diff --git a/docs/docs/segment-root.md b/docs/docs/segment-root.md index b27645a2..eff6112c 100644 --- a/docs/docs/segment-root.md +++ b/docs/docs/segment-root.md @@ -22,3 +22,15 @@ Show when the current user is root or when in an elevated shell (Windows). } } ``` + +## Template ([info][templates]) + +:::note default template + +``` template +\uF0E7 +``` + +::: + +[templates]: /docs/config-templates diff --git a/docs/docs/segment-ruby.md b/docs/docs/segment-ruby.md index 23a514ab..3f8417b4 100644 --- a/docs/docs/segment-ruby.md +++ b/docs/docs/segment-ruby.md @@ -33,7 +33,17 @@ Display the currently active ruby version. - `always`: the segment is always displayed - `files`: the segment is only displayed when `*.rb`, `Gemfile` or `Rakefile` files are present (default) -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} +``` + +::: + +### Properties - `.Full`: `string` - the full version - `.Major`: `string` - major number diff --git a/docs/docs/segment-rust.md b/docs/docs/segment-rust.md index eebed922..535cc10c 100644 --- a/docs/docs/segment-rust.md +++ b/docs/docs/segment-rust.md @@ -33,7 +33,17 @@ Display the currently active rust version. - `always`: the segment is always displayed - `files`: the segment is only displayed when `*.rs`, `Cargo.toml` or `Cargo.lock` files are present (default) -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} +``` + +::: + +### Properties - `.Full`: `string` - the full version - `.Major`: `string` - major number diff --git a/docs/docs/segment-session.md b/docs/docs/segment-session.md index f82d400a..2eff6618 100644 --- a/docs/docs/segment-session.md +++ b/docs/docs/segment-session.md @@ -24,7 +24,17 @@ Show the current user and host name. } ``` -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ if .SSHSession }}\uf817 {{ end }}{{ .UserName }}@{{ .HostName }} +``` + +::: + +### Properties - `.UserName`: `string` - the current user's name - `.HostName`: `string` - the current computer's name diff --git a/docs/docs/segment-shell.md b/docs/docs/segment-shell.md index 8c13f622..01f71211 100644 --- a/docs/docs/segment-shell.md +++ b/docs/docs/segment-shell.md @@ -29,7 +29,17 @@ Show the current shell name (ZSH, powershell, bash, ...). - mapped_shell_names: `object` - custom glyph/text to use in place of specified shell names (case-insensitive) -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ .Name }} +``` + +::: + +### Properties - `.Name`: `string` - the shell name diff --git a/docs/docs/segment-spotify.md b/docs/docs/segment-spotify.md index 7cba0c44..98c00174 100644 --- a/docs/docs/segment-spotify.md +++ b/docs/docs/segment-spotify.md @@ -35,7 +35,17 @@ On macOS, all states are supported (playing/paused/stopped). - paused_icon: `string` - text/icon to show when paused - defaults to `\uF8E3 ` - stopped_icon: `string` - text/icon to show when stopped - defaults to `\uF04D ` -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ .Icon }}{{ if ne .Status \"stopped\" }}{{ .Artist }} - {{ .Track }}{{ end }} +``` + +::: + +### Properties - `.Status`: `string` - player status (`playing`, `paused`, `stopped`) - `.Artist`: `string` - current artist diff --git a/docs/docs/segment-strava.mdx b/docs/docs/segment-strava.mdx index 22c03a05..0fd75666 100644 --- a/docs/docs/segment-strava.mdx +++ b/docs/docs/segment-strava.mdx @@ -69,7 +69,17 @@ if that color is visible against any of your backgrounds. - WorkOutIcon - defaults to `\ue213` - UnknownActivityIcon - defaults to `\ue213` -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ if .Error }}{{ .Error }}{{ else }}{{ .Ago }}{{ end }} +``` + +::: + +### Properties The properties below are available for use in your template diff --git a/docs/docs/segment-sysinfo.md b/docs/docs/segment-sysinfo.md index 4b5f5514..273f9c27 100644 --- a/docs/docs/segment-sysinfo.md +++ b/docs/docs/segment-sysinfo.md @@ -31,7 +31,17 @@ Display SysInfo. - Precision: `int` - The precision used for any float values - defaults to 2 -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ round .PhysicalPercentUsed .Precision }} +``` + +::: + +### Properties - `.PhysicalTotalMemory`: `int` - is the total of used physical memory - `.PhysicalFreeMemory`: `int` - is the total of free physical memory diff --git a/docs/docs/segment-terraform.md b/docs/docs/segment-terraform.md index 35bd1773..5b4d96d2 100644 --- a/docs/docs/segment-terraform.md +++ b/docs/docs/segment-terraform.md @@ -27,7 +27,17 @@ This requires a terraform binary in your PATH and will only show in directories } ``` -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ .WorkspaceName }} +``` + +::: + +### Properties - `.WorkspaceName`: `string` - is the current workspace name diff --git a/docs/docs/segment-text.md b/docs/docs/segment-text.md index 17ccbd0d..6647aa03 100644 --- a/docs/docs/segment-text.md +++ b/docs/docs/segment-text.md @@ -35,7 +35,17 @@ New-Alias -Name 'Set-PoshContext' -Value 'Set-EnvVar' -Scope Global -Force ::: -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ .Text }} +``` + +::: + +### Properties - `.Root`: `boolean` - is the current user root/admin or not - `.Path`: `string` - the current working directory diff --git a/docs/docs/segment-time.md b/docs/docs/segment-time.md index 27439a51..ddf9fcf0 100644 --- a/docs/docs/segment-time.md +++ b/docs/docs/segment-time.md @@ -25,11 +25,22 @@ Show the current timestamp. - time_format: `string` - format to use, follows the [golang standard][format] - defaults to `15:04:05` -## [Template][templates] Properties +## Template ([info][templates]) -- `.CurrentDate`: `time` - The time to display(testing purpose) +:::note default template -### Standard time and date formats +``` template +{{ .CurrentDate | date .Format }} +``` + +::: + +### Properties + +- `.Format`: `string` - The time format (set via `time_format`) +- `.CurrentDate`: `time` - The time to display (testing purpose) + +## Standard time and date formats - January 2, 2006 **Date** - 01/02/06 @@ -46,7 +57,7 @@ Show the current timestamp. - Mon, 02 Jan 2006 15:04:05 MST 27e95cb - Mon, 02 Jan 2006 15:04:05 -0700 **with numeric zone** -#### The following predefined date and timestamp format constants are also available +### The following predefined date and timestamp format constants are also available - ANSIC = "Mon Jan _2 15:04:05 2006" - UnixDate = "Mon Jan _2 15:04:05 MST 2006" diff --git a/docs/docs/segment-wakatime.md b/docs/docs/segment-wakatime.md index b8496550..037eb8fe 100644 --- a/docs/docs/segment-wakatime.md +++ b/docs/docs/segment-wakatime.md @@ -40,11 +40,21 @@ works if you can curl it yourself and a result. - defaults to `` - http_timeout: `int` - The default timeout for http request is 20ms. If no segment is shown, try increasing this timeout. - cache_timeout: `int` - The default timeout for request caching is 10m. A value of 0 disables the cache. -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ secondsRound .CummulativeTotal.Seconds }} +``` + +::: + +### Properties - `.CummulativeTotal`: `wtTotals` - object holding total tracked time values -### wtTotal Properties +### wtTotals Properties - `.Seconds`: `int` - a number reprecenting the total tracked time in seconds - `.Text`: `string` - a string with human readable tracked time (eg: "2 hrs 30 mins") diff --git a/docs/docs/segment-wifi.md b/docs/docs/segment-wifi.md index 7ed49520..ead73764 100644 --- a/docs/docs/segment-wifi.md +++ b/docs/docs/segment-wifi.md @@ -30,7 +30,17 @@ Currently only supports Windows and WSL. Pull requests for Darwin and Linux supp } ``` -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ if .Error }}{{ .Error }}{{ else }}\uFAA8 {{ .SSID }} {{ .Signal }}% {{ .ReceiveRate }}Mbps{{ end }} +``` + +::: + +### Properties - `.SSID`: `string` - the SSID of the current wifi network - `.RadioType`: `string` - the radio type - _e.g. 802.11ac, 802.11ax, 802.11n, etc._ diff --git a/docs/docs/segment-winreg.md b/docs/docs/segment-winreg.md index a459453b..c2d6333e 100644 --- a/docs/docs/segment-winreg.md +++ b/docs/docs/segment-winreg.md @@ -38,7 +38,17 @@ Supported registry key types: Ending path with \ will get the (Default) key from that path. - fallback: `string` - the value to fall back to if no entry is found -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ .Value }} +``` + +::: + +### Properties - .Value: `string` - The result of your query, or fallback if not found. diff --git a/docs/docs/segment-ytm.md b/docs/docs/segment-ytm.md index 5e326be9..8dba8241 100644 --- a/docs/docs/segment-ytm.md +++ b/docs/docs/segment-ytm.md @@ -38,7 +38,17 @@ Remote Control password. - stopped_icon: `string` - text/icon to show when paused - defaults to `\uF04D ` - api_url: `string` - the YTMDA Remote Control API URL- defaults to `http://127.0.0.1:9863` -## [Template][templates] Properties +## Template ([info][templates]) + +:::note default template + +``` template +{{ .Icon }}{{ if ne .Status \"stopped\" }}{{ .Artist }} - {{ .Track }}{{ end }} +``` + +::: + +### Properties - `.Status`: `string` - player status (`playing`, `paused`, `stopped`) - `.Artist`: `string` - current artist diff --git a/src/segments/battery.go b/src/segments/battery.go index 3a171a39..32014fee 100644 --- a/src/segments/battery.go +++ b/src/segments/battery.go @@ -28,7 +28,7 @@ const ( ) func (b *Battery) Template() string { - return "{{ if not .Error }}{{.Icon}}{{.Percentage}}{{ end }}{{.Error}}" + return "{{ if not .Error }}{{ .Icon }}{{ .Percentage }}{{ end }}{{ .Error }}" } func (b *Battery) Enabled() bool { diff --git a/src/segments/brewfather.go b/src/segments/brewfather.go index e51c99a8..59006bf5 100644 --- a/src/segments/brewfather.go +++ b/src/segments/brewfather.go @@ -55,10 +55,6 @@ const ( BFCacheTimeout properties.Property = "cache_timeout" - DefaultTemplate string = "{{.StatusIcon}} {{if .DaysBottledOrFermented}}{{.DaysBottledOrFermented}}{{.DayIcon}} {{end}}[{{.Recipe.Name}}]({{.URL}})" + - " {{printf \"%.1f\" .MeasuredAbv}}%{{ if and (.Reading) (eq .Status \"Fermenting\")}} " + - "{{printf \"%.3f\" .Reading.Gravity}} {{.Reading.Temperature}}\u00b0 {{.TemperatureTrendIcon}}{{end}}" - BFStatusPlanning string = "Planning" BFStatusBrewing string = "Brewing" BFStatusFermenting string = "Fermenting" @@ -101,7 +97,7 @@ type Batch struct { } func (bf *Brewfather) Template() string { - return DefaultTemplate + return "{{ .StatusIcon }} {{ if .DaysBottledOrFermented }}{{ .DaysBottledOrFermented }}{{ .DayIcon }} {{ end }}{{ url .Recipe.Name .URL }} {{ printf \"%.1f\" .MeasuredAbv }}%{{ if and (.Reading) (eq .Status \"Fermenting\") }} {{ printf \"%.3f\" .Reading.Gravity }} {{ .Reading.Temperature }}\u00b0 {{ .TemperatureTrendIcon }}{{ end }}" // nolint:lll } func (bf *Brewfather) Enabled() bool { diff --git a/src/segments/nightscout_test.go b/src/segments/nightscout_test.go index 85e50414..a19d0243 100644 --- a/src/segments/nightscout_test.go +++ b/src/segments/nightscout_test.go @@ -29,56 +29,56 @@ func TestNSSegment(t *testing.T) { Case: "Flat 150", JSONResponse: ` [{"_id":"619d6fa819696e8ded5b2206","sgv":150,"date":1637707537000,"dateString":"2021-11-23T22:45:37.000Z","trend":4,"direction":"Flat","device":"share2","type":"sgv","utcOffset":0,"sysTime":"2021-11-23T22:45:37.000Z","mills":1637707537000}]`, // nolint:lll - Template: " {{.Sgv}}{{.TrendIcon}}", - ExpectedString: " 150→", + Template: "\ue2a1 {{.Sgv}}{{.TrendIcon}}", + ExpectedString: "\ue2a1 150→", ExpectedEnabled: true, }, { Case: "DoubleDown 50", JSONResponse: ` [{"_id":"619d6fa819696e8ded5b2206","sgv":50,"date":1637707537000,"dateString":"2021-11-23T22:45:37.000Z","trend":4,"direction":"DoubleDown","device":"share2","type":"sgv","utcOffset":0,"sysTime":"2021-11-23T22:45:37.000Z","mills":1637707537000}]`, // nolint:lll - Template: " {{.Sgv}}{{.TrendIcon}}", - ExpectedString: " 50↓↓", + Template: "\ue2a1 {{.Sgv}}{{.TrendIcon}}", + ExpectedString: "\ue2a1 50↓↓", ExpectedEnabled: true, }, { Case: "DoubleUp 250", JSONResponse: ` [{"_id":"619d6fa819696e8ded5b2206","sgv":250,"date":1637707537000,"dateString":"2021-11-23T22:45:37.000Z","trend":4,"direction":"DoubleUp","device":"share2","type":"sgv","utcOffset":0,"sysTime":"2021-11-23T22:45:37.000Z","mills":1637707537000}]`, // nolint:lll - Template: " {{.Sgv}}{{.TrendIcon}}", - ExpectedString: " 250↑↑", + Template: "\ue2a1 {{.Sgv}}{{.TrendIcon}}", + ExpectedString: "\ue2a1 250↑↑", ExpectedEnabled: true, }, { Case: "SingleUp 130", JSONResponse: ` [{"_id":"619d6fa819696e8ded5b2206","sgv":130,"date":1637707537000,"dateString":"2021-11-23T22:45:37.000Z","trend":4,"direction":"SingleUp","device":"share2","type":"sgv","utcOffset":0,"sysTime":"2021-11-23T22:45:37.000Z","mills":1637707537000}]`, // nolint:lll - Template: " {{.Sgv}}{{.TrendIcon}}", - ExpectedString: " 130↑", + Template: "\ue2a1 {{.Sgv}}{{.TrendIcon}}", + ExpectedString: "\ue2a1 130↑", ExpectedEnabled: true, }, { Case: "FortyFiveUp 174", JSONResponse: ` [{"_id":"619d6fa819696e8ded5b2206","sgv":174,"date":1637707537000,"dateString":"2021-11-23T22:45:37.000Z","trend":4,"direction":"FortyFiveUp","device":"share2","type":"sgv","utcOffset":0,"sysTime":"2021-11-23T22:45:37.000Z","mills":1637707537000}]`, // nolint:lll - Template: " {{.Sgv}}{{.TrendIcon}}", - ExpectedString: " 174↗", + Template: "\ue2a1 {{.Sgv}}{{.TrendIcon}}", + ExpectedString: "\ue2a1 174↗", ExpectedEnabled: true, }, { Case: "FortyFiveDown 61", JSONResponse: ` [{"_id":"619d6fa819696e8ded5b2206","sgv":61,"date":1637707537000,"dateString":"2021-11-23T22:45:37.000Z","trend":4,"direction":"FortyFiveDown","device":"share2","type":"sgv","utcOffset":0,"sysTime":"2021-11-23T22:45:37.000Z","mills":1637707537000}]`, // nolint:lll - Template: " {{.Sgv}}{{.TrendIcon}}", - ExpectedString: " 61↘", + Template: "\ue2a1 {{.Sgv}}{{.TrendIcon}}", + ExpectedString: "\ue2a1 61↘", ExpectedEnabled: true, }, { Case: "DoubleDown 50", JSONResponse: ` [{"_id":"619d6fa819696e8ded5b2206","sgv":50,"date":1637707537000,"dateString":"2021-11-23T22:45:37.000Z","trend":4,"direction":"DoubleDown","device":"share2","type":"sgv","utcOffset":0,"sysTime":"2021-11-23T22:45:37.000Z","mills":1637707537000}]`, // nolint:lll - Template: " {{.Sgv}}{{.TrendIcon}}", - ExpectedString: " 50↓↓", + Template: "\ue2a1 {{.Sgv}}{{.TrendIcon}}", + ExpectedString: "\ue2a1 50↓↓", ExpectedEnabled: true, }, { @@ -96,8 +96,8 @@ func TestNSSegment(t *testing.T) { Case: "DoubleDown 50 from cache", JSONResponse: ` [{"_id":"619d6fa819696e8ded5b2206","sgv":50,"date":1637707537000,"dateString":"2021-11-23T22:45:37.000Z","trend":4,"direction":"DoubleDown","device":"share2","type":"sgv","utcOffset":0,"sysTime":"2021-11-23T22:45:37.000Z","mills":1637707537000}]`, // nolint:lll - Template: " {{.Sgv}}{{.TrendIcon}}", - ExpectedString: " 50↓↓", + Template: "\ue2a1 {{.Sgv}}{{.TrendIcon}}", + ExpectedString: "\ue2a1 50↓↓", ExpectedEnabled: true, CacheTimeout: 10, }, @@ -105,8 +105,8 @@ func TestNSSegment(t *testing.T) { Case: "DoubleDown 50 from cache not found", JSONResponse: ` [{"_id":"619d6fa819696e8ded5b2206","sgv":50,"date":1637707537000,"dateString":"2021-11-23T22:45:37.000Z","trend":4,"direction":"DoubleDown","device":"share2","type":"sgv","utcOffset":0,"sysTime":"2021-11-23T22:45:37.000Z","mills":1637707537000}]`, // nolint:lll - Template: " {{.Sgv}}{{.TrendIcon}}", - ExpectedString: " 50↓↓", + Template: "\ue2a1 {{.Sgv}}{{.TrendIcon}}", + ExpectedString: "\ue2a1 50↓↓", ExpectedEnabled: true, CacheTimeout: 10, CacheFoundFail: true, @@ -115,8 +115,8 @@ func TestNSSegment(t *testing.T) { Case: "Error parsing response", JSONResponse: ` 4tffgt4e4567`, - Template: " {{.Sgv}}{{.TrendIcon}}", - ExpectedString: " 50↓↓", + Template: "\ue2a1 {{.Sgv}}{{.TrendIcon}}", + ExpectedString: "\ue2a1 50↓↓", ExpectedEnabled: false, CacheTimeout: 10, }, @@ -124,7 +124,7 @@ func TestNSSegment(t *testing.T) { Case: "Faulty template", JSONResponse: ` [{"sgv":50,"direction":"DoubleDown"}]`, - Template: " {{.Sgv}}{{.Burp}}", + Template: "\ue2a1 {{.Sgv}}{{.Burp}}", ExpectedString: template.IncorrectTemplate, ExpectedEnabled: true, CacheTimeout: 10, diff --git a/src/segments/time.go b/src/segments/time.go index b8e6ecfe..7ad80b34 100644 --- a/src/segments/time.go +++ b/src/segments/time.go @@ -11,6 +11,7 @@ type Time struct { env environment.Environment CurrentDate time.Time + Format string } const ( @@ -19,11 +20,12 @@ const ( ) func (t *Time) Template() string { - return "{{ .CurrentDate | date \"" + t.props.GetString(TimeFormat, "15:04:05") + "\" }}" + return "{{ .CurrentDate | date .Format }}" } func (t *Time) Enabled() bool { // if no date set, use now(unit testing) + t.Format = t.props.GetString(TimeFormat, "15:04:05") if t.CurrentDate.IsZero() { t.CurrentDate = time.Now() }