Install & quick start
YAML.sh ships as one executable text file containing its shell launcher and AWK engine.
Install
With Homebrew:
brew install azohra/tools/ysh
Or download the release directly. The installer verifies its pinned SHA-256 digest before writing the file:
curl -fsSL https://yaml.azohra.com/install | sh
Choose another destination without sudo:
curl -fsSL https://yaml.azohra.com/install | YSH_INSTALL_DIR="$HOME/.local/bin" sh
Read-only commands need a POSIX-compatible /bin/sh and AWK. --check, --diff, and -i also use the host's mktemp, cp, cmp, mv, rm, and wc. No other language runtime is required.
Read YAML
Given config.yml:
server:
host: localhost
ports: [8080, 8443]
services:
- name: api
enabled: true
Select a scalar:
ysh '.server.host' config.yml
# localhost
Select a sequence item or filter a stream:
ysh '.server.ports[1]' config.yml
# 8443
ysh '.services[] | select(.enabled) | .name' config.yml
# api
Collections print as compact JSON by default:
ysh '.services[0]' config.yml
# {"name":"api","enabled":true}
Omit the file to read standard input:
printf '%s\n' 'answer: 42' | ysh '.answer'
Change YAML
Print transformed YAML without changing the file:
ysh -o=yaml '.release.channel = "stable"' config.yml
Preview the exact in-place change:
ysh --diff '.release.channel = "stable"' config.yml
Then write it:
ysh -i '.release.channel = "stable"' config.yml
Common edits retain comments and surrounding formatting. Add --preserve-only to fail rather than regenerate YAML when a change cannot be made safely in the original source. See multiple documents and file edits for check mode, multi-file changes, and exact write guarantees.
Build and convert
Use -n to create a document without reading input:
ysh -n -o=yaml '{name: "api", enabled: true}'
Input can also be JSON, TOML, INI, or XML:
ysh '.database.port' config.toml
ysh -p xml -o json '.catalog.item' catalog.xml