Skip to content

Instantly share code, notes, and snippets.

@kvz
Created April 8, 2025 07:56
Show Gist options
  • Save kvz/5ae34553c7f8fea3978c232fe81deec8 to your computer and use it in GitHub Desktop.
Save kvz/5ae34553c7f8fea3978c232fe81deec8 to your computer and use it in GitHub Desktop.
saveWIPAndSync
// Add this to your keybindings.json, you can find it by typing Keyboard from the command palette
...
{
"key": "shift+cmd+enter",
"command": "workbench.action.tasks.runTask",
"args": "saveWIPAndSync"
}
...
// Place this in your .vscode dir in the repo where you want to use this
{
"version": "2.0.0",
"tasks": [
{
"label": "saveWIPAndSync",
"type": "shell",
"command": "branch=$(git rev-parse --abbrev-ref HEAD); if [ \"$branch\" = \"main\" ]; then echo 'Error: Cannot commit WIP to main branch.'; exit 1; else git add . && git commit -m 'Save WIP state' && git push; fi",
"problemMatcher": [],
"presentation": {
"reveal": "never"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment