docs: add template information

This commit is contained in:
Jan De Dobbeleer 2022-02-01 12:10:46 +01:00 committed by Jan De Dobbeleer
parent 0373d2c507
commit b4292e2e50
48 changed files with 512 additions and 81 deletions

View file

@ -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 - template: `string` - A go [text/template][go-text-template] template extended with [sprig][sprig] utilizing the
properties below - defaults to `{{ .Shell }}> ` properties below - defaults to `{{ .Shell }}> `
## [Template][templates] Properties ## Template ([info][templates])
- `.Root`: `boolean` - is the current user root/admin or not - `.Root`: `boolean` - is the current user root/admin or not
- `.PWD`: `string` - the current working directory - `.PWD`: `string` - the current working directory

View file

@ -30,7 +30,17 @@ Display the currently active Angular CLI version.
- `always`: the segment is always displayed - `always`: the segment is always displayed
- `files`: the segment is only displayed when `angular.json` file is present (default) - `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 - `.Full`: `string` - the full version
- `.Major`: `string` - major number - `.Major`: `string` - major number

View file

@ -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 - display_default: `boolean` - display the segment or not when the user profile matches `default` - defaults
to `true` to `true`
## [Template][templates] Properties ## Template ([info][templates])
:::note default template
``` template
{{ .Profile }}{{ if .Region }}@{{ .Region }}{{ end }}
```
:::
### Properties
- `.Profile`: `string` - the currently active profile - `.Profile`: `string` - the currently active profile
- `.Region`: `string` - the currently active region - `.Region`: `string` - the currently active region

View file

@ -14,7 +14,7 @@ Display the currently active Azure subscription information.
{ {
"type": "az", "type": "az",
"style": "powerline", "style": "powerline",
"powerline_symbol": "\uE0B0", "powerline_symbol": "\uE0B0",
"foreground": "#000000", "foreground": "#000000",
"background": "#9ec3f0", "background": "#9ec3f0",
"properties": { "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 - `.EnvironmentName`: `string` - the account environment name
- `.HomeTenantID`: `string` - the home tenant id - `.HomeTenantID`: `string` - the home tenant id
@ -33,7 +43,7 @@ Display the currently active Azure subscription information.
- `.Name`: `string` - the account name - `.Name`: `string` - the account name
- `.State`: `string` - the account state - `.State`: `string` - the account state
- `.TenantID`: `string` - the tenant id - `.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` - `.Origin`: `string` - where we received the information from, can be `CLI` or `PWSH`
[templates]: /docs/config-templates [templates]: /docs/config-templates

View file

@ -34,7 +34,17 @@ Display the currently active Azure functions CLI version.
- `always`: the segment is always displayed - `always`: the segment is always displayed
- `files`: the segment is only displayed when a `host.json` or `local.settings.json` files is present (default) - `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 - `.Full`: `string` - the full version
- `.Major`: `string` - major number - `.Major`: `string` - major number

View file

@ -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 - 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 - 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 - `.State`: `struct` - the battery state, has a `.String` function
- `.Current`: `float64` - Current (momentary) charge rate (in mW). - `.Current`: `float64` - Current (momentary) charge rate (in mW).

View file

@ -68,7 +68,17 @@ You can override the default icons for batch status as used by template property
- completed_status_icon - completed_status_icon
- archived_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 Commonly used fields

View file

@ -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. - 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 - 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. - `.Output`: `string` - the output of the command.

View file

@ -33,7 +33,17 @@ Display the currently active crystal version.
- `always`: the segment is always displayed - `always`: the segment is always displayed
- `files`: the segment is only displayed when `*.cr` or `shard.yml` files are present (default) - `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 - `.Full`: `string` - the full version
- `.Major`: `string` - major number - `.Major`: `string` - major number

View file

@ -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` - `files`: the segment is only displayed when `*.dart`, `pubspec.yaml`, `pubspec.yml`, `pubspec.lock` files or the `.dart_tool`
folder are present (default) 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 - `.Full`: `string` - the full version
- `.Major`: `string` - major number - `.Major`: `string` - major number

View file

