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.
Append mode (default — no placeholders)
Section titled “Append mode (default — no placeholders)”When a command has no placeholders, extra arguments typed after the alias name are simply appended with safe quoting.
qwik add gs "git status"gs --short # → git status --shortAny arguments after the alias name are shell-quoted and appended:
alias-with-spaces "two words"# → the original command + 'two words' (safely quoted)Template mode (placeholders)
Section titled “Template mode (placeholders)”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 reference
Section titled “Placeholder reference”| 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 |
Single positional
Section titled “Single positional”qwik add gco "git checkout {1}"gco main # → git checkout mainMultiple positionals
Section titled “Multiple positionals”qwik add gcm 'git commit -m "{1}: {2}"'gcm feat "add login"# → git commit -m "feat: add login"Named placeholders (readable)
Section titled “Named placeholders (readable)”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).
Default values
Section titled “Default values”{N:-default} is especially useful for aliases with a sensible fallback:
qwik add gpo "git push origin {1:-main}"gpo # → git push origin maingpo feature/x # → git push origin feature/xAll args joined
Section titled “All args joined”qwik add gc-chore 'git commit -m "chore: {@}"'gc-chore init version# → git commit -m "chore: init version"All args as one quoted string
Section titled “All args as one quoted string”qwik add note 'echo "Note: {*}"'note hello world# → echo "Note: 'hello world'"Mixed — template + appended extras
Section titled “Mixed — template + appended extras”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 templatePractical examples
Section titled “Practical examples”Git shortcuts
Section titled “Git shortcuts”# Conventional commit with default scopeqwik 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"Kubernetes shortcuts
Section titled “Kubernetes shortcuts”# Get pods in a namespace (default: default)qwik add kgp "kubectl get pods -n {1:-default}"kgp # → kubectl get pods -n defaultkgp kube-system # → kubectl get pods -n kube-systemGeneral utility
Section titled “General utility”# Make a directory and cd into itqwik add mkcd 'mkdir -p {1} && cd {1}'
# Quick serve directoryqwik add serve "python3 -m http.server {1:-8080}"
# Copy with progressqwik add cpv "rsync -ah --progress {1} {2}"How surplus arguments work
Section titled “How surplus arguments work”When you use a template alias with more arguments than placeholders consume, the extra ones are safely appended.
qwik add k "kubectl {1}"
# {1} gets 'get', then 'pods -n kube-system' is appendedk get pods -n kube-system # → kubectl get pods -n kube-systemIf all arguments are consumed by {@} or {*}, nothing is appended:
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)Escaping and safety
Section titled “Escaping and safety”Quoting behavior
Section titled “Quoting behavior”{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.
Shell metacharacters
Section titled “Shell metacharacters”If the expanded command contains shell metacharacters (;, |, &&, ||,
>, <, ~, *, ?, $()), qwik automatically switches to
shell=True execution. Otherwise it uses a safer argv list.
qwik add mkcd 'mkdir -p {1} && cd {1}'# Contains && → runs via shell=TrueValidation and error messages
Section titled “Validation and error messages”At add time
Section titled “At add time”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.
At runtime
Section titled “At runtime”If a required positional is missing, a clear error is shown:
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:
qwik add gco "git checkout {1:-main}"gco# → git checkout main (no error — falls back to 'main')Platform-Conditional Variants
Section titled “Platform-Conditional Variants”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.
qwik add open "xdg-open {1}" # base commandqwik add open "open {1}" --platform macos # adds a variantqwik add open "start {1}" --platform windows
qwik show open # all variants, active one markedqwik list --platform windows # preview another platform's resolutionEvery 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.
- Use
{1:-default}for optional args — provides a fallback and skips runtime validation - Use
{@}for “the rest” — convenient when the number of args varies - Use
{*}when you need a single string — messages, commit bodies, etc. - You can mix placeholders — e.g.
"echo {1} and {@}"(but be mindful of what gets duplicated) - Defaults can be empty —
{1:-}falls back to an empty string instead of erroring