sublimehq / sublime_merge

Issue tracker for Sublime Merge
https://www.sublimemerge.com
272 stars 14 forks source link

custom menu item disabled #1917

Open br4nnigan opened 1 month ago

br4nnigan commented 1 month ago

Version info

Description

it seems that using any other command than "git" in custom menus leads to the menu item being ignored. Example Commit.sublime-menu:

    [
        {
            "caption": "Show branches containing this commit",
            "command": "git",
            "args": {"argv": ["branch", "-a", "--contains", "$commit"]}
        },
        {
            "caption": "Find merge commit",
            "command": "/home/me/bin/find_merge.sh",
            "args": {"argv": ["$commit"]}
        },
        {
            "caption": "Find merge commit2",
            "command": "/bin/sh",
            "args": {"argv": ["-c", "'commit=$commit && branch=${1:-HEAD} && (git rev-list $commit..$branch --ancestry-path | cat -n; git rev-list $commit..$branch --first-parent | cat -n) | sort -k2 -s | uniq -f1 -d | sort -n | tail -1 | cut -f2'"]}
        },
        {
            "caption": "test",
            "command": "sh",
            "args": {"argv": []}
        }
    ]

Only the first one works

dpjohnst commented 1 month ago

G'day @br4nnigan,

Thanks for reaching out!

The command portion of the menu item refers to a Sublime Merge command. Sublime Merge currently doesn't support running ad-hoc processes.

As a temporary work-around you can define a git alias to run your scripts, and then run the associated alias through the git command.

  1. Add your custom alias using the following git command git config alias.customalias '!f() { echo $1; }; f'
  2. Add the associated command definition to your menu file
    {
            "caption": "My Custom Command",
            "command": "git",
            "args": {"argv": ["customalias", "$commit"]}
    },

Cheers, - Dylan from Sublime HQ