Skip to main content

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:

NameTypeDescriptionExample
.Shellstringthe current shell name{{ .Shell }}
.Homestringthe user's $HOME folder{{ .Home }}/go/bin/aliae
.OSstringthe current operating system (windows, darwin, linux){{ .Home }}/go/bin/aliae{{ if eq .OS "windows" }}.exe{{ end }}
.Archstringthe aliae executable's compiled architecture{{ .Home }}/go/bin/aliae-{{ .Arch }}{{ if eq .OS "windows" }}.exe{{ end }}
.Hostnamestringthe machine's hostname{{ .Hostname }}
.ConfigPathstringthe directory containing the loaded aliae config file{{ .ConfigPath }}/themes
envstringretrieve an environment variable value{{ env "POSH_THEME" }}
matchbooleanmatch a shell name to one or multiple options{{ match .Shell "zsh" "bash" }}
hasCommandbooleancheck if an executable exists{{ hasCommand "oh-my-posh" }}
dirAccessiblebooleancheck if a directory exists and is traversable{{ dirAccessible "/opt/homebrew/bin" }}
pathAccessiblebooleancheck if a path exists and is readable{{ pathAccessible "/etc/hosts" }}
wslPathstringconvert 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'