mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 04:45:47 +02:00
Add docs for menuFromCommand prompts
This commit is contained in:
parent
d18c8c8dc3
commit
9daa47fb2d
2 changed files with 19 additions and 3 deletions
|
@ -35,6 +35,18 @@ customCommands:
|
||||||
command: "git flow {{index .PromptResponses 0}} start {{index .PromptResponses 1}}"
|
command: "git flow {{index .PromptResponses 0}} start {{index .PromptResponses 1}}"
|
||||||
context: 'localBranches'
|
context: 'localBranches'
|
||||||
loadingText: 'creating branch'
|
loadingText: 'creating branch'
|
||||||
|
- key : 'r'
|
||||||
|
description: 'Checkout a remote branch as FETCH_HEAD'
|
||||||
|
command: "git fetch {{index .PromptResponses 0}} {{index .PromptResponses 1}} && git checkout FETCH_HEAD"
|
||||||
|
context: 'remotes'
|
||||||
|
prompts:
|
||||||
|
- type: 'input'
|
||||||
|
title: 'Remote:'
|
||||||
|
initialValue: "{{index .SelectedRemote.Name }}"
|
||||||
|
- type: 'menuFromCommand'
|
||||||
|
title: 'Remote branch:'
|
||||||
|
command: 'git branch -r --list {{index .PromptResponses 0}}/*'
|
||||||
|
filter: '.*{{index .PromptResponses 0}}/(.*)'
|
||||||
```
|
```
|
||||||
|
|
||||||
Looking at the command assigned to the 'n' key, here's what the result looks like:
|
Looking at the command assigned to the 'n' key, here's what the result looks like:
|
||||||
|
@ -85,6 +97,10 @@ The permitted prompt fields are:
|
||||||
| title | the title to display in the popup panel | no |
|
| title | the title to display in the popup panel | no |
|
||||||
| initialValue | (only applicable to 'input' prompts) the initial value to appear in the text box | no |
|
| initialValue | (only applicable to 'input' prompts) the initial value to appear in the text box | no |
|
||||||
| options | (only applicable to 'menu' prompts) the options to display in the menu | no |
|
| options | (only applicable to 'menu' prompts) the options to display in the menu | no |
|
||||||
|
| command | (only applicable to 'menuFromCommand' prompts) the command to run to generate | yes |
|
||||||
|
| | menu options | |
|
||||||
|
| filter | (only applicable to 'menuFromCommand' prompts) the regexp to run specify groups | yes |
|
||||||
|
| | which are going to be kept from the command's output | |
|
||||||
|
|
||||||
The permitted option fields are:
|
The permitted option fields are:
|
||||||
| _field_ | _description_ | _required_ |
|
| _field_ | _description_ | _required_ |
|
||||||
|
|
|
@ -179,11 +179,11 @@ func (gui *Gui) handleCustomCommandKeybinding(customCommand config.CustomCommand
|
||||||
var candidates []string
|
var candidates []string
|
||||||
reg := regexp.MustCompile(filter)
|
reg := regexp.MustCompile(filter)
|
||||||
for _,str := range strings.Split(string(message), "\n"){
|
for _,str := range strings.Split(string(message), "\n"){
|
||||||
cand := str
|
cand := ""
|
||||||
if str != "" {
|
if str != "" {
|
||||||
for i := 1; i < (reg.NumSubexp()+1); i++ {
|
for i := 1; i < (reg.NumSubexp()+1); i++ {
|
||||||
trim := reg.ReplaceAllString(str, "${"+fmt.Sprint(i)+"}")
|
keep := reg.ReplaceAllString(str, "${"+fmt.Sprint(i)+"}")
|
||||||
cand = strings.Trim(cand, trim)
|
cand += keep
|
||||||
}
|
}
|
||||||
candidates = append(candidates, cand)
|
candidates = append(candidates, cand)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue