This extension allows you to run either a default file* or a defined commands at VSCode startup.
It could be useful when you want to install automatically a private extension once VSCode is starting on a remote host. You can also set some default configuration for each user on managed laptop or remote server.
You have to create a file named vscode-startup-hook[.bat / .sh / .exe / .bin] on a specific folder. The extension and location depend of your OS and if want to run the script on local or on a remote server.
- $HOME_DIR/.vscode
- exemple:
C:\Users\colas\.vscode
- exemple:
- $HOME_DIR/.vscode-hook
- exemple:
C:\Users\colas\.vscode-hook
- exemple:
- ~/.vscode-server
- ~/.vscode-server-insiders
- ~/.vscode-remote
- ~/.vscode-hook
The extension was not tested on Windows server
- Windows: .bat / .sh / .exe
- Linux/ MAC: .bat / .sh / .exe
To run a .sh file on Windows user should have installed Git bash for exemple
You can also configure some custom command to run at each startup. The configuration should be put in settings.json
{
"hook.postStartup": [
"echo first command",
"/bin/bash ~/myScript.sh"
]
}
In your script you can use the command code
to install a public or private extension.
Read more about the command code
on the official documetation
If you want to run the command only once you can either disable to extension or uninstall it at the end of your script or commands, with respectively the following commands:
code --disable-extension colas.post-startup-hook
code --uninstall-extension colas.post-startup-hook
By default VSCode doen't provide any way to configure automatically your local instance. With the following configuration you can install automatically a private extension on your remote SSH instance an let your extension configure it.
- Set this configuration in your local VSCode (at the first initialization of VSCode on the remote host, it will install automically this public extension)
"remote.SSH.defaultExtensions": [
"colas.post-startup-hook"
]
- Exemple of script
~/.vscode-hook/vscode-startup-hook.sh
to create
#!/bin/sh
curl -o myPrivateExtension.vsix 'https://artifactory/myPrivateExtension.vsix'
code --install-extension myPrivateExtension.vsix --force
code --uninstall-extension colas.post-startup-hook