Sublime Forum

Custom command selectors are replaced by empty string with no prompt


I’m trying to use selectors in a custom command to push a renamed remote ref from my local branch. Something like this:

"caption": "Push Renamed",
"command": "git",
"args": {
    "argv": ["push", "origin", "$head:$text"],
    "prompt": true,

However, this doesn’t work and tries to run git push origin <head>:. I want it to prompt the user for text to name the remote branch and then run the command with that text, like git push origin <head>:<user-text>.

It seems like selectors are only observed if they’re the only value for an argument. Since Git’s push subcommand doesn’t support accepting a destination except as part of the ref argument, it seems like there might be no way to do this unless Sublime Merge interpolated selectors into strings.



This is a known limitation of the current stable build, but dev build 2080 (released Dec 5th) includes the changelog item:

Custom commands now support selectors anywhere in an argument

So, I would imagine that this should be possible in that version or in the next stable version whenever that lands.



Thanks! That gets me a little bit closer, but it looks like this only works if there is only a single selector in the argument? Adding a variable causes it to no longer work. So, for instance, the command above still doesn’t work, but if I remove If I remove $head from the last argument, a palette to type in the $text value appears.



If that’s the case and you’re on that build, it might be worth an issue. There are a few git commands that require arguments that need more than one of these, so I would guess that that would be more in the spirit of what this was intended to fix.



Sounds good – I’ve filed on the issue tracker.