-
Notifications
You must be signed in to change notification settings - Fork 1
Scripting
phlx0 edited this page Mar 15, 2026
·
1 revision
snip is designed to compose with other tools. Here are patterns for using it in scripts and automation.
Use -q to suppress the "Copied to clipboard" message so stdout is clean:
TOKEN=$(snip -q my-api-token)
curl -H "Authorization: Bearer $TOKEN" https://api.example.comsnip run deploy-prod
if [[ $? -ne 0 ]]; then
echo "deploy failed"
exit 1
fisnip -q my-sql-query | psql -U myuser mydb
snip -q nginx-config | ssh user@server "cat > /etc/nginx/nginx.conf"# Get the content field only
snip --json ports | jq -r '.content'
# Get tags
snip --json deploy | jq -r '.tags[]'
# Check language
snip --json myscript | jq -r '.language'snip --list | while read -r title; do
echo "=== $title ==="
snip -q "$title"
echo
donesnip --list startup | while read -r title; do
snip run "$title"
done# Add to crontab: crontab -e
0 9 * * * snip --export > ~/dotfiles/snippets-$(date +%F).jsonif snip -q mysnippet > /dev/null 2>&1; then
echo "found"
else
echo "not found"
fi