0

I'm working on a large angular / .NET Core project and have to type e.g. dotnet run /path/to/subproject in the terminal often.

Can I use VSCode to store/manage these common commands? I've been through the vscode docs on launch.json and tasks.json but cannot find a good answer.

Thanks!

1 Answers1

0

Yes, you have a couple of options.

(1) Set up a command to just rerun the last command - see Make a keybinding to run previous or last shell commands

{
  "key": "alt+x",          // choose your keybinding    
  "command": "workbench.action.terminal.sendSequence",    
  "args": { "text": "\u001b[A\u000d" }
},

or (2) just put your frequently-used command into a keybinding ala:

{
  "key": "alt+x",          // choose your keybinding    
  "command": "workbench.action.terminal.sendSequence",    
  "args": { "text": "dotnet run /path/to/subproject\u000d" },
  //  "when": "terminalFocus"
},

The \u000d is a return so the command runs immediately. I find it easiest to not have the when clause so I can run it from anywhere - editorFocus or terminalFocus, etc.

These go into your keybindings.json.

You can use variables where you have /path/to/subproject. See task - variable substitution and available variables which may help with your path.

Mark
  • 143,421
  • 24
  • 428
  • 436
  • I was actually hoping for something a little more concrete, something that could be checked into source control and not interfere with my and others' keybindings. – Jonathan Chukinas Jun 20 '20 at 17:29