Sublime Forum

Custom commands with variable input

#1

Hi,

I’m trying to create a custom command to be accessible through the command palette in Sublime Merge.
I’m doing this by editing A .sublime-commands file in my user folder.

[
    {
    "caption": "Git command",
    "command": "git",
    "args": {"argv": ["status"]}
    }
]

How do I make such a command accept an aditional variable input from the palette? Like a “-s” that the user enter in the palette in adition to the above command. So that the called command would be git status -s.

Thanks

´

0 Likes

#2

I don’t think that’s possible yet until a plugin system is in place. However, in the meantime, you can create multiple commands to accomplish the same goal.

0 Likes

#3
0 Likes

#4

how to custom command with the input?

0 Likes

#5

This need to be prioritized as it allows a user to workaround other unresolved issues.

0 Likes

#6

This was added in build 2034:

  • Added support for selector arguments to custom git commands ($select_branch, $select_local_branch, $select_remote_branch, $select_commit, $select_tag, $select_stash, $text)

So the OP’s example becomes:

[
    {
    "caption": "Git command",
    "command": "git",
    "args": {"argv": ["status", "$text"]}
    }
]

1 Like

#7

Thank you, that was exactly what I was looking for. I saw it in the changelog but wasn’t sure what it meant and how it was used. Now it’s all clear!

0 Likes