Updated Custom Commands Compendium (markdown)

Yang Cao 2021-12-28 13:58:23 +08:00
parent bb4730c9a0
commit 3aca417092

@ -121,6 +121,64 @@ customCommands:
valueFormat: '{{ .commit_id }}'
labelFormat: '{{ .commit_id | green | bold }} - {{ .commit_msg | yellow }}'
```
## Fetch a remote branch as a new local branch
```yml
customCommands:
- key: '<c-f>'
description: 'fetch a remote branch as a new local branch'
command: "git fetch {{index .SelectedRemote.Name }} {{index .PromptResponses 0}}:{{index .PromptResponses 1}}"
context: 'remotes'
prompts:
- type: 'input'
title: 'Remote Branch Name'
initialValue: ''
- type: 'input'
title: 'New Local Branch Name'
initialValue: ''
loadingText: 'fetching branch'
```
## Commit as non-default author
```yml
customCommands:
- key: '<c-c>'
description: 'commit as non-default author'
command: 'git commit -m "{{index .PromptResponses 0}}" --author="{{index .PromptResponses 1}} <{{index .PromptResponses 2}}>"'
context: 'files'
prompts:
- type: 'input'
title: 'Commit Message'
initialValue: ''
- type: 'input'
title: 'Author Name'
initialValue: ''
- type: 'input'
title: 'Email Address'
initialValue: ''
loadingText: 'commiting'
```
## Amend the author of last commit
```yml
customCommands:
- key: '<c-a>'
description: 'amend the author of last commit'
command: 'git commit --amend --author="{{index .PromptResponses 0}} <{{index .PromptResponses 1}}>"'
context: 'commits'
prompts:
- type: 'input'
title: 'Author Name'
initialValue: ''
- type: 'input'
title: 'Email Address'
initialValue: ''
subprocess: true
```
Example Usage on lazygit repo:
- Search word: `lazygit`
- Subtree/File: `**/commits.go`