Skip to content

Alias Templates & Arguments

Aliases can pass arguments through unchanged or interpolate them into the command. The mode is detected automatically by whether the command contains any {…} placeholder.

When a command has no placeholders, extra arguments typed after the alias name are simply appended with safe quoting.

Terminal window
qwik add gs "git status"
gs --short # → git status --short

Any arguments after the alias name are shell-quoted and appended:

Terminal window
alias-with-spaces "two words"
# → the original command + 'two words' (safely quoted)

When a command contains {1}, {@}, {*}, or {1:-default}, qwik switches into template mode. Placeholders are substituted with the provided runtime arguments at their exact positions. Any arguments not consumed by placeholders are still appended after the command using safe quoting.

Placeholder Meaning
{1}, {2}, {3}… Nth positional argument (1-based)
{name} Named slot — mapped to a positional index by order of first appearance
{@} All arguments joined with spaces
{*} All arguments as a single quoted string
{1:-default} Nth positional, falling back to default if missing
{name:-default} Named slot, falling back to default if the arg is missing
Terminal window
qwik add gco "git checkout {1}"
gco main # → git checkout main
Terminal window
qwik add gcm 'git commit -m "{1}: {2}"'
gcm feat "add login"
# → git commit -m "feat: add login"
Terminal window
qwik add gco "git checkout {branch}"
gco main # → git checkout main
qwik add gcm 'git commit -m "{type}: {scope}"'
gcm feat login # → git commit -m "feat: login"

Named placeholders are mapped to positional arguments by order of first appearance: the first distinct name is {1}, the second is {2}, and so on. Repeating a name reuses its index (echo {a} {a} with arg x → echo x x). Named and numeric placeholders share the same index space — echo {1} {name} with args a b → echo a b ({1}=a, {name}=b at index 2).

{N:-default} is especially useful for aliases with a sensible fallback:

Terminal window
qwik add gpo "git push origin {1:-main}"
gpo # → git push origin main
gpo feature/x # → git push origin feature/x
Terminal window
qwik add gc-chore 'git commit -m "chore: {@}"'
gc-chore init version
# → git commit -m "chore: init version"
Terminal window
qwik add note 'echo "Note: {*}"'
note hello world
# → echo "Note: 'hello world'"
Terminal window
qwik add k "kubectl {1}"
k get pods -n kube-system
# → kubectl get pods -n kube-system
# {1}=get, "pods -n kube-system" appended after template
Terminal window
# Conventional commit with default scope
qwik add gcf 'git commit -m "feat({1:-core}): {@}"'
gcf api "add auth endpoint"
# → git commit -m "feat(api): add auth endpoint"
gcf "fix typo"
# → git commit -m "feat(core): fix typo"
Terminal window
# Get pods in a namespace (default: default)
qwik add kgp "kubectl get pods -n {1:-default}"
kgp
# → kubectl get pods -n default
kgp kube-system
# → kubectl get pods -n kube-system
Terminal window
# Make a directory and cd into it
qwik add mkcd 'mkdir -p {1} && cd {1}'
# Quick serve directory
qwik add serve "python3 -m http.server {1:-8080}"
# Copy with progress
qwik add cpv "rsync -ah --progress {1} {2}"

When you use a template alias with more arguments than placeholders consume, the extra ones are safely appended.

Terminal window
qwik add k "kubectl {1}"
# {1} gets 'get', then 'pods -n kube-system' is appended
k get pods -n kube-system
# → kubectl get pods -n kube-system

If all arguments are consumed by {@} or {*}, nothing is appended:

Terminal window
qwik add gc-chore 'git commit -m "chore: {@}"'
gc-chore fix typo
# → git commit -m "chore: fix typo"
# (nothing extra appended because {@} consumed both args)
  • {1}, {@}, and {N:-default} interpolations are quoted at runtime, so args containing shell metacharacters are passed safely
  • {*} wraps all arguments as a single shell-quoted string
  • {@} joins args with spaces (no extra quoting beyond join)

For example, qwik run gco '; rm -rf /' expands to git checkout '; rm -rf /' on a POSIX shell — the ; is quoted and treated as a literal argument, not a command separator.

The quoting rule depends on which shell will actually run the expanded command — chosen by qwik run’s shell detection, not by the host platform (a user can be running POSIX bash under Git Bash or WSL on a Windows host). Full per-shell details live in the Shell Quoting & Escaping reference.

If the expanded command contains shell metacharacters (;, |, &&, ||, >, <, ~, *, ?, $()), qwik automatically switches to shell=True execution. Otherwise it uses a safer argv list.

Terminal window
qwik add mkcd 'mkdir -p {1} && cd {1}'
# Contains && → runs via shell=True
Terminal window
qwik add bad "echo {0}"
# ✗ Error: {0} is not valid. Positional placeholders must be 1-based ({1}, {2}, ...).

{0} is rejected at add-time and at run-time — positional placeholders are 1-based. Invalid brace content (e.g. {123bad}, {some text}) is left untouched as a literal, not an error.

If a required positional is missing, a clear error is shown:

Terminal window
qwik add gco "git checkout {1}"
gco
# ✗ Error: Missing argument 1 for alias: "git checkout {1}" (received 0 argument(s))

Unlike raw shell aliases where missing $1 silently becomes empty, qwik tells you exactly what’s wrong. Use {1:-default} to avoid the error by providing a fallback:

Terminal window
qwik add gco "git checkout {1:-main}"
gco
# → git checkout main (no error — falls back to 'main')

One synced store, many machines. An alias can carry per-platform command variants so the same store works on a Linux workstation, a macOS laptop, and a Windows desktop:

[aliases.open]
command = "xdg-open {1}"
command_macos = "open {1}"
command_windows = "start {1}"

Resolution order (first match wins): command_<platform>_<shell> (e.g. command_windows_pwsh), then command_<platform>, then the base command. qwik init and qwik run resolve identically, so the hook and the subprocess always run the same command for your platform and shell.

Terminal window
qwik add open "xdg-open {1}" # base command
qwik add open "open {1}" --platform macos # adds a variant
qwik add open "start {1}" --platform windows
qwik show open # all variants, active one marked
qwik list --platform windows # preview another platform's resolution

Every variant is placeholder-validated at add time, and all variants must accept the same arguments as the base — xdg-open {1} with open {1} {2} is rejected. Per-shell variants (command_windows_pwsh, …) can be added with qwik edit.

  1. Use {1:-default} for optional args — provides a fallback and skips runtime validation
  2. Use {@} for “the rest” — convenient when the number of args varies
  3. Use {*} when you need a single string — messages, commit bodies, etc.
  4. You can mix placeholders — e.g. "echo {1} and {@}" (but be mindful of what gets duplicated)
  5. Defaults can be empty — {1:-} falls back to an empty string instead of erroring