Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

docs: add `wt step up` as example multi-line alias (#2078)

Maximilian Roos8c515ac72327
diff --git a/docs/content/step.md b/docs/content/step.md
index 9170eaaec..7b366526b 100644
--- a/docs/content/step.md
+++ b/docs/content/step.md
@@ -824,6 +824,22 @@ port = "echo http://localhost:{{ branch | hash_port }}"
{{ terminal(cmd="wt step deploy # run the alias|||wt step deploy --dry-run # show expanded command|||wt step deploy --var env=staging # pass extra template variables|||wt step deploy --yes # skip approval prompt") }}
+Multi-line aliases work too. This `up` alias fetches all remotes and rebases each worktree onto its upstream, skipping worktrees without a tracking branch or with a rebase already in progress:
+
+```toml
+# ~/.config/worktrunk/config.toml
+[aliases]
+up = '''
+git fetch --all --prune && wt step for-each -- '
+ git rev-parse --verify @{u} >/dev/null 2>&1 || exit 0
+ g=$(git rev-parse --git-dir)
+ test -d "$g/rebase-merge" -o -d "$g/rebase-apply" && exit 0
+ git rebase @{u} --no-autostash || git rebase --abort
+''''
+```
+
+{{ terminal(cmd="wt step up") }}
+
When defined in both user and project config, both run — user first, then project. Project-config aliases require [command approval](@/hook.md#wt-hook-approvals) on first run, same as project hooks. User-config aliases are trusted.
Inside an alias body, an inner `wt switch` (or `wt switch --create`) passes its `cd` through to the parent shell, so an alias wrapping `wt switch --create` lands the shell in the new worktree just like running it directly.
diff --git a/skills/worktrunk/reference/step.md b/skills/worktrunk/reference/step.md
index 35c79c827..c55023016 100644
--- a/skills/worktrunk/reference/step.md
+++ b/skills/worktrunk/reference/step.md
@@ -874,6 +874,24 @@ $ wt step deploy --var env=staging # pass extra template variables
$ wt step deploy --yes # skip approval prompt
```
+Multi-line aliases work too. This `up` alias fetches all remotes and rebases each worktree onto its upstream, skipping worktrees without a tracking branch or with a rebase already in progress:
+
+```toml
+# ~/.config/worktrunk/config.toml
+[aliases]
+up = '''
+git fetch --all --prune && wt step for-each -- '
+ git rev-parse --verify @{u} >/dev/null 2>&1 || exit 0
+ g=$(git rev-parse --git-dir)
+ test -d "$g/rebase-merge" -o -d "$g/rebase-apply" && exit 0
+ git rebase @{u} --no-autostash || git rebase --abort
+''''
+```
+
+```bash
+$ wt step up
+```
+
When defined in both user and project config, both run — user first, then project. Project-config aliases require [command approval](https://worktrunk.dev/hook/#wt-hook-approvals) on first run, same as project hooks. User-config aliases are trusted.
Inside an alias body, an inner `wt switch` (or `wt switch --create`) passes its `cd` through to the parent shell, so an alias wrapping `wt switch --create` lands the shell in the new worktree just like running it directly.
diff --git a/src/cli/mod.rs b/src/cli/mod.rs
index 70ad9037c..19b91733b 100644
--- a/src/cli/mod.rs
+++ b/src/cli/mod.rs
@@ -1164,6 +1164,24 @@ $ wt step deploy --var env=staging # pass extra template variables
$ wt step deploy --yes # skip approval prompt
```
+Multi-line aliases work too. This `up` alias fetches all remotes and rebases each worktree onto its upstream, skipping worktrees without a tracking branch or with a rebase already in progress:
+
+```toml
+# ~/.config/worktrunk/config.toml
+[aliases]
+up = '''
+git fetch --all --prune && wt step for-each -- '
+ git rev-parse --verify @{u} >/dev/null 2>&1 || exit 0
+ g=$(git rev-parse --git-dir)
+ test -d "$g/rebase-merge" -o -d "$g/rebase-apply" && exit 0
+ git rebase @{u} --no-autostash || git rebase --abort
+''''
+```
+
+```console
+$ wt step up
+```
+
When defined in both user and project config, both run — user first, then project. Project-config aliases require [command approval](@/hook.md#wt-hook-approvals) on first run, same as project hooks. User-config aliases are trusted.
Inside an alias body, an inner `wt switch` (or `wt switch --create`) passes its `cd` through to the parent shell, so an alias wrapping `wt switch --create` lands the shell in the new worktree just like running it directly.
diff --git a/tests/snapshots/integration__integration_tests__help__help_step_long.snap b/tests/snapshots/integration__integration_tests__help__help_step_long.snap
index 53e38a861..21bcada07 100644
--- a/tests/snapshots/integration__integration_tests__help__help_step_long.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_step_long.snap
@@ -112,6 +112,20 @@ Custom command templates configured in user config (~/.config/worktrunk/conf
  wt step deploy --var env=staging # pass extra template variables
  wt step deploy --yes # skip approval prompt
+Multi-line aliases work too. This up alias fetches all remotes and rebases each worktree onto its upstream, skipping worktrees without a tracking branch or with a rebase already in progress:
+
+  # ~/.config/worktrunk/config.toml
+  [aliases]
+  up = '''
+  git fetch --all --prune && wt step for-each -- '
+   git rev-parse --verify @{u} >/dev/null 2>&1 || exit 0
+   g=$(git rev-parse --git-dir)
+   test -d "$g/rebase-merge" -o -d "$g/rebase-apply" && exit 0
+   git rebase @{u} --no-autostash || git rebase --abort
+  ''''
+
+  wt step up
+
When defined in both user and project config, both run — user first, then project. Project-config aliases require command approval on first run, same as project hooks. User-config aliases are trusted.
Inside an alias body, an inner wt switch (or wt switch --create) passes its cd through to the parent shell, so an alias wrapping wt switch --create lands the shell in the new worktree just like running it directly.