Templates
Exampleโ
env:
- name: POSH_THEME
value: '{{ .Home }}/.configs/posh.omp.yaml'
Descriptionโ
Some fields have text/template abilities, allowing to reuse the same configuration across multiple environments resulting in environment specific values.
Out of the box you get the following functionality:
| Name | Type | Description | Example |
|---|---|---|---|
.Shell | string | the current shell name | {{ .Shell }} |
.Home | string | the user's $HOME folder | {{ .Home }}/go/bin/aliae |
.OS | string | the current operating system (windows, darwin, linux) | {{ .Home }}/go/bin/aliae{{ if eq .OS "windows" }}.exe{{ end }} |
.Arch | string | the aliae executable's compiled architecture | {{ .Home }}/go/bin/aliae-{{ .Arch }}{{ if eq .OS "windows" }}.exe{{ end }} |
.Hostname | string | the machine's hostname | {{ .Hostname }} |
.ConfigPath | string | the directory containing the loaded aliae config file | {{ .ConfigPath }}/themes |
env | string | retrieve an environment variable value | {{ env "POSH_THEME" }} |
match | boolean | match a shell name to one or multiple options | {{ match .Shell "zsh" "bash" }} |
hasCommand | boolean | check if an executable exists | {{ hasCommand "oh-my-posh" }} |
dirAccessible | boolean | check if a directory exists and is traversable | {{ dirAccessible "/opt/homebrew/bin" }} |
pathAccessible | boolean | check if a path exists and is readable | {{ pathAccessible "/etc/hosts" }} |
wslPath | string | convert a Windows path to its WSL equivalent | {{ wslPath "C:\\Documents\\theme.omp.yml" }} |
tip
wslPath relies on the wslpath binary, which only exists inside WSL's interop layer. Outside
WSL (or if the binary can't convert the given path) it returns the path unchanged, so it's safe to
use unconditionally in a config shared across machines.
tip
When using a template in a single line, you have to use quotes to wrap the template string.
env:
- name: POSH_THEME
value: '{{ .Home }}/.configs/posh.omp.yaml'