@ -36,7 +36,17 @@ Display the currently active .NET SDK version.
or `*.fsproj` files are present (default) or `*.fsproj` files are present (default)
- version_url_template: `string` - A go text/template [template][templates] that creates the changelog URL - 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 - `.Full`: `string` - the full version
- `.Major`: `string` - major number - `.Major`: `string` - major number

View file

@ -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` | | amarillo | `0.001s` | `2.1s` | `182.1s` | `14,582.1s` |
| round | `1ms` | `2s` | `3m 2s` | `4h 3m` | | 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 - `.Ms`: `number` - the execution time in milliseconds
- `.FormattedMs`: `string` - the formatted value based on the `style` above. - `.FormattedMs`: `string` - the formatted value based on the `style` above.

View file

@ -35,7 +35,17 @@ Displays the last exit code or that the last command failed based on the configu
[colors]: /docs/config-colors [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 - `.Code`: `number` - the last known exit code
- `.Meaning`: `string` - the textual meaning linked to exit code (if applicable, otherwise identical to `.Code`) - `.Meaning`: `string` - the textual meaning linked to exit code (if applicable, otherwise identical to `.Code`)

View file

@ -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 ` - 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 ` - 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) - `.Working`: `GitStatus` - changes in the working tree (see below)
- `.Staging`: `GitStatus` - staged changes in the work tree (see below) - `.Staging`: `GitStatus` - staged changes in the work tree (see below)

View file

@ -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) - `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` - 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 - `.Full`: `string` - the full version
- `.Major`: `string` - major number - `.Major`: `string` - major number

View file

@ -34,7 +34,17 @@ sidebar_label: Ipify
- cache_timeout: `int` in minutes - How long do you want your IP address cached? - - cache_timeout: `int` in minutes - How long do you want your IP address cached? -
defaults to 10 min defaults to 10 min
## [Template][templates] Properties ## Template ([info][templates])
:::note default template
``` template
{{ .IP }}
```
:::
### Properties
- .IP: `string` - Your external IP address - .IP: `string` - Your external IP address

View file

@ -46,7 +46,17 @@ Display the currently active java version.
- `*.clj` - `*.clj`
- `*.cljc` - `*.cljc`
## [Template][templates] Properties ## Template ([info][templates])
:::note default template
``` template
{{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}
```
:::
### Properties
- `.Full`: `string` - the full version - `.Full`: `string` - the full version
- `.Major`: `string` - major number - `.Major`: `string` - major number

View file

@ -33,7 +33,17 @@ Display the currently active julia version.
- `always`: the segment is always displayed - `always`: the segment is always displayed
- `files`: the segment is only displayed when `*.jl` files are present (default) - `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 - `.Full`: `string` - the full version
- `.Major`: `string` - major number - `.Major`: `string` - major number

View file

@ -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 - parse_kubeconfig: `boolean` - parse kubeconfig files instead of calling out to kubectl to improve
performance - defaults to `false` 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 - `.Context`: `string` - the current kubectl context
- `.Namespace`: `string` - the current kubectl context namespace - `.Namespace`: `string` - the current kubectl context namespace

View file

@ -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 - `.Version`: `string` - the current version
- `.AssemblyVersion`: `string` - the current assembly version - `.AssemblyVersion`: `string` - the current assembly version

View file

@ -45,7 +45,7 @@ if that color is visible against any of your backgrounds.
"properties": { "properties": {
"url": "https://YOURNIGHTSCOUTAPP.herokuapp.com/api/v1/entries.json?count=1&token=APITOKENFROMYOURADMIN", "url": "https://YOURNIGHTSCOUTAPP.herokuapp.com/api/v1/entries.json?count=1&token=APITOKENFROMYOURADMIN",
"http_timeout": 1500, "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: Or display in mmol/l (instead of the default mg/dl) with the following template:
```json ```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 ## Properties
@ -79,7 +79,17 @@ Or display in mmol/l (instead of the default mg/dl) with the following template:
- SingleDownIcon - defaults to ↓ - SingleDownIcon - defaults to ↓
- DoubleDownIcon - 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 - .ID: `string` - The internal ID of the object
- .Sgv: `int` - Your Serum Glucose Value (your sugar) - .Sgv: `int` - Your Serum Glucose Value (your sugar)

View file

@ -34,7 +34,17 @@ Display the currently active node version.
- yarn_icon: `string` - the icon/text to display when using Yarn - defaults to ` \uF61A` - 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` - 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 - `.Full`: `string` - the full version
- `.Major`: `string` - major number - `.Major`: `string` - major number

View file

@ -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` - 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` - 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 [templates]: /docs/config-templates

View file

@ -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 - template: `string` - A go [text/template][go-text-template] template extended with [sprig][sprig] utilizing the
properties below - defaults to `{{.Weather}} ({{.Temperature}}{{.UnitIcon}})` 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 - `.Weather`: `string` - the current weather icon
- `.Temperature`: `string` - the current temperature - `.Temperature`: `string` - the current temperature

View file

@ -121,9 +121,19 @@ starts with a symbol or icon.
- `__pycache__` will be shortened to `__p` - `__pycache__` will be shortened to `__p`
- `➼ folder` will be shortened to `➼ f` - `➼ 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 - `.StackCount`: `int` - the stack count
[templates]: /docs/config-templates [templates]: /docs/config-templates

View file

@ -33,7 +33,17 @@ Display the currently active php version.
- `always`: the segment is always displayed - `always`: the segment is always displayed
- `files`: the segment is only displayed when `*.php, composer.json, composer.lock, .php-version` files are present (default) - `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 - `.Full`: `string` - the full version
- `.Major`: `string` - major number - `.Major`: `string` - major number

View file

@ -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` - 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` - 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) - `.Selector`: `string` - the current selector context (branch/changeset/label)
- `.Behind`: `bool` - the current workspace is behind and changes are incoming - `.Behind`: `bool` - the current workspace is behind and changes are incoming

View file

@ -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 - `.Status`: `string` - the status reported from posh-git

View file

@ -40,7 +40,17 @@ or not - defaults to `true`
- `environment`: the segment is only displayed when a virtual env is present - `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 - `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) - `.Venv`: `string` - the virtual environment name (if present)
- `.Full`: `string` - the full version - `.Full`: `string` - the full version

View file

@ -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

View file

@ -33,7 +33,17 @@ Display the currently active ruby version.
- `always`: the segment is always displayed - `always`: the segment is always displayed
- `files`: the segment is only displayed when `*.rb`, `Gemfile` or `Rakefile` files are present (default) - `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 - `.Full`: `string` - the full version
- `.Major`: `string` - major number - `.Major`: `string` - major number

View file

@ -33,7 +33,17 @@ Display the currently active rust version.
- `always`: the segment is always displayed - `always`: the segment is always displayed
- `files`: the segment is only displayed when `*.rs`, `Cargo.toml` or `Cargo.lock` files are present (default) - `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 - `.Full`: `string` - the full version
- `.Major`: `string` - major number - `.Major`: `string` - major number

View file

@ -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 - `.UserName`: `string` - the current user's name
- `.HostName`: `string` - the current computer's name - `.HostName`: `string` - the current computer's name

View file

@ -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) - 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 - `.Name`: `string` - the shell name

View file

@ -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 ` - paused_icon: `string` - text/icon to show when paused - defaults to `\uF8E3 `
- stopped_icon: `string` - text/icon to show when stopped - defaults to `\uF04D ` - 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`) - `.Status`: `string` - player status (`playing`, `paused`, `stopped`)
- `.Artist`: `string` - current artist - `.Artist`: `string` - current artist

View file

@ -69,7 +69,17 @@ if that color is visible against any of your backgrounds.
- WorkOutIcon - defaults to `\ue213` - WorkOutIcon - defaults to `\ue213`
- UnknownActivityIcon - 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 The properties below are available for use in your template

View file

@ -31,7 +31,17 @@ Display SysInfo.
- Precision: `int` - The precision used for any float values - defaults to 2 - 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 - `.PhysicalTotalMemory`: `int` - is the total of used physical memory
- `.PhysicalFreeMemory`: `int` - is the total of free physical memory - `.PhysicalFreeMemory`: `int` - is the total of free physical memory

View file

@ -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 - `.WorkspaceName`: `string` - is the current workspace name

View file

@ -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 - `.Root`: `boolean` - is the current user root/admin or not
- `.Path`: `string` - the current working directory - `.Path`: `string` - the current working directory

View file

@ -25,11 +25,22 @@ Show the current timestamp.
- time_format: `string` - format to use, follows the [golang standard][format] - defaults to `15:04:05` - 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** - January 2, 2006 **Date**
- 01/02/06 - 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 MST 27e95cb
- Mon, 02 Jan 2006 15:04:05 -0700 **with numeric zone** - 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" - ANSIC = "Mon Jan _2 15:04:05 2006"
- UnixDate = "Mon Jan _2 15:04:05 MST 2006" - UnixDate = "Mon Jan _2 15:04:05 MST 2006"

View file

@ -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. - 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. - 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 - `.CummulativeTotal`: `wtTotals` - object holding total tracked time values
### wtTotal Properties ### wtTotals Properties
- `.Seconds`: `int` - a number reprecenting the total tracked time in seconds - `.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") - `.Text`: `string` - a string with human readable tracked time (eg: "2 hrs 30 mins")

View file

@ -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 - `.SSID`: `string` - the SSID of the current wifi network
- `.RadioType`: `string` - the radio type - _e.g. 802.11ac, 802.11ax, 802.11n, etc._ - `.RadioType`: `string` - the radio type - _e.g. 802.11ac, 802.11ax, 802.11n, etc._

View file

@ -38,7 +38,17 @@ Supported registry key types:
Ending path with \ will get the (Default) key from that path. Ending path with \ will get the (Default) key from that path.
- fallback: `string` - the value to fall back to if no entry is found - 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. - .Value: `string` - The result of your query, or fallback if not found.

View file

@ -38,7 +38,17 @@ Remote Control password.
- stopped_icon: `string` - text/icon to show when paused - defaults to `\uF04D ` - 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` - 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`) - `.Status`: `string` - player status (`playing`, `paused`, `stopped`)
- `.Artist`: `string` - current artist - `.Artist`: `string` - current artist

View file

@ -28,7 +28,7 @@ const (
) )
func (b *Battery) Template() string { 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 { func (b *Battery) Enabled() bool {

View file

@ -55,10 +55,6 @@ const (
BFCacheTimeout properties.Property = "cache_timeout" 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" BFStatusPlanning string = "Planning"
BFStatusBrewing string = "Brewing" BFStatusBrewing string = "Brewing"
BFStatusFermenting string = "Fermenting" BFStatusFermenting string = "Fermenting"
@ -101,7 +97,7 @@ type Batch struct {
} }
func (bf *Brewfather) Template() string { 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 { func (bf *Brewfather) Enabled() bool {

View file

@ -29,56 +29,56 @@ func TestNSSegment(t *testing.T) {
Case: "Flat 150", Case: "Flat 150",
JSONResponse: ` 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 [{"_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}}", Template: "\ue2a1 {{.Sgv}}{{.TrendIcon}}",
ExpectedString: " 150→", ExpectedString: "\ue2a1 150→",
ExpectedEnabled: true, ExpectedEnabled: true,
}, },
{ {
Case: "DoubleDown 50", Case: "DoubleDown 50",
JSONResponse: ` 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 [{"_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}}", Template: "\ue2a1 {{.Sgv}}{{.TrendIcon}}",
ExpectedString: " 50↓↓", ExpectedString: "\ue2a1 50↓↓",
ExpectedEnabled: true, ExpectedEnabled: true,
}, },
{ {
Case: "DoubleUp 250", Case: "DoubleUp 250",
JSONResponse: ` 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 [{"_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}}", Template: "\ue2a1 {{.Sgv}}{{.TrendIcon}}",
ExpectedString: " 250↑↑", ExpectedString: "\ue2a1 250↑↑",
ExpectedEnabled: true, ExpectedEnabled: true,
}, },
{ {
Case: "SingleUp 130", Case: "SingleUp 130",
JSONResponse: ` 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 [{"_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}}", Template: "\ue2a1 {{.Sgv}}{{.TrendIcon}}",
ExpectedString: " 130↑", ExpectedString: "\ue2a1 130↑",
ExpectedEnabled: true, ExpectedEnabled: true,
}, },
{ {
Case: "FortyFiveUp 174", Case: "FortyFiveUp 174",
JSONResponse: ` 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 [{"_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}}", Template: "\ue2a1 {{.Sgv}}{{.TrendIcon}}",
ExpectedString: " 174↗", ExpectedString: "\ue2a1 174↗",
ExpectedEnabled: true, ExpectedEnabled: true,
}, },
{ {
Case: "FortyFiveDown 61", Case: "FortyFiveDown 61",
JSONResponse: ` 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 [{"_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}}", Template: "\ue2a1 {{.Sgv}}{{.TrendIcon}}",
ExpectedString: " 61↘", ExpectedString: "\ue2a1 61↘",
ExpectedEnabled: true, ExpectedEnabled: true,
}, },
{ {
Case: "DoubleDown 50", Case: "DoubleDown 50",
JSONResponse: ` 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 [{"_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}}", Template: "\ue2a1 {{.Sgv}}{{.TrendIcon}}",
ExpectedString: " 50↓↓", ExpectedString: "\ue2a1 50↓↓",
ExpectedEnabled: true, ExpectedEnabled: true,
}, },
{ {
@ -96,8 +96,8 @@ func TestNSSegment(t *testing.T) {
Case: "DoubleDown 50 from cache", Case: "DoubleDown 50 from cache",
JSONResponse: ` 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 [{"_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}}", Template: "\ue2a1 {{.Sgv}}{{.TrendIcon}}",
ExpectedString: " 50↓↓", ExpectedString: "\ue2a1 50↓↓",
ExpectedEnabled: true, ExpectedEnabled: true,
CacheTimeout: 10, CacheTimeout: 10,
}, },
@ -105,8 +105,8 @@ func TestNSSegment(t *testing.T) {
Case: "DoubleDown 50 from cache not found", Case: "DoubleDown 50 from cache not found",
JSONResponse: ` 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 [{"_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}}", Template: "\ue2a1 {{.Sgv}}{{.TrendIcon}}",
ExpectedString: " 50↓↓", ExpectedString: "\ue2a1 50↓↓",
ExpectedEnabled: true, ExpectedEnabled: true,
CacheTimeout: 10, CacheTimeout: 10,
CacheFoundFail: true, CacheFoundFail: true,
@ -115,8 +115,8 @@ func TestNSSegment(t *testing.T) {
Case: "Error parsing response", Case: "Error parsing response",
JSONResponse: ` JSONResponse: `
4tffgt4e4567`, 4tffgt4e4567`,
Template: " {{.Sgv}}{{.TrendIcon}}", Template: "\ue2a1 {{.Sgv}}{{.TrendIcon}}",
ExpectedString: " 50↓↓", ExpectedString: "\ue2a1 50↓↓",
ExpectedEnabled: false, ExpectedEnabled: false,
CacheTimeout: 10, CacheTimeout: 10,
}, },
@ -124,7 +124,7 @@ func TestNSSegment(t *testing.T) {
Case: "Faulty template", Case: "Faulty template",
JSONResponse: ` JSONResponse: `
[{"sgv":50,"direction":"DoubleDown"}]`, [{"sgv":50,"direction":"DoubleDown"}]`,
Template: " {{.Sgv}}{{.Burp}}", Template: "\ue2a1 {{.Sgv}}{{.Burp}}",
ExpectedString: template.IncorrectTemplate, ExpectedString: template.IncorrectTemplate,
ExpectedEnabled: true, ExpectedEnabled: true,
CacheTimeout: 10, CacheTimeout: 10,

View file

@ -11,6 +11,7 @@ type Time struct {
env environment.Environment env environment.Environment
CurrentDate time.Time CurrentDate time.Time
Format string
} }
const ( const (
@ -19,11 +20,12 @@ const (
) )
func (t *Time) Template() string { func (t *Time) Template() string {
return "{{ .CurrentDate | date \"" + t.props.GetString(TimeFormat, "15:04:05") + "\" }}" return "{{ .CurrentDate | date .Format }}"
} }
func (t *Time) Enabled() bool { func (t *Time) Enabled() bool {
// if no date set, use now(unit testing) // if no date set, use now(unit testing)
t.Format = t.props.GetString(TimeFormat, "15:04:05")
if t.CurrentDate.IsZero() { if t.CurrentDate.IsZero() {
t.CurrentDate = time.Now() t.CurrentDate = time.Now()
} }