Documentation menu

Template Variables

Every context field an action's command can use, both as a Go template field and as a HERDR_PLUS_* environment variable.

Every action’s command template can use these fields. The same values are also exported to the command’s environment with a HERDR_PLUS_ prefix — so a script that would rather not bother with templating can read them straight from the environment.

The variables

TemplateEnv varMeaning
{{.Value}}HERDR_PLUS_VALUESelected option / entered text (select & form).
{{.WorkDir}}HERDR_PLUS_WORKDIRDirectory you launched herdr-plus from.
{{.SessionTitle}}HERDR_PLUS_SESSION_TITLEherdr workspace label (often the repo name).
{{.SessionId}}HERDR_PLUS_SESSION_IDherdr workspace id.
{{.WorkspaceLabel}}HERDR_PLUS_WORKSPACE_LABELSame as SessionTitle.
{{.WorkspaceId}}HERDR_PLUS_WORKSPACE_IDSame as SessionId.
{{.TabLabel}}HERDR_PLUS_TAB_LABELherdr tab label.
{{.TabId}}HERDR_PLUS_TAB_IDherdr tab id.
{{.PaneId}}HERDR_PLUS_PANE_IDPane you launched from.
{{.TerminalId}}HERDR_PLUS_TERMINAL_IDherdr terminal id.
{{.Agent}}HERDR_PLUS_AGENTAgent running in the pane, if any.
{{.AgentSessionId}}HERDR_PLUS_AGENT_SESSION_IDThat agent’s session id.
{{.Home}}Your home directory.

Two ways to use them

Every field above is available both as a Go template field in the command and as a HERDR_PLUS_ environment variable when the command runs. For example, {{.WorkDir}} is also $HERDR_PLUS_WORKDIR.

Note: {{.Home}} is the one exception — it is available as a template field but has no environment variable.

Examples

Using a variable in the command template — open the launch directory in your file manager:

name = "Reveal Working Dir"
description = "Open the launch directory"
type = "command"
command = "open {{.WorkDir}}"

Using the environment variable instead — a command that prefers $HERDR_PLUS_* over templating:

name = "Print Context"
description = "Echo the workspace label and working dir"
type = "command"
command = 'echo "workspace=$HERDR_PLUS_WORKSPACE_LABEL dir=$HERDR_PLUS_WORKDIR"'

Tip: Any field herdr can’t supply is left empty rather than failing — a partial context is better than refusing to launch. Fields like {{.Agent}} or {{.AgentSessionId}} will be blank when no agent is running in the pane.

See also

Spot something off? Edit this page on GitHub ↗