Skip to content

Add condition field to custom command prompts#5364

Merged
stefanhaller merged 1 commit intojesseduffield:masterfrom
mrt181:add-conditional-prompts
Apr 6, 2026
Merged

Add condition field to custom command prompts#5364
stefanhaller merged 1 commit intojesseduffield:masterfrom
mrt181:add-conditional-prompts

Conversation

@mrt181
Copy link
Copy Markdown

@mrt181 mrt181 commented Mar 12, 2026

When building multi-step custom command forms, some prompts are only relevant depending on earlier answers. Without conditional logic, users must dismiss irrelevant prompts manually.

Prompts now accept a condition field with a template expression evaluated against prior form values. Skipped prompts default to an empty string.

PR Description

Please check if the PR fulfills these requirements

  • Cheatsheets are up-to-date (run go generate ./...)
  • Code has been formatted (see here)
  • Tests have been added/updated (see here for the integration test guide)
  • Text is internationalised (see here)
  • If a new UserConfig entry was added, make sure it can be hot-reloaded (see here)
  • Docs have been updated if necessary
  • You've read through your own file changes for silly mistakes etc

@mrt181 mrt181 force-pushed the add-conditional-prompts branch from cfd9c66 to e934c7c Compare March 12, 2026 14:37
@mrt181 mrt181 force-pushed the add-conditional-prompts branch from e934c7c to 4040756 Compare March 16, 2026 14:31
@mrt181 mrt181 force-pushed the add-conditional-prompts branch 3 times, most recently from a51be39 to b117f12 Compare March 27, 2026 20:37
Copy link
Copy Markdown
Collaborator

@stefanhaller stefanhaller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks reasonable overall. A few things below.

@mrt181 mrt181 force-pushed the add-conditional-prompts branch from b117f12 to 0164659 Compare April 2, 2026 09:58
@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Apr 2, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 22 duplication

Metric Results
Complexity 0
Duplication 22

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@mrt181 mrt181 force-pushed the add-conditional-prompts branch 2 times, most recently from e9bcf6d to 980ff0a Compare April 2, 2026 21:21
When building multi-step custom command forms, some prompts are only
relevant depending on earlier answers. Without conditional logic,
users must dismiss irrelevant prompts manually.

Prompts now accept a `condition` field with a template expression
evaluated against prior form values. Skipped prompts default to
an empty string.

The template expression is a string pre- and suffixed with double curly
braces - {{}}.

Form keys can be reused, a guard ensures that skipped prompts do not
reset already set form keys with an empty string. This allows the
conditional flow to remind a user to set a key that was left empty
because additional conditions want that key to be set. This removes the
need to have additional if checks in the command that uses the form
keys.
@stefanhaller stefanhaller force-pushed the add-conditional-prompts branch from 980ff0a to 4cb6faf Compare April 6, 2026 17:14
@stefanhaller stefanhaller added the enhancement New feature or request label Apr 6, 2026
@stefanhaller stefanhaller enabled auto-merge April 6, 2026 17:16
@stefanhaller stefanhaller merged commit 7f5250a into jesseduffield:master Apr 6, 2026
14 checks passed
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Apr 8, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [jesseduffield/lazygit](https://github.com/jesseduffield/lazygit) | minor | `v0.60.0` → `v0.61.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>jesseduffield/lazygit (jesseduffield/lazygit)</summary>

### [`v0.61.0`](https://github.com/jesseduffield/lazygit/releases/tag/v0.61.0)

[Compare Source](jesseduffield/lazygit@v0.60.0...v0.61.0)

<!-- Release notes generated using configuration in .github/release.yml at v0.61.0 -->

The big one in this release is support for GitHub pull requests. They are shown as little GitHub icons next to each branch that has one, and you can open a MR in the browser by pressing shift-G. To enable this, all you need to do is install the [`gh`](https://cli.github.com/) tool if you haven't already, and log in using `gh auth login`.

#### What's Changed

##### Features ✨

- Show pull requests against branches by [@&#8203;jesseduffield](https://github.com/jesseduffield) in [#&#8203;2781](jesseduffield/lazygit#2781)

##### Enhancements 🔥

- Add support for clicking on arrows in the file list to expand/collapse directories by [@&#8203;blakemckeany](https://github.com/blakemckeany) in [#&#8203;5365](jesseduffield/lazygit#5365)
- Remove empty directories after discarding untracked files by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5408](jesseduffield/lazygit#5408)
- Make file sort order and case sensitivity configurable, and default to mix files and folders by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5427](jesseduffield/lazygit#5427)
- Allow customizing the window width/height thresholds for when to use portrait mode by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5452](jesseduffield/lazygit#5452)
- Log hashes of local branches when deleting them by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5441](jesseduffield/lazygit#5441)
- Add condition field to custom command prompts by [@&#8203;mrt181](https://github.com/mrt181) in [#&#8203;5364](jesseduffield/lazygit#5364)

##### Fixes 🔧

- Fix staging only some lines of a block of consecutive changes by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5396](jesseduffield/lazygit#5396)
- Fix the expanded layout of the branches panel (half and full screen modes) by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5413](jesseduffield/lazygit#5413)
- Fix searching commits or main view after switching repos by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5424](jesseduffield/lazygit#5424)
- Scroll to top when showing subcommits by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5425](jesseduffield/lazygit#5425)
- Fix patch commands when git config has color=always by [@&#8203;matthijskooijman](https://github.com/matthijskooijman) in [#&#8203;5405](jesseduffield/lazygit#5405)
- Don't stage out-of-date submodules when asking user to auto-stage after resolving conflicts by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5440](jesseduffield/lazygit#5440)

##### Maintenance ⚙️

- Remove go-git dependency by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5420](jesseduffield/lazygit#5420)
- Make Debian/Ubuntu install command architecture-independent by [@&#8203;discapes](https://github.com/discapes) in [#&#8203;5386](jesseduffield/lazygit#5386)
- Bump github.com/buger/jsonparser from 1.1.1 to 1.1.2 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;5423](jesseduffield/lazygit#5423)
- fix: pin 7 unpinned action(s), extract 1 inline secret to env var by [@&#8203;dagecko](https://github.com/dagecko) in [#&#8203;5439](jesseduffield/lazygit#5439)
- Fix dependabot config file by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5443](jesseduffield/lazygit#5443)
- Bump actions/cache from 4 to 5 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;5444](jesseduffield/lazygit#5444)
- Bump actions/download-artifact from 7 to 8 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;5445](jesseduffield/lazygit#5445)
- Bump actions/upload-artifact from 6 to 7 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;5446](jesseduffield/lazygit#5446)
- Bump github.com/lucasb-eyer/go-colorful from 1.3.0 to 1.4.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;5447](jesseduffield/lazygit#5447)
- Bump github.com/spf13/afero from 1.9.5 to 1.15.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;5448](jesseduffield/lazygit#5448)
- Bump github.com/creack/pty from 1.1.11 to 1.1.24 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;5449](jesseduffield/lazygit#5449)
- Bump github.com/stretchr/testify from 1.10.0 to 1.11.1 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;5450](jesseduffield/lazygit#5450)
- Bump github.com/sanity-io/litter from 1.5.2 to 1.5.8 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;5451](jesseduffield/lazygit#5451)
- Bump github.com/adrg/xdg from 0.4.0 to 0.5.3 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;5456](jesseduffield/lazygit#5456)
- Bump github.com/spkg/bom from 0.0.0-20160624110644-59b7046e48ad to 1.0.1 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;5457](jesseduffield/lazygit#5457)
- Bump github.com/integrii/flaggy from 1.4.0 to 1.8.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;5458](jesseduffield/lazygit#5458)
- Bump github.com/sahilm/fuzzy from 0.1.0 to 0.1.1 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;5459](jesseduffield/lazygit#5459)
- Bump github.com/sasha-s/go-deadlock from 0.3.6 to 0.3.9 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;5460](jesseduffield/lazygit#5460)

##### Docs 📖

- Add a note about AI to CONTRIBUTING.md by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5404](jesseduffield/lazygit#5404)
- Update redo keybinding in README.md by [@&#8203;unikitty37](https://github.com/unikitty37) in [#&#8203;5387](jesseduffield/lazygit#5387)
- Fix grammar in the contributor guide by [@&#8203;Rohan5commit](https://github.com/Rohan5commit) in [#&#8203;5392](jesseduffield/lazygit#5392)

##### I18n 🌎

- Update translations from Crowdin by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5476](jesseduffield/lazygit#5476)

##### Performance Improvements 📊

- Improve performance of discarding many files by [@&#8203;stefanhaller](https://github.com/stefanhaller) in [#&#8203;5407](jesseduffield/lazygit#5407)

#### New Contributors

- [@&#8203;blakemckeany](https://github.com/blakemckeany) made their first contribution in [#&#8203;5365](jesseduffield/lazygit#5365)
- [@&#8203;discapes](https://github.com/discapes) made their first contribution in [#&#8203;5386](jesseduffield/lazygit#5386)
- [@&#8203;unikitty37](https://github.com/unikitty37) made their first contribution in [#&#8203;5387](jesseduffield/lazygit#5387)
- [@&#8203;Rohan5commit](https://github.com/Rohan5commit) made their first contribution in [#&#8203;5392](jesseduffield/lazygit#5392)
- [@&#8203;matthijskooijman](https://github.com/matthijskooijman) made their first contribution in [#&#8203;5405](jesseduffield/lazygit#5405)
- [@&#8203;dagecko](https://github.com/dagecko) made their first contribution in [#&#8203;5439](jesseduffield/lazygit#5439)
- [@&#8203;mrt181](https://github.com/mrt181) made their first contribution in [#&#8203;5364](jesseduffield/lazygit#5364)

**Full Changelog**: <jesseduffield/lazygit@v0.60.0...v0.61.0>

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMDQuOCIsInVwZGF0ZWRJblZlciI6IjQzLjEwNC44IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiLCJhdXRvbWF0aW9uOmJvdC1hdXRob3JlZCIsImRlcGVuZGVuY3ktdHlwZTo6bWlub3IiXX0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants