Skip to content

Custom Commands Compendium

sportshead edited this page Dec 25, 2020 · 48 revisions

If you have implemented a custom command(s) that you find useful, please add it here so others can find it too. If a particular command proves popular, we will merge it into the codebase for all to use.

If you want to know how to implement your own custom commands see here

Creating a review in Gerrit

customCommands:
  - key: '<c-p>'
    command: "git push origin HEAD:refs/for/{{.CheckedOutBranch.Name}}"
    context: 'global'
    loadingText: 'pushing'

Pushing to a specific remote branch

customCommands:
  - key: '<c-p>'
    context: 'global'
    loadingText: 'pushing'
    prompts:
      - type: 'input'
        title: 'which branch do you want to push to?'
    command: "git push origin {{index .PromptResponses 0}}"

Creating an annotated tag

  - key : 'N'
    description: 'create annotated tag'
    command: "git tag -a {{index .PromptResponses 0}} -m \"{{index .PromptResponses 1}}\""
    context: 'tags'
    prompts:
      - type: 'input'
        title: 'Annotated tag name:'
      - type: 'input'
        title: 'Annotated tag message:'

Open GitHub Pull Request

customCommands:
  - key: "<c-r>"
    command: "gh pr create --fill --web"
    context: "global"
    loadingText: "Creating pull request on GitHub"

This can be customized to fit your needs. Run gh pr create --help to see what flags are available.

Checkout branch via Github Pull Request id

customCommands:
  - key: "v" # couldn't think of a better keybinding
    prompts:
      - type: 'input'
        title: 'PR id:'
    command: "hub pr checkout {{index .PromptResponses 0}}"
    context: "localBranches"
    loadingText: "checking out PR"

Opening git mergetool

customCommands:
  - key: "M"
    command: "git mergetool {{ .SelectedFile.Name }}"
    context: "files"
    loadingText: "opening git mergetool"
    subprocess: true

Pruning deleted remote branches

customCommands:
    - key: "<c-p>"
      command: "git remote prune {{.SelectedRemote.Name}}"
      context: "remotes"
      loadingText: "Pruning..."
      description: "prune deleted remote branches"
Clone this wiki locally