Skip to main content

Shell Variable

The shell variable type executes a shell command and captures its stdout output.

Basic Usage

- trigger: ":ip"
replace: "IP: {{ip}}"
vars:
- name: ip
type: shell
params:
cmd: "hostname -I | awk '{print $1}'"

Practical Examples

System Information

- trigger: ":disk"
replace: "Disk: {{disk}}"
vars:
- name: disk
type: shell
params:
cmd: "df -h / | tail -1 | awk '{print $3\"/\"$2\" (\"$5\")\"}'"

Uptime

- trigger: ":uptime"
replace: "Uptime: {{up}}"
vars:
- name: up
type: shell
params:
cmd: "uptime -p | sed 's/up //'"

File Listings

- trigger: ":files"
replace: "Files:\n{{files}}"
vars:
- name: files
type: shell
params:
cmd: "ls -la | head -10"

Weather (requires curl)

- trigger: ":weather"
replace: "{{weather}}"
vars:
- name: weather
type: shell
params:
cmd: "curl -s 'wttr.in?format=%C+%t'"

Dynamic Form Values

Shell variables can populate choice/list options dynamically:

- trigger: ":run"
replace: "Running: {{form.script}}"
vars:
- name: scripts
type: shell
params:
cmd: "ls ~/scripts/*.sh | xargs -n1 basename"
- name: form
type: form
params:
layout: "Select script: [[script]]"
fields:
script:
type: list
values: "{{scripts}}"

Security Notes

warning

Shell commands run with the privileges of the current user. Be careful with:

  • Commands that modify files or system state
  • Commands that include user-provided input
  • Commands in shared match files from untrusted sources

What's Next

Learn about Variable Chaining to combine multiple variables.