Sublime Forum

Key Command To Stash With Arguments


I’m trying to modify the default ctrl+s key binding to stash including untracked files, but I can’t find a way to do it. The default command looks like:

{ "keys": ["ctrl+s"], "command": "stash" }

and I’ve tried several likely alternatives such as

{ "keys": ["ctrl+s"], "command": "stash", "args": { "include_untracked": true } }
{ "keys": ["ctrl+s"], "command": "stash_include_untracked" }

but because Sublime Merge doesn’t have a list of all available commands/arguments I can’t find it. Any idea if there’s a hidden command or argument I’m missing, and if so how to find them myself in the future?



What you want is this:

  { "keys": ["ctrl+s"], 
    "command": "stash", 
    "args": {
      "message": "",
      "options": ["--include-untracked", 0]

The easiest way to determine information like this very similar to how you would do the same thing in Sublime Text (since the two products share a common code base).

In Sublime Text, you would View > Show Console to see the console, enter sublime.log_commands(True) to turn on command logging, and then trigger the command as normal (key binding, menu entry, command palette) and the console will tell you what command was executed and with which arguments.

The process is similar in Sublime Merge, except that you use Tools > Show Console instead (although it is the same key binding in both apps if you’re famliar with that), and the console has no input widget in it.

So to turn on logging, Preferences > Edit Settings... and add "log_commands": true, as a preference to turn on logging.

Once that’s done you can trigger the command (in this case from the stash dropbown) and the log will tell you what it did:

command: stash {"message": "", "options": ["--include-untracked", 0]}
Executing: git stash push --include-untracked

Here the first line is showing the command and arguments to use, and the second one is showing merge responding with the resulting git command.

Unlike in Text, where command logging will turn itself off when you quit and restart the app (unless you turn it off yourself), the setting in Merge will persist with command logging until you turn it off.