diff --git a/pkg/gui/services/custom_commands/handler_creator.go b/pkg/gui/services/custom_commands/handler_creator.go
index bad972bd6..4a81b08b5 100644
--- a/pkg/gui/services/custom_commands/handler_creator.go
+++ b/pkg/gui/services/custom_commands/handler_creator.go
@@ -67,26 +67,38 @@ func (self *HandlerCreator) call(customCommand config.CustomCommand) func() erro
 			}
 
 			resolveTemplate := self.getResolveTemplateFn(form, promptResponses, sessionState)
-			resolvedPrompt, err := self.resolver.resolvePrompt(&prompt, resolveTemplate)
-			if err != nil {
-				return self.c.Error(err)
-			}
 
 			switch prompt.Type {
 			case "input":
 				f = func() error {
+					resolvedPrompt, err := self.resolver.resolvePrompt(&prompt, resolveTemplate)
+					if err != nil {
+						return self.c.Error(err)
+					}
 					return self.inputPrompt(resolvedPrompt, wrappedF)
 				}
 			case "menu":
 				f = func() error {
+					resolvedPrompt, err := self.resolver.resolvePrompt(&prompt, resolveTemplate)
+					if err != nil {
+						return self.c.Error(err)
+					}
 					return self.menuPrompt(resolvedPrompt, wrappedF)
 				}
 			case "menuFromCommand":
 				f = func() error {
+					resolvedPrompt, err := self.resolver.resolvePrompt(&prompt, resolveTemplate)
+					if err != nil {
+						return self.c.Error(err)
+					}
 					return self.menuPromptFromCommand(resolvedPrompt, wrappedF)
 				}
 			case "confirm":
 				f = func() error {
+					resolvedPrompt, err := self.resolver.resolvePrompt(&prompt, resolveTemplate)
+					if err != nil {
+						return self.c.Error(err)
+					}
 					return self.confirmPrompt(resolvedPrompt, g)
 				}
 			default:
diff --git a/pkg/integration/tests/custom_commands/menu_from_commands_output.go b/pkg/integration/tests/custom_commands/menu_from_commands_output.go
new file mode 100644
index 000000000..fdd207c4c
--- /dev/null
+++ b/pkg/integration/tests/custom_commands/menu_from_commands_output.go
@@ -0,0 +1,69 @@
+package custom_commands
+
+import (
+	"github.com/jesseduffield/lazygit/pkg/config"
+	. "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var MenuFromCommandsOutput = NewIntegrationTest(NewIntegrationTestArgs{
+	Description:  "Using prompt response in menuFromCommand entries",
+	ExtraCmdArgs: "",
+	Skip:         false,
+	SetupRepo: func(shell *Shell) {
+		shell.
+			EmptyCommit("foo").
+			NewBranch("feature/foo").
+			EmptyCommit("bar").
+			NewBranch("feature/bar").
+			EmptyCommit("baz")
+	},
+	SetupConfig: func(cfg *config.AppConfig) {
+		cfg.UserConfig.CustomCommands = []config.CustomCommand{
+			{
+				Key:     "a",
+				Context: "localBranches",
+				Command: "git checkout {{ index .PromptResponses 1 }}",
+				Prompts: []config.CustomCommandPrompt{
+					{
+						Type:         "input",
+						Title:        "Which git command do you want to run?",
+						InitialValue: "branch",
+					},
+					{
+						Type:        "menuFromCommand",
+						Title:       "Branch:",
+						Command:     `git {{ index .PromptResponses 0 }} --format='%(refname:short)'`,
+						Filter:      "(?P<branch>.*)",
+						ValueFormat: `{{ .branch }}`,
+						LabelFormat: `{{ .branch | green }}`,
+					},
+				},
+			},
+		}
+	},
+	Run: func(
+		shell *Shell,
+		input *Input,
+		assert *Assert,
+		keys config.KeybindingConfig,
+	) {
+		assert.WorkingTreeFileCount(0)
+		input.SwitchToBranchesWindow()
+
+		input.PressKeys("a")
+
+		assert.InPrompt()
+		assert.MatchCurrentViewTitle(Equals("Which git command do you want to run?"))
+		assert.MatchSelectedLine(Equals("branch"))
+		input.Confirm()
+
+		assert.InMenu()
+		assert.MatchCurrentViewTitle(Equals("Branch:"))
+		input.NextItem()
+		input.NextItem()
+		assert.MatchSelectedLine(Equals("master"))
+		input.Confirm()
+
+		assert.CurrentBranchName("master")
+	},
+})
diff --git a/pkg/integration/tests/tests.go b/pkg/integration/tests/tests.go
index f097b032d..6c074bb10 100644
--- a/pkg/integration/tests/tests.go
+++ b/pkg/integration/tests/tests.go
@@ -39,6 +39,7 @@ var tests = []*components.IntegrationTest{
 	custom_commands.Basic,
 	custom_commands.FormPrompts,
 	custom_commands.MenuFromCommand,
+	custom_commands.MenuFromCommandsOutput,
 	custom_commands.MultiplePrompts,
 	file.DirWithUntrackedFile,
 	interactive_rebase.AmendMerge,
diff --git a/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/COMMIT_EDITMSG
new file mode 100644
index 000000000..76018072e
--- /dev/null
+++ b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/COMMIT_EDITMSG
@@ -0,0 +1 @@
+baz
diff --git a/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/FETCH_HEAD b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/FETCH_HEAD
new file mode 100644
index 000000000..e69de29bb
diff --git a/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/HEAD b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/HEAD
new file mode 100644
index 000000000..cb089cd89
--- /dev/null
+++ b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/HEAD
@@ -0,0 +1 @@
+ref: refs/heads/master
diff --git a/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/config b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/config
new file mode 100644
index 000000000..2b89b8630
--- /dev/null
+++ b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/config
@@ -0,0 +1,12 @@
+[core]
+	repositoryformatversion = 0
+	filemode = true
+	bare = false
+	logallrefupdates = true
+[user]
+	email = CI@example.com
+	name = CI
+[commit]
+	gpgSign = false
+[protocol "file"]
+	allow = always
diff --git a/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/description b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/description
new file mode 100644
index 000000000..498b267a8
--- /dev/null
+++ b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/description
@@ -0,0 +1 @@
+Unnamed repository; edit this file 'description' to name the repository.
diff --git a/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/index b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/index
new file mode 100644
index 000000000..65d675154
Binary files /dev/null and b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/index differ
diff --git a/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/info/exclude b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/info/exclude
new file mode 100644
index 000000000..a5196d1be
--- /dev/null
+++ b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/info/exclude
@@ -0,0 +1,6 @@
+# git ls-files --others --exclude-from=.git/info/exclude
+# Lines that start with '#' are comments.
+# For a project mostly in C, the following would be a good set of
+# exclude patterns (uncomment them if you want to use them):
+# *.[oa]
+# *~
diff --git a/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/logs/HEAD b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/logs/HEAD
new file mode 100644
index 000000000..3905c1bad
--- /dev/null
+++ b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/logs/HEAD
@@ -0,0 +1,6 @@
+0000000000000000000000000000000000000000 44531ed59352b290ebe5d6bebeada267dff76fd5 CI <CI@example.com> 1669412559 +0100	commit (initial): foo
+44531ed59352b290ebe5d6bebeada267dff76fd5 44531ed59352b290ebe5d6bebeada267dff76fd5 CI <CI@example.com> 1669412559 +0100	checkout: moving from master to feature/foo
+44531ed59352b290ebe5d6bebeada267dff76fd5 b3518a56dbbd6df36eff0613aea30ab8e6659b26 CI <CI@example.com> 1669412559 +0100	commit: bar
+b3518a56dbbd6df36eff0613aea30ab8e6659b26 b3518a56dbbd6df36eff0613aea30ab8e6659b26 CI <CI@example.com> 1669412559 +0100	checkout: moving from feature/foo to feature/bar
+b3518a56dbbd6df36eff0613aea30ab8e6659b26 083b75d86104b3a7d89d9c355719b2aa9113cab9 CI <CI@example.com> 1669412559 +0100	commit: baz
+083b75d86104b3a7d89d9c355719b2aa9113cab9 44531ed59352b290ebe5d6bebeada267dff76fd5 CI <CI@example.com> 1669412567 +0100	checkout: moving from feature/bar to master
diff --git a/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/logs/refs/heads/feature/bar b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/logs/refs/heads/feature/bar
new file mode 100644
index 000000000..77d5c6099
--- /dev/null
+++ b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/logs/refs/heads/feature/bar
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 b3518a56dbbd6df36eff0613aea30ab8e6659b26 CI <CI@example.com> 1669412559 +0100	branch: Created from HEAD
+b3518a56dbbd6df36eff0613aea30ab8e6659b26 083b75d86104b3a7d89d9c355719b2aa9113cab9 CI <CI@example.com> 1669412559 +0100	commit: baz
diff --git a/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/logs/refs/heads/feature/foo b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/logs/refs/heads/feature/foo
new file mode 100644
index 000000000..a09bd9f99
--- /dev/null
+++ b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/logs/refs/heads/feature/foo
@@ -0,0 +1,2 @@
+0000000000000000000000000000000000000000 44531ed59352b290ebe5d6bebeada267dff76fd5 CI <CI@example.com> 1669412559 +0100	branch: Created from HEAD
+44531ed59352b290ebe5d6bebeada267dff76fd5 b3518a56dbbd6df36eff0613aea30ab8e6659b26 CI <CI@example.com> 1669412559 +0100	commit: bar
diff --git a/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/logs/refs/heads/master b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/logs/refs/heads/master
new file mode 100644
index 000000000..d1b8c187e
--- /dev/null
+++ b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/logs/refs/heads/master
@@ -0,0 +1 @@
+0000000000000000000000000000000000000000 44531ed59352b290ebe5d6bebeada267dff76fd5 CI <CI@example.com> 1669412559 +0100	commit (initial): foo
diff --git a/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/objects/08/3b75d86104b3a7d89d9c355719b2aa9113cab9 b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/objects/08/3b75d86104b3a7d89d9c355719b2aa9113cab9
new file mode 100644
index 000000000..e428309a2
--- /dev/null
+++ b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/objects/08/3b75d86104b3a7d89d9c355719b2aa9113cab9
@@ -0,0 +1,3 @@
+x��M
+�0@a�9E��L��H��1f�	
+ƖA<�=��Ƿxe��1�#8�]�F�>Ղ�Ab@����sn�	��x�װ�˜��T�-���+`Ɋ�H<~����y��y�����KY�d"E�S"{`�zL
����Y�9�
\ No newline at end of file
diff --git a/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/objects/44/531ed59352b290ebe5d6bebeada267dff76fd5 b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/objects/44/531ed59352b290ebe5d6bebeada267dff76fd5
new file mode 100644
index 000000000..07469bc40
Binary files /dev/null and b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/objects/44/531ed59352b290ebe5d6bebeada267dff76fd5 differ
diff --git a/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904
new file mode 100644
index 000000000..adf64119a
Binary files /dev/null and b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 differ
diff --git a/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/objects/b3/518a56dbbd6df36eff0613aea30ab8e6659b26 b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/objects/b3/518a56dbbd6df36eff0613aea30ab8e6659b26
new file mode 100644
index 000000000..5dca5a75d
Binary files /dev/null and b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/objects/b3/518a56dbbd6df36eff0613aea30ab8e6659b26 differ
diff --git a/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/refs/heads/feature/bar b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/refs/heads/feature/bar
new file mode 100644
index 000000000..9dfead794
--- /dev/null
+++ b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/refs/heads/feature/bar
@@ -0,0 +1 @@
+083b75d86104b3a7d89d9c355719b2aa9113cab9
diff --git a/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/refs/heads/feature/foo b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/refs/heads/feature/foo
new file mode 100644
index 000000000..0fd10f171
--- /dev/null
+++ b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/refs/heads/feature/foo
@@ -0,0 +1 @@
+b3518a56dbbd6df36eff0613aea30ab8e6659b26
diff --git a/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/refs/heads/master b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/refs/heads/master
new file mode 100644
index 000000000..203202599
--- /dev/null
+++ b/test/integration_new/custom_commands/menu_from_commands_output/expected/repo/.git_keep/refs/heads/master
@@ -0,0 +1 @@
+44531ed59352b290ebe5d6bebeada267dff76fd5