Skip to content

feat: multi-step aliases with scoped env vars #100

Description

@sassman

Currently an alias maps to a single command string. This adds support for sequencing multiple commands and declaring scoped environment variables — without shell-specific syntax like && or export.

Proposed CLI (open for discussion)

# multi-step — runs with && semantics, stops on first failure
am add deploy \
  --cmd "cargo build --release" \
  --cmd "scp target/release/app server:/app"

# scoped env vars — visible to all steps, don't leak into the shell after
am add test \
  --env "NODE_ENV=production" \
  --env "DEBUG=1" \
  --cmd "npm run build" \
  --cmd "npm test"

# single command with env var still works
am add test --env "NODE_ENV=production" "npm test"

Flag names (--cmd, --env) and their short forms are not finalized. Alternatives under consideration for the step flag: --run, --do, --and, --exec.

Expected generated output (bash/zsh)

test() {
  local -x NODE_ENV=production
  local -x DEBUG=1
  npm run build && npm test
}

Expected generated output (fish)

function test
  set -lx NODE_ENV production
  set -lx DEBUG 1
  npm run build
  and npm test
end

Proposed am ls display

Single-step aliases are unchanged. Multi-step aliases expand into a nested tree, consistent with how subcommand groups are already rendered:

🌐 global
│  ├─ gs → git status
│  ├─ deploy  [2 steps]
│  │  ├─ cargo build --release
│  │  ╰─ scp dist server:/app
│  ╰─ test  [NODE_ENV=production] [DEBUG=1]
│     ├─ npm run build
│     ╰─ npm test
│
╰─● work (active: 1)
     ╰─ …

Display format is a proposal — exact rendering of env vars and step count indicators open for discussion.

Scope

  • Repeatable --cmd flag for sequenced commands (&& semantics, fail-fast)
  • Repeatable --env flag for scoped vars (KEY=VALUE, local to function, exported to child processes)
  • All existing shells: bash, zsh, fish, powershell, brush
  • raw is incompatible with multi-step (error if combined)
  • No implicit $@ on multi-step — use {{@}} explicitly in any step that should receive args
  • TUI editing of multi-step aliases: out of scope for this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions