Sublime Forum

Custom command not appearing in pallet

#1

I’m on Linux (Ubuntu) using build 2020. I added a custom command to /home/icholy/.config/sublime-merge/Packages/User/Default.sublime-commands.

[
  {
    "caption": "Switch Branch",
    "command": "git",
    "args": {"argv": ["switch", "$select_branch"]}
  }
]

After restarting, the command doesn’t show up in the command pallet. I’m not sure how to debug further.

0 Likes

#2

Custom commands where added in Dev Build 2034. You are on an old stable build. I’d recommend upgrading to the latest stable build which is Build 2063 at the time of writing this.

1 Like

#3

Ah, thanks. I was using an old build from the snap store.

0 Likes

#4

@UltraInstinct05 is there a way to map key bindings to custom commands? I want to remap ctrl+b to my “Switch Branch” command.

0 Likes

#5

You can yes. Given the nature of these selectors (they need to be executed via the command palette to show the list), it will be slightly different from the direct command palette entry in .sublime-commands. Basically you need to execute the git command via the show_command_palette command to get the same effect as directly adding it to the command palette

Go to your user key bindings by navigating to Preferences -> Edit Key Bindings ... from the main menu. There paste the following.

{
    "keys": ["ctrl+b"],
    "command": "show_command_palette",
    "args": {
        "command": "git",
        "args": {"argv": ["switch", "$select_branch"]},
        "description": "Switch Branch",
    },
}

This should then show the same command palette UI for picking a branch to switch to (same as your command palette entry).

The only thing I fail to understand is why the description arg is not working. That arg is used for showing an InputHandler label description. In your command palette entry case, it would be Switch Branch. Here it is somehow Git because it fails (?). The functionality should still work though.

1 Like

#6

Thank you so much! The description is working correctly on my end.

0 Likes