Skip to content

Instantly share code, notes, and snippets.

@oktomus
Last active November 11, 2025 13:00
Show Gist options
  • Select an option

  • Save oktomus/e284923a7fce837615bb756a1060e5dc to your computer and use it in GitHub Desktop.

Select an option

Save oktomus/e284923a7fce837615bb756a1060e5dc to your computer and use it in GitHub Desktop.
Fork custom commands

With custom commands, you are one shortcut away to run commands thanks to the Quick Launch (Ctrl+P, ⌘+P).

Custom commands can be configured in File > Preferences > Custom commands, or by editing the json file custom-commands.json located in AppData/Local/Fork on Windows and ~/Library/Application Support/com.DanPristupov.Fork/custom-commands.json on MacOS.

Please share your own custom commands :)

How to use

Fork commands are posted as comments on this gist. Press CTRL+F to search for commands.

Then, copy-paste the commands you need in custom-commands.json.

Make sure to close Fork before editing the json file.

@russellweed
Copy link

Here's mine:

Target Name Type Title Description Script Path Button 1 Button 2
Repository Show Unmerged Branches UI Show Unmerged Branches Which branch do you want to check for unmerged branches? $git branch --no-merged origin/develop -a branch --no-merged origin/master -a

@oktomus
Copy link
Author

oktomus commented May 1, 2021

Thanks @russellweed, I will add it to the gist

@Lawendt
Copy link

Lawendt commented May 21, 2021

It would be awesome to also provide the JSON of this commands. You can find it on windows on AppData\Local\Fork

@russellweed
Copy link

russellweed commented May 21, 2021

@Lawendt Thanks for the tip. Didn't know where they were stored.

AppData\Local\Fork\custom-commands.json

[
  {
    "name": "Show Unmerged Branches",
    "target": "repository",
    "ui": {
      "title": "Show Unmerged Branches",
      "description": "Which branch do you want to check for unmerged branches?",
      "buttons": [
        {
          "title": "develop",
          "action": {
            "type": "process",
            "path": "$git",
            "args": "branch --no-merged origin/develop -a",
            "showOutput": true,
            "waitForExit": true
          }
        },
        {
          "title": "master",
          "action": {
            "type": "process",
            "path": "$git",
            "args": "branch --no-merged origin/master -a",
            "showOutput": true,
            "waitForExit": true
          }
        }
      ]
    }
  }
]

I think this format just works better overall too, and makes contributing a lot easier.

@oktomus
Copy link
Author

oktomus commented May 22, 2021

Great idea, I'm going to edit it
Thanks @Lawendt

@Lawendt
Copy link

Lawendt commented May 22, 2021

Also sharing mine

Show which branches contain the selected commit:

{
    "name": "Which branches contain this commit",
    "target": "revision",
    "action": {
      "type": "process",
      "path": "$git",
      "args": "branch -a -r --contains $SHA",
      "showOutput": true,
      "waitForExit": true
    }
  }

@sundeepgupta
Copy link

On macOS, it's located in ~/Library/Application Support/com.DanPristupov.Fork/custom-commands.json

@ewnu
Copy link

ewnu commented May 12, 2022

For making compact archive(respects .gitignore)

{
    "action" : {
      "showOutput" : false,
      "args" : "archive --format=tar.gz --output=$path\/$reponame_$sha.tar.gz $SHA",
      "path" : "$git",
      "type" : "process",
      "waitForExit" : true
    },
    "name" : "Archive '$name'",
    "target" : "revision"
}

@ewnu
Copy link

ewnu commented May 12, 2022

Ask to run git gc --aggressive on this repository(It's located in 'Open In' menu)

{
    "target" : "repository",
    "ui" : {
      "buttons" : [
        {
          "title" : "OK",
          "action" : {
            "showOutput" : false,
            "type" : "process",
            "waitForExit" : true,
            "args" : "gc --aggressive",
            "path" : "$git"
          }
        },
        {
          "title" : "Cancel",
          "action" : {
            "type" : "cancel"
          }
        }
      ],
      "title" : "Garbage Collect",
      "description" : "Are you sure you want to run \"git gc --aggressive\" ?"
    },
    "name" : "Garbage Collect"
}

@ewnu
Copy link

ewnu commented May 12, 2022

For macos, open this repo in kitty terminal

{
    "name" : "Open in Kitty",
    "target" : "repository",
    "action" : {
      "showOutput" : false,
      "waitForExit" : true,
      "type" : "process",
      "args" : "-n -a kitty $path --args -1 -d $path",
      "path" : "\/usr\/bin\/open"
    }
}

@reggian
Copy link

reggian commented Jun 9, 2022

Rebase Recursively
Commit context menu. Rebases the current branch onto the selected commit.

  {
    "name" : "Rebase Recursively to Here",
    "target" : "revision",
    "ui" : {
      "description" : "Are you sure you want to rebase the current branch recursively onto this commit?",
      "buttons" : [
        {
          "action" : {
            "args" : "rebase -r $SHA",
            "showOutput" : true,
            "path" : "$git",
            "type" : "process",
            "waitForExit" : true
          },
          "title" : "Proceed"
        },
        {
          "title" : "Cancel",
          "action" : {
            "type" : "cancel"
          }
        }
      ],
      "title" : "Rebase Recursively"
    }
  }

@oktomus
Copy link
Author

oktomus commented Jun 9, 2022

Amend

run amend

Amend your staged changes into the last commit.

  {
    "name": "Amend",
    "target": "repository",
    "action": {
      "type": "process",
      "path": "$git",
      "args": "commit --amend --no-edit",
      "showOutput": false,
      "waitForExit": true
    }
  }

Commit summary

  {
    "name": "Commit summary",
    "target": "repository",
    "action": {
      "type": "process",
      "path": "$git",
      "args": "show  --compact-summary",
      "showOutput": true,
      "waitForExit": true
    }
  }

For a specific file type:

  {
    "name": "C# Commit summary",
    "target": "repository",
    "action": {
      "type": "process",
      "path": "$git",
      "args": "show  --compact-summary *.cs",
      "showOutput": true,
      "waitForExit": true
    }
  }

Show branches containing the selected commit

{
  "name": "Which branches contain this commit",
  "target": "revision",
  "action": {
    "type": "process",
    "path": "$git",
    "args": "branch -a -r --contains $SHA",
    "showOutput": true,
    "waitForExit": true
  }
}

Show unmerged branches

show unmerged branches

  {
    "name": "Show Unmerged Branches",
    "target": "repository",
    "ui": {
      "title": "Show Unmerged Branches",
      "description": "Which branch do you want to check for unmerged branches?",
      "buttons": [
        {
          "title": "develop",
          "action": {
            "type": "process",
            "path": "$git",
            "args": "branch --no-merged origin/develop -a",
            "showOutput": true,
            "waitForExit": true
          }
        },
        {
          "title": "master",
          "action": {
            "type": "process",
            "path": "$git",
            "args": "branch --no-merged origin/master -a",
            "showOutput": true,
            "waitForExit": true
          }
        }
      ]
    }
  }

@tadija
Copy link

tadija commented Jun 28, 2022

"Open PR on Github" (for the selected commit):

{
  "action" : {
    "showOutput" : false,
    "type" : "sh",
    "waitForExit" : true,
    "script" : "pr_id=$(git log --oneline -n 1 $sha | grep -o '(#[0-9]\\+' | cut -c3- | tail -1)\nrepo_url=$(git config remote.origin.url | sed -e 's\/git@\/https:\\\/\\\/\/' -e 's\/\\.git$\/\/' | sed -E 's\/(\\\/\\\/[^:]*):\/\\1\\\/\/')\npr_url=$(echo $repo_url\/pull\/$pr_id)\nopen $pr_url"
  },
  "name" : "Open PR on Github",
  "target" : "revision"
}

@matic1123
Copy link

matic1123 commented Nov 29, 2022

Ill share mine, for MacOS and JB users. Open in Rider and Open in WebStorm custom commands:

  {
    "name" : "Open in Rider",
    "action" : {
      "type" : "sh",
      "script" : "~\/Library\/Application\\ Support\/JetBrains\/Toolbox\/scripts\/rider .",
      "showOutput" : false,
      "waitForExit" : true
    },
    "target" : "repository"
  },
  {
    "target" : "repository",
    "name" : "Open in WebStorm",
    "action" : {
      "showOutput" : false,
      "type" : "sh",
      "waitForExit" : true,
      "script" : "~\/Library\/Application\\ Support\/JetBrains\/Toolbox\/scripts\/webstorm ."
    }
  }

@bbilginn
Copy link

I was looking for some flavour then found this and wanted to share it here :)
fork-dev/TrackerWin#961

@JessyCatterwaul
Copy link

I don't understand what "UI" vs. "Action" is. Is there documentation?

I'm looking to trigger a script upon committing to a specific branch, to perform work locally instead of on a GitHub runner. Is this possible, or will it require triggering a command from the command-P menu?

@kroer
Copy link

kroer commented Nov 1, 2025

Is there a way to add a cutom command (with repository as target) as button on top panel next to the stash?

@chrift
Copy link

chrift commented Nov 11, 2025

I'm confused about these custom commands - does anyone know how to make it so I can use a keyboard shortcut to commit & push in one go?
I don't want it to automatically push all the time, so don't want to turn that option on, but sometimes the precommit takes an annoyingly long time so i just want the option for it to push automatically without me having to sit and watch it and then push.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment