Scroll to navigation

elvish-platform(7) Miscellaneous Information Manual elvish-platform(7)

Introduction

The platform: module provides access to the platform’s identifying data.

Variables

$platform:arch {#platform:arch}

The architecture of the platform; e.g. amd64, arm, ppc. This corresponds to Go’s GOARCH (https://pkg.go.dev/runtime?tab=doc#pkg-constants) constant. This is read-only.

$platform:is-unix {#platform:is-unix}

Whether or not the platform is UNIX-like. This includes Linux, macOS (Darwin), FreeBSD, NetBSD, and OpenBSD. This can be used to decide, for example, if the unix module is usable. This is read-only.

$platform:is-windows {#platform:is-windows}

Whether or not the platform is Microsoft Windows. This is read-only.

$platform:os {#platform:os}

The name of the operating system; e.g. darwin (macOS), linux, etc. This corresponds to Go’s GOOS (https://pkg.go.dev/runtime?tab=doc#pkg-constants) constant. This is read-only.

Functions

platform:hostname {#platform:hostname}

platform:hostname &strip-domain=$false
    

Outputs the hostname of the system. If the option &strip-domain is $true, strips the part after the first dot.

This function throws an exception if it cannot determine the hostname. It is implemented using Go’s os.Hostname (https://golang.org/pkg/os/#Hostname).

Examples:

~> platform:hostname
▶ lothlorien.elv.sh
~> platform:hostname &strip-domain=$true
▶ lothlorien
    
February 25, 2023 Elvish 0.18.0