Back to Chezmoi

Variables

assets/chezmoi.io/docs/reference/templates/variables.md

2.70.27.1 KB
Original Source

Variables

chezmoi provides the following automatically-populated variables:

VariableTypeValue
.chezmoi.archstringArchitecture, e.g. amd64, arm, etc. as returned by runtime.GOARCH
.chezmoi.args[]stringThe arguments passed to the chezmoi command, starting with the program command
.chezmoi.cacheDirstringThe cache directory
.chezmoi.configobjectThe configuration, as read from the config file
.chezmoi.configFilestringThe path to the configuration file used by chezmoi
.chezmoi.destDirstringThe destination directory
.chezmoi.executablestringThe path to the chezmoi executable, if available
.chezmoi.flagsobjectSelected flags passed to the chezmoi command
.chezmoi.fqdnHostnamestringThe fully-qualified domain name hostname of the machine chezmoi is running on
.chezmoi.gidstringThe primary group ID
.chezmoi.groupstringThe group of the user running chezmoi
.chezmoi.homeDirstringThe home directory of the user running chezmoi (with forward slashes as the path separator)
.chezmoi.hostnamestringThe hostname of the machine chezmoi is running on, up to the first .
.chezmoi.kernelobjectContains information from /proc/sys/kernel. Linux only, useful for detecting specific kernels (e.g. Microsoft's WSL kernel)
.chezmoi.osstringOperating system, e.g. darwin, linux, etc. as returned by runtime.GOOS
.chezmoi.osReleaseobjectThe information from /etc/os-release, Linux only, run chezmoi data to see its output
.chezmoi.pathListSeparatorstringThe path list separator, typically ; on Windows and : on other systems. Used to separate paths in environment variables. i.e., /bin:/sbin:/usr/bin
.chezmoi.pathSeparatorstringThe path separator, typically \ on windows and / on unix. Used to separate files and directories in a path. i.e., c:\see\dos\run
.chezmoi.rawHomeDirstringThe home directory of the user running chezmoi (with backslashes as the path separator on Windows)
.chezmoi.sourceDirstringThe source directory
.chezmoi.sourceFilestringThe path of the template relative to the source directory
.chezmoi.targetFilestringThe absolute path of the target file for the template
.chezmoi.uidstringThe user ID
.chezmoi.usernamestringThe username of the user running chezmoi
.chezmoi.version.builtBystringThe program that built the chezmoi executable, if set
.chezmoi.version.commitstringThe git commit at which the chezmoi executable was built, if set
.chezmoi.version.datestringThe timestamp at which the chezmoi executable was built, if set
.chezmoi.version.versionstringThe version of chezmoi
.chezmoi.windowsVersionobjectWindows version information, if running on Windows
.chezmoi.workingTreestringThe working tree of the source directory

.chezmoi.windowsVersion contains the following keys populated from the registry key Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion.

KeyType
currentBuildstring
currentMajorVersionNumberinteger
currentMinorVersionNumberinteger
currentVersionstring
displayVersionstring
editionIDstring
productNamestring

Additional variables can be defined in the config file in the data section. Variable names must consist of a letter and be followed by zero or more letters and/or digits